werewolf-1.5.1.1: A game engine for playing werewolf within an arbitrary chat client

Copyright(c) Henry J. Wylde 2016
LicenseBSD3
Maintainerpublic@hjwylde.com
Safe HaskellNone
LanguageHaskell2010

Game.Werewolf.Response

Contents

Description

A response is used as a return result of calling the werewolf binary. Each response has a list of associated messages.

werewolf was designed to be ambivalent to the playing chat client. The response-message structure reflects this by staying away from anything that could be construed as client-specific. This includes features such as emoji support.

Synopsis

Response

data Response Source #

When a user sends a command to the werewolf binary, a response is always returned.

The chat interface should then relay any messages from the response. Whether or not the command was valid (indicated by the ok flag) is often irrelevant as the returned messages will include errors to the user.

Constructors

Response 

Fields

Instances

Common responses

success :: Response Source #

A successful, empty response.

failure :: Response Source #

An unsuccessful, empty response.

Exit functions

exitWith :: MonadIO m => Response -> m a Source #

Exits fast with the given response. The response is encoded as JSON, printed to stdout and then the program is exited with 0 (success).

The program always exits with success even if the response was a failure one. This is to distinguish between bad calls to the binary and bad commands to the werewolf engine.

Message

data Message Source #

A message may be either public or private, indicated by its to field.

Each message contains a single text field. This field is permitted to contain special characters such as new lines and tabs.

Constructors

Message 

Fields

Instances

Eq Message Source # 

Methods

(==) :: Message -> Message -> Bool #

(/=) :: Message -> Message -> Bool #

Show Message Source # 
Generic Message Source # 

Associated Types

type Rep Message :: * -> * #

Methods

from :: Message -> Rep Message x #

to :: Rep Message x -> Message #

ToJSON Message Source # 
FromJSON Message Source # 
type Rep Message Source # 
type Rep Message = D1 (MetaData "Message" "Game.Werewolf.Response" "werewolf-1.5.1.1-It4Ni5CeXewBRmJehTXowY" False) (C1 (MetaCons "Message" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "to") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text))) (S1 (MetaSel (Just Symbol "message") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text))))

publicMessage :: Text -> Message Source #

Creates a public message with the given text.

privateMessage :: Text -> Text -> Message Source #

privateMessage to message

Creates a private message to to with the given text.

groupMessages :: [Text] -> Text -> [Message] Source #

groupMessages tos message

Creates multiple private messages (1 to each recipient) with the given text.