werewolf-1.5.2.0: 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

Description

Re-exports all of the public modules under Game.Werewolf. These are:

N.B., where clashes are found between Game.Werewolf.Player, Game.Werewolf.Role and Game.Werewolf.Variant, the Game.Werewolf.Player functions are preferred.

Synopsis

Documentation

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 # 
Instance details

Defined in Game.Werewolf.Response

Methods

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

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

Show Message Source # 
Instance details

Defined in Game.Werewolf.Response

Generic Message Source # 
Instance details

Defined in Game.Werewolf.Response

Associated Types

type Rep Message :: * -> * #

Methods

from :: Message -> Rep Message x #

to :: Rep Message x -> Message #

ToJSON Message Source # 
Instance details

Defined in Game.Werewolf.Response

FromJSON Message Source # 
Instance details

Defined in Game.Werewolf.Response

type Rep Message Source # 
Instance details

Defined in Game.Werewolf.Response

type Rep Message = D1 (MetaData "Message" "Game.Werewolf.Response" "werewolf-1.5.2.0-AiL3EiiR9OnCXND4I095yn" False) (C1 (MetaCons "Message" PrefixI True) (S1 (MetaSel (Just "to") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe Text)) :*: S1 (MetaSel (Just "message") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text)))

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
Eq Response Source # 
Instance details

Defined in Game.Werewolf.Response

Show Response Source # 
Instance details

Defined in Game.Werewolf.Response

Generic Response Source # 
Instance details

Defined in Game.Werewolf.Response

Associated Types

type Rep Response :: * -> * #

Methods

from :: Response -> Rep Response x #

to :: Rep Response x -> Response #

ToJSON Response Source # 
Instance details

Defined in Game.Werewolf.Response

FromJSON Response Source # 
Instance details

Defined in Game.Werewolf.Response

type Rep Response Source # 
Instance details

Defined in Game.Werewolf.Response

type Rep Response = D1 (MetaData "Response" "Game.Werewolf.Response" "werewolf-1.5.2.0-AiL3EiiR9OnCXND4I095yn" False) (C1 (MetaCons "Response" PrefixI True) (S1 (MetaSel (Just "ok") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool) :*: S1 (MetaSel (Just "messages") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Message])))

success :: Response Source #

A successful, empty response.

failure :: Response Source #

An unsuccessful, empty response.

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.

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.

data Activity Source #

Defines whether a role is diurnal or nocturnal. I.e., if the role's turn occurs during the day or night.

Constructors

Diurnal 
Nocturnal 
Instances
Eq Activity Source # 
Instance details

Defined in Game.Werewolf.Role

Read Activity Source # 
Instance details

Defined in Game.Werewolf.Role

Show Activity Source # 
Instance details

Defined in Game.Werewolf.Role

Humanise Activity Source # 
Instance details

Defined in Game.Werewolf.Role

data Allegiance Source #

The NoOne allegiance is used for the Loners. It is not used to determine who has won (i.e., if one Loner wins, the others still lose).

data Role Source #

Role definitions require only a few pieces of information.

The balance attribute on a role indicates the allegiance it favours. For example, a Simple Werewolf has a balance of -4 while the Seer has a balance of 2. A balance of 0 means it favours neither allegiance.

N.B., role equality is defined on just the tag as a role's allegiance may change throughout the game.

Instances
Eq Role Source # 
Instance details

Defined in Game.Werewolf.Role

Methods

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

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

Read Role Source # 
Instance details

Defined in Game.Werewolf.Role

Show Role Source # 
Instance details

Defined in Game.Werewolf.Role

Methods

showsPrec :: Int -> Role -> ShowS #

show :: Role -> String #

showList :: [Role] -> ShowS #

Humanise Role Source # 
Instance details

Defined in Game.Werewolf.Role

Methods

humanise :: Role -> Text Source #

allRoles :: [Role] Source #

A list containing all the roles defined in this file.

restrictedRoles :: [Role] Source #

A list containing roles that are restricted to a single instance per Game.

  restrictedRoles = allRoles \\ [simpleVillagerRole, simpleWerewolfRole, spitefulVillagerRole, zombieRole]
  

orphanRole :: Role Source #

