werewolf-1.0.2.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

ok :: Bool

Boolean flag to indicate success.

messages :: [Message]

List of messages.

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 it's 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

to :: Maybe Text

The message recipient: Nothing for a public message, Just for a private message.

message :: Text

The message 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.