werewolf-1.1.0.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.Game

Contents

Description

A game is not quite as simple as players! Roughly speaking though, this engine is stateful. The game state only changes when a command is issued. Thus, this module defines the Game data structure and any fields required to keep track of the current state.

Synopsis

Game

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).

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.

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 :: [Player] -> Game Source

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

Getters

votee :: Fold Game Player Source

The traversal of the votes victim. This is the player, if they exist, that received the majority of the votes.

Prisms

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.

Searches

getAllowedVoters :: Game -> [Player] Source

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

getPendingVoters :: Game -> [Player] Source

Gets all Alive players that have yet to vote.

Queries

hasAnyoneWon :: Game -> Bool Source

Queries whether anyone has won.

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.

hasVillagersWon :: Game -> Bool Source

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

N.B., the Fallen Angel is 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.