Abandoned by their parents as a child, with no-one wanting to look after another mouth to feed, the Orphan was left to fend for themself. No-one looked twice at the Orphan and even fewer showed kindness towards the lonely child. One day however, one townsperson changed all this. He offered the Orphan food, water and a roof over their head. Grateful for his chairty and affection, the Orphan made him their role model. Pray that no ill should befall their role model, for they are the only one conforming the Orphan as a Villager.

On the first night, the Orphan chooses a player to become their role model. So long as the role model is alive, the Orphan is a Villager. If however the role model is eliminated, then the Orphan becomes a Werewolf.

villageDrunkRole :: Role Source #

Hah, maybe not as liked as the Jester, but the Drunk sure does their fair share of stupid things in the night! No-one knows if they even actually make it home; sometimes people see them sleeping outside the Blacksmith's home, others say they see them wandering towards the woods. It's pointless quizzing the Village Drunk in the morning about their doings; they can never remember what they did!

The Village Drunk is initially aligned with the Villagers.

On the third night the Village Drunk sobers up and is randomly assigned a new alignment, either Villagers or Werewolves.

dullahanRole :: Role Source #

Normally the Dullahan carries their head under one arm, however while amongst the Villagers, they ere on the side of caution and rest it in a more traditional place. The Dullahan rides a black horse as dark as night and hunts down travellers in the countryside. Beware if the Dullahan knows your name, for you are then marked for death and you should avoid them at all /costs.

The Dullahan is given a list of player names at the start of the game. To win, they must eliminate all of them before the end of the game.

fallenAngelRole :: Role Source #

Long ago during the War in Heaven, angels fell from the sky as one by one those that followed Lucifer were defeated. For centuries they lived amongst mortal Villagers as punishment for their sins and wrongdoings. The Fallen Angel was one such being and is now one of the few angels left on Earth. Nothing is worse punishment for them, the Fallen Angel yearns for death to once again be free!

The Fallen Angel wins if they manage to get lynched by the Villagers before the end of the game.

necromancerRole :: Role Source #

The dead are feared among the living; the dead outnumber the living. In most villages the dead remain that way, but not when the Necromancer is present. The Necromancer devoted their life to learning black magic and methods of bringing people back to life. Unfortunately this art is hard to perfect and all they can manage to bring back are soulless Zombies.

Once per game the Necromancer can choose to resurrect all dead players as Zombies. The Zombies are aligned with the Necromancer and they cannot be lynched or devoured.

If the Necromancer is killed, all Zombies die with them.

The Necromancer and Zombies win if they are the last ones alive.

zombieRole :: Role Source #

A loyal follower of the Necromancer. A Zombie has no mind of its own and blindly obeys every command of their master.

A Zombie wins with the Necromancer. They cannot be killed, however they die when the Necromancer dies.

beholderRole :: Role Source #

Awareness comes easy to the Beholder. They listen to their senses and trust their hunches. Over the years the Beholder has grown to know a certain few of the village just by paying attention. Little cues here and there, the way someone talks, the way they move - it all gives clues as to their true nature and role.

At the start of the game the Beholder is informed the Seer's identity.

crookedSenatorRole :: Role Source #

Never trust a politician. Nor a Crooked Senator for that matter. The Crooked Senator may seem like he has the village's best interests at heart, but let's be honest, when put in a tough situation he looks after no-one but himself. Even when safe, the Crooked Senator may decide to toy with the Villagers' emotions and try pit them against one another.

The Crooked Senator looks at the village votes as they come in.

druidRole :: Role Source #

How honoured we are to be in the presence of such a noble leader. The return of the Druid marks an exceptional time in Fougères's history! Friend of the woodland creatures, practiced philosopher and now, with the help of Ferina their companion, a bane to the Werewolves themselves! My does she have a nose on her, strong enough to sniff out lycanthropes in close proximity! Listen for her grunt and heed her warning for she will not let you down.

Each morning when Ferina wakes from her slumber she will be alert and cautious. If the Druid is next to a Werewolf in the player circle then Ferina will grunt in warning.

hunterRole :: Role Source #

A skilled marksman with quick reflexes. In the unfortunate situation that they are jumped and killed unjustly, they let off a shot at their attacker, killing them instantly. The Hunter never misses.

If the Hunter is killed they choose one player, believed to be an attacker, to kill immediately.

jesterRole :: Role Source #

Every village needs a Jester; they're so stupid, but provide so much entertainment! The Jester may not have any special abilities, but at least no-one in the village wants to hurt them.

If the village votes to lynch the Jester, their identity is revealed. The village realise there's no point in burning them and so they are set free.

The Jester continues to play but may no longer vote as no-one can take them seriously.

lycanRole :: Role Source #

Traditionally a Werewolf once transformed loses all memories and personality. Over years of transforming, the Lycan has slowly evolved and learnt how to retain themself. Night after night of devouring with the other Werewolves took its toll. The screams alone were enough to turn the Lycan and make them question their true nature.

The Lycan is aligned with the Villagers, but appears to nature-seeing roles (e.g., the Seer) as a Werewolf.

medusaRole :: Role Source #

A beautiful flirt, the Medusa is aligned with the Villagers but harbours a terrifying secret. During the day they are well known in the village of Fougères for their stunning appearance which captures the eye and love of all the townsfolk. However when their secret takes ahold at sundown, their true self is revealed. Any who gaze upon her true form would see live snakes for hair and the few that further look into her eyes are turned to stone.

If Medusa attracts the attention of a Werewolf during the night and is devoured, the first Werewolf to their left in the player circle will catch their gaze and turn to stone, instantly killing the lupine predator.

oracleRole :: Role Source #

Originally rejected by the townsfolk, the Oracle's prophetic divinations has earned trust within the village. With constant precognition - and concern for the future - the Oracle knows the village will only live if they work together.

Each night the Oracle chooses a player to divine. They are then informed of the player's role the following morning. This wisdom is for the Oracle to use to ensure the future of Fougères.

protectorRole :: Role Source #

The Protector is one of the few pure of heart and altruistic Villagers; they are forever putting others needs above their own. Each night they fight against the Werewolves with naught but a sword and shield, potentially saving an innocents life.

Each night the Protector chooses a player deemed worthy of their protection. That player is safe for that night (and only that night) against the Werewolves.

The Protector may not protect the same player two nights in a row.

saintRole :: Role Source #

The Saint, also historically known as a hallow, is recognized as having an exceptional degree of holiness and likeness to God. They are a humble Villager and shine light on these dark times. Extinguishing this light would not be wise

If the Saint is lynched by the village, all who voted for them die.

scapegoatRole :: Role Source #

Werewolves don't just spring up out of the ground! That's where dwarves come from. Clearly someone is to blame for this affliction to Fougères. Unluckily for the Scapegoat, since no-one actually knows who brought them here, the blame is always laid upon them!

If the village's vote ends in a tie, it's the Scapegoat who is eliminated instead of no-one.

In this event, the Scapegoat has one last task to complete: they must choose whom is permitted to vote or not on the next day.

seerRole :: Role Source #

The Seer has the ability to see into fellow townsfolk and determine their true nature. This ability to see is not given out lightly, for certain it is a gift! The visions will always be true, but only for the present as not even the Seer knows what the future holds.

Each night the Seer sees the allegiance of one player of their choice.

simpleVillagerRole :: Role Source #

A simple, ordinary townsperson in every way. Some may be cobblers, others bakers or even nobles. No matter their differences though, the plight of Werewolves in Fougères unites all the Villagers in this unfortunate time.

The Simple Villager has no special abilities, they must use their guile to determine whom among them is not who they say they are.

spitefulVillagerRole :: Role Source #

A simple, ordinary townsperson in every way. Some may be cobblers, others bakers or even nobles. No matter their differences though, the plight of Werewolves in Fougères unites all the Villagers in this unfortunate time.

Yet the Spiteful Villager has no loyalty in the afterlife; whoever causes them harm may find themselves in trouble.

When the Spiteful Villager is killed, they are informed of everyone's roles and may haunt the village as they wish.

trueVillagerRole :: Role Source #

The True Villager has a heart and soul as clear as day! Their allegiance and devotion to the village are beyond reproach. If there is one person whom you should confide in, listen to and trust, it is the True Villager.

At the start of the game the True Villager's identity is revealed.

witchRole :: Role Source #

Somehow forgotten with the coming of the Werewolves, the Witch has a chance to prove themself valuable to the village and maybe abolish the absurd pastime of burning and drowning their cult. The Witch is blessed (or maybe cursed) with the ability to make two powerful potions; one of which heals a victim of the Werewolves, the other poisons a player.

The Witch is called after the Werewolves. They are able to heal and poison one player per game. There is no restriction on using both potions in one night or on healing themself.

alphaWolfRole :: Role Source #

The Alpha Wolf leads the Werewolves in the raids against Fougères each night and not even the Seer can see them coming. If the Werewolves caused the Villagers to question and accuse one another beforehand, the Alpha Wolf eliminates any shred of humanity left. No-one can be trusted anymore and no-one knows the truth.

The Alpha Wolf appears to nature-seeing roles (e.g., the Seer) as a Villager.

simpleWerewolfRole :: Role Source #

The Simple Werewolf is a fearsome lupine, cunning like no other creature that roams the forest. Their origin is unknown, but that matters little, for they present a grave threat to Fougères. While each day they hide in plain sight as an ordinary Villager, each night they transform and devour an innocent. There is little hope left for the village.

A Werewolf may never devour another Werewolf.

data State Source #

Surprise surprise, players may be Dead or Alive.

Constructors

Alive 
Dead 
Instances
Eq State Source # 
Instance details

Defined in Game.Werewolf.Player

Methods

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

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

Read State Source # 
Instance details

Defined in Game.Werewolf.Player

Show State Source # 
Instance details

Defined in Game.Werewolf.Player

Methods

showsPrec :: Int -> State -> ShowS #

show :: State -> String #

showList :: [State] -> ShowS #

data Player Source #

A player has a name, role and state. Any stateful information needed for a player's role is held on the Game itself.

N.B., player equality is defined on just the name.

Instances
Eq Player Source # 
Instance details

Defined in Game.Werewolf.Player

Methods

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

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

Read Player Source # 
Instance details

Defined in Game.Werewolf.Player

Show Player Source # 
Instance details

Defined in Game.Werewolf.Player

Humanise Player Source # 
Instance details

Defined in Game.Werewolf.Player

Methods

humanise :: Player -> Text Source #

newPlayer :: Text -> Role -> Player Source #

Creates a new Alive player.

druid :: Traversal' Player () Source #

The traversal of Players with a druidRole.

druid = role . only druidRole

lycan :: Traversal' Player () Source #

The traversal of Players with a lycanRole.

lycan = role . only lycanRole

orphan :: Traversal' Player () Source #

The traversal of Players with an orphanRole.

orphan = role . only orphanRole

saint :: Traversal' Player () Source #

The traversal of Players with a saintRole.

saint = role . only saintRole

seer :: Traversal' Player () Source #

The traversal of Players with a seerRole.

seer = role . only seerRole

witch :: Traversal' Player () Source #

The traversal of Players with a witchRole.

witch = role . only witchRole

loner :: Traversal' Player () Source #

The traversal of Players aligned with NoOne.

loner = role . allegiance . _NoOne

villager :: Traversal' Player () Source #

The traversal of Players aligned with the Villagers.

villager = role . allegiance . _Villagers

werewolf :: Traversal' Player () Source #

The traversal of Players aligned with the Werewolves.

werewolf = role . allegiance . _Werewolves

names :: Traversable t => Traversal' (t Player) Text Source #

The traversal of Player names.

names = traverse . name

roles :: Traversable t => Traversal' (t Player) Role Source #

The traversal of Player roles.

roles = traverse . role

states :: Traversable t => Traversal' (t Player) State Source #

The traversal of Player states.

states = traverse . state

named :: Text -> Traversal' Player Player Source #

The traversal of Players with the given name.

named name' = filteredBy . name name'

data Variant Source #

Variant definitions require only a few pieces of information.

Instances
Eq Variant Source # 
Instance details

Defined in Game.Werewolf.Variant

Methods

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

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

Read Variant Source # 
Instance details

Defined in Game.Werewolf.Variant

Show Variant Source # 
Instance details

Defined in Game.Werewolf.Variant

Humanise Variant Source # 
Instance details

Defined in Game.Werewolf.Variant

allVariants :: [Variant] Source #

A list containing all the variants defined in this file.

data Stage Source #

Most of these are fairly self-explainable (the turn stages). Sunrise and Sunset are provided as meaningful breaks between the day and night as, for example, a VillagesTurn may not always be available (curse that retched Scapegoat).

Once the game reaches a turn stage, it requires a command to help push it past. Often only certain roles and commands may be performed at any given stage.

Instances
Eq Stage Source # 
Instance details

Defined in Game.Werewolf.Game

Methods

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

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

Read Stage Source # 
Instance details

Defined in Game.Werewolf.Game

Show Stage Source # 
Instance details

Defined in Game.Werewolf.Game

Methods

showsPrec :: Int -> Stage -> ShowS #

show :: Stage -> String #

showList :: [Stage] -> ShowS #

Humanise Stage Source # 
Instance details

Defined in Game.Werewolf.Game

Methods

humanise :: Stage -> Text Source #

data Game Source #

There are a few key pieces of information that a game always needs to hold. These are:

Any further fields on the game are specific to one or more roles (and their respective turns!). Some of the additional fields are reset each round (e.g., the Seer's see) while others are kept around for the whole game (e.g., the Orphan's roleModel).

Instances
Eq Game Source # 
Instance details

Defined in Game.Werewolf.Game

Methods

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

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

Read Game Source # 
Instance details

Defined in Game.Werewolf.Game

Show Game Source # 
Instance details

Defined in Game.Werewolf.Game

Methods

showsPrec :: Int -> Game -> ShowS #

show :: Game -> String #

showList :: [Game] -> ShowS #

allStages :: [Stage] Source #

All of the Stages in the order that they should occur.

stageCycle :: [Stage] Source #

An infinite cycle of all Stages in the order that they should occur.

stageAvailable :: Game -> Stage -> Bool Source #

Checks whether the stage is available for the given Game. Most often this just involves checking if there is an applicable role alive, but sometimes it is more complex.

One of the more complex checks here is for the VillagesTurn. If the Fallen Angel is in play, then the VillagesTurn is available on the first day rather than only after the first night.

newGame :: Variant -> [Player] -> Game Source #

Creates a new Game with the given players. No validations are performed here, those are left to the binary.

votee :: Fold Game Player Source #

The traversal of the votes victim's name. This is the player, if they exist, that received the majority of the votes. This could be an empty list depending on whether the votes were in conflict.

allowedVoters :: Fold Game Player Source #

The traversal of the allowed voters during the VillagesTurn or WerewolvesTurn. In a standard game, this is all Alive players. However there are two scenarios for the VillagesTurn that may change this:

1) if the scapegoat has chosen some chosenVoters, it is these players. 2) if the jester has been revealed, he may not vote.

pendingVoters :: Fold Game Player Source #

The traversal of all Alive players that have yet to vote. This is synonymous to voters - Map.keys votes

firstRound :: Prism' Game Game Source #

The traversal of Games on the first round.

secondRound :: Prism' Game Game Source #

The traversal of Games on the second round.

thirdRound :: Prism' Game Game Source #

The traversal of Games on the third round.

getMarks :: Game -> [Player] Source #

Gets all the marks in a game (which is names only) and maps them to their player.

hasAnyoneWon :: Game -> Bool Source #

Queries whether anyone has won.

hasDullahanWon :: Game -> Bool Source #

Queries whether the Dullahan has won. The Dullahan wins if they manage to eliminate all their marks.

hasFallenAngelWon :: Game -> Bool Source #

Queries whether the Fallen Angel has won. The Fallen Angel wins if they manage to get themselves lynched by the Villagers.

hasNecromancerWon :: Game -> Bool Source #

Queries whether the Necromancer has won. The Necromancer wins if they and their zombies are the only players surviving.

N.B., the Jester is not considered when determining whether the Necromancer has won.

hasVillagersWon :: Game -> Bool Source #

Queries whether the Villagers have won. The Villagers win if they are the only players surviving.

N.B., the Dullahan and Fallen Angel are not considered when determining whether the Villagers have won.

hasWerewolvesWon :: Game -> Bool Source #

Queries whether the Werewolves have won. The Werewolves win if they are the only players surviving.

hasEveryoneLost :: Game -> Bool Source #

Queries whether everyone has lost.