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

Copyright | (c) Henry J. Wylde 2016
License | BSD3
Maintainer | public@hjwylde.com
Safe Haskell | None
Language | Haskell2010

Game.Werewolf.Player

Contents

- Player
  - Traversals

Description

Players are quite simple in themselves. They have a `name`, `role` and `state`.

Synopsis

- data Player
- name :: Lens' Player Text
- role :: Lens' Player Role
- state :: Lens' Player State
- data State
  - = Alive
  - | Dead
- _Alive :: Prism' State ()
- _Dead :: Prism' State ()
- newPlayer :: Text -> Role -> Player
- alphaWolf :: Traversal' Player ()
- beholder :: Traversal' Player ()
- crookedSenator :: Traversal' Player ()
- druid :: Traversal' Player ()
- dullahan :: Traversal' Player ()
- fallenAngel :: Traversal' Player ()
- hunter :: Traversal' Player ()
- jester :: Traversal' Player ()
- lycan :: Traversal' Player ()
- medusa :: Traversal' Player ()
- necromancer :: Traversal' Player ()
- oracle :: Traversal' Player ()
- orphan :: Traversal' Player ()
- protector :: Traversal' Player ()
- saint :: Traversal' Player ()
- scapegoat :: Traversal' Player ()
- seer :: Traversal' Player ()
- simpleVillager :: Traversal' Player ()
- simpleWerewolf :: Traversal' Player ()
- spitefulVillager :: Traversal' Player ()
- trueVillager :: Traversal' Player ()
- villageDrunk :: Traversal' Player ()
- witch :: Traversal' Player ()
- zombie :: Traversal' Player ()
- loner :: Traversal' Player ()
- villager :: Traversal' Player ()
- werewolf :: Traversal' Player ()
- names :: Traversable t => Traversal' (t Player) Text
- roles :: Traversable t => Traversal' (t Player) Role
- states :: Traversable t => Traversal' (t Player) State
- named :: Text -> Traversal' Player Player
- alphaWolves :: Traversable t => Traversal' (t Player) Player
- beholders :: Traversable t => Traversal' (t Player) Player
- crookedSenators :: Traversable t => Traversal' (t Player) Player
- druids :: Traversable t => Traversal' (t Player) Player
- dullahans :: Traversable t => Traversal' (t Player) Player
- fallenAngels :: Traversable t => Traversal' (t Player) Player
- hunters :: Traversable t => Traversal' (t Player) Player
- jesters :: Traversable t => Traversal' (t Player) Player
- lycans :: Traversable t => Traversal' (t Player) Player
- medusas :: Traversable t => Traversal' (t Player) Player
- necromancers :: Traversable t => Traversal' (t Player) Player
- oracles :: Traversable t => Traversal' (t Player) Player
- orphans :: Traversable t => Traversal' (t Player) Player
- protectors :: Traversable t => Traversal' (t Player) Player
- saints :: Traversable t => Traversal' (t Player) Player
- scapegoats :: Traversable t => Traversal' (t Player) Player
- seers :: Traversable t => Traversal' (t Player) Player
- simpleVillagers :: Traversable t => Traversal' (t Player) Player
- simpleWerewolves :: Traversable t => Traversal' (t Player) Player
- spitefulVillagers :: Traversable t => Traversal' (t Player) Player
- trueVillagers :: Traversable t => Traversal' (t Player) Player
- villageDrunks :: Traversable t => Traversal' (t Player) Player
- witches :: Traversable t => Traversal' (t Player) Player
- zombies :: Traversable t => Traversal' (t Player) Player
- loners :: Traversable t => Traversal' (t Player) Player
- villagers :: Traversable t => Traversal' (t Player) Player
- werewolves :: Traversable t => Traversal' (t Player) Player
- alive :: Traversal' Player Player
- dead :: Traversal' Player Player

# Player

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 # |
Methods (==) :: Player -> Player -> Bool # (/=) :: Player -> Player -> Bool #
Read Player Source # |
Methods readsPrec :: Int -> ReadS Player # readList :: ReadS [Player] # readPrec :: ReadPrec Player # readListPrec :: ReadPrec [Player] #
Show Player Source # |
Methods showsPrec :: Int -> Player -> ShowS # show :: Player -> String # showList :: [Player] -> ShowS #
Humanise Player Source # |
Methods humanise :: Player -> Text Source #

name :: Lens' Player Text Source #

role :: Lens' Player Role Source #

state :: Lens' Player State Source #

data State Source #

Surprise surprise, players may be `Dead` or `Alive`.

Constructors

Alive |
Dead |

Instances

Eq State Source # |
Methods (==) :: State -> State -> Bool # (/=) :: State -> State -> Bool #
Read State Source # |
Methods readsPrec :: Int -> ReadS State # readList :: ReadS [State] # readPrec :: ReadPrec State # readListPrec :: ReadPrec [State] #
Show State Source # |
Methods showsPrec :: Int -> State -> ShowS # show :: State -> String # showList :: [State] -> ShowS #

_Alive :: Prism' State () Source #

_Dead :: Prism' State () Source #

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

Creates a new `Alive` player.

## Traversals

alphaWolf :: Traversal' Player () Source #

The traversal of `Player`s with an `alphaWolfRole`.

    alphaWolf = role . only alphaWolfRole

beholder :: Traversal' Player () Source #

The traversal of `Player`s with a `beholderRole`.

    beholder = role . only beholderRole

crookedSenator :: Traversal' Player () Source #

The traversal of `Player`s with a `crookedSenatorRole`.

    crookedSenator = role . only crookedSenatorRole

druid :: Traversal' Player () Source #

The traversal of `Player`s with a `druidRole`.

    druid = role . only druidRole

dullahan :: Traversal' Player () Source #

The traversal of `Player`s with a `dullahanRole`.

    dullahan = role . only dullahanRole

fallenAngel :: Traversal' Player () Source #

The traversal of `Player`s with a `fallenAngelRole`.

    fallenAngel = role . only fallenAngelRole

hunter :: Traversal' Player () Source #

The traversal of `Player`s with a `hunterRole`.

    hunter = role . only hunterRole

jester :: Traversal' Player () Source #

The traversal of `Player`s with a `jesterRole`.

    jester = role . only jesterRole

lycan :: Traversal' Player () Source #

The traversal of `Player`s with a `lycanRole`.

    lycan = role . only lycanRole

medusa :: Traversal' Player () Source #

The traversal of `Player`s with a `medusaRole`.

    medusa = role . only medusaRole

necromancer :: Traversal' Player () Source #

The traversal of `Player`s with a `necromancerRole`.

    necromancer = role . only necromancerRole

oracle :: Traversal' Player () Source #

The traversal of `Player`s with a `oracleRole`.

    oracle = role . only oracleRole

orphan :: Traversal' Player () Source #

The traversal of `Player`s with an `orphanRole`.

    orphan = role . only orphanRole

protector :: Traversal' Player () Source #

The traversal of `Player`s with a `protectorRole`.

    protector = role . only protectorRole

saint :: Traversal' Player () Source #

The traversal of `Player`s with a `saintRole`.

    saint = role . only saintRole

scapegoat :: Traversal' Player () Source #

The traversal of `Player`s with a `scapegoatRole`.

    scapegoat = role . only scapegoatRole

seer :: Traversal' Player () Source #

The traversal of `Player`s with a `seerRole`.

    seer = role . only seerRole

simpleVillager :: Traversal' Player () Source #

The traversal of `Player`s with a `simpleVillagerRole`.

    simpleVillager = role . only simpleVillagerRole

simpleWerewolf :: Traversal' Player () Source #

The traversal of `Player`s with a `simpleWerewolfRole`.

    simpleWerewolf = role . only simpleWerewolfRole

spitefulVillager :: Traversal' Player () Source #

The traversal of `Player`s with a `spitefulVillagerRole`.

    spitefulVillager = role . only spitefulVillagerRole

trueVillager :: Traversal' Player () Source #

The traversal of `Player`s with a `trueVillagerRole`.

    trueVillager = role . only trueVillagerRole

villageDrunk :: Traversal' Player () Source #

The traversal of `Player`s with a `villageDrunkRole`.

    villageDrunk = role . only villageDrunkRole

witch :: Traversal' Player () Source #

The traversal of `Player`s with a `witchRole`.

    witch = role . only witchRole

zombie :: Traversal' Player () Source #

The traversal of `Player`s with a `zombieRole`.

    zombie = role . only zombieRole

loner :: Traversal' Player () Source #

The traversal of `Player`s aligned with `NoOne`.

    loner = role . allegiance . _NoOne

villager :: Traversal' Player () Source #

The traversal of `Player`s aligned with the `Villagers`.

    villager = role . allegiance . _Villagers

werewolf :: Traversal' Player () Source #

The traversal of `Player`s aligned with the `Werewolves`.

    werewolf = role . allegiance . _Werewolves

The following traversals are provided just as a bit of sugar to avoid continually writing ``traverse` .`.

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

N.B., the following traversals are not legal for the same reason `filtered` isn't!

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

The traversal of `Player`s with the given name.

    named name' = filteredBy . name name'

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

The traversal of `alphaWolf` `Player`s.

    alphaWolves = traverse . filtered (is alphaWolf)

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

The traversal of `beholder` `Player`s.

    beholders = traverse . filtered (is beholder)

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

The traversal of `crookedSenator` `Player`s.

    crookedSenators = traverse . filtered (is crookedSenator)

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

The traversal of `druid` `Player`s.

    druids = traverse . filtered (is druid)

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

The traversal of `dullahan` `Player`s.

    dullahans = traverse . filtered (is dullahan)

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

The traversal of `fallenAngel` `Player`s.

    fallenAngels = traverse . filtered (is fallenAngel)

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

The traversal of `hunter` `Player`s.

    hunters = traverse . filtered (is hunter)

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

The traversal of `jester` `Player`s.

    jesters = traverse . filtered (is jester)

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

The traversal of `lycan` `Player`s.

    lycans = traverse . filtered (is lycan)

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

The traversal of `medusa` `Player`s.

    medusas = traverse . filtered (is medusa)

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

The traversal of `necromancer` `Player`s.

    necromancers = traverse . filtered (is necromancer)

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

The traversal of `oracle` `Player`s.

    oracles = traverse . filtered (is oracle)

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

The traversal of `orphan` `Player`s.

    orphans = traverse . filtered (is orphan)

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

The traversal of `protector` `Player`s.

    protectors = traverse . filtered (is protector)

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

The traversal of `saint` `Player`s.

    saints = traverse . filtered (is saint)

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

The traversal of `scapegoat` `Player`s.

    scapegoats = traverse . filtered (is scapegoat)

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

The traversal of `seer` `Player`s.

    seers = traverse . filtered (is seer)

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

The traversal of `simpleVillager` `Player`s.

    simpleVillagers = traverse . filtered (is simpleVillager)

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

The traversal of `simpleWerewolf` `Player`s.

    simpleWerewolves = traverse . filtered (is simpleWerewolf)

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

The traversal of `spitefulVillager` `Player`s.

    spitefulVillagers = traverse . filtered (is spitefulVillager)

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

The traversal of `trueVillager` `Player`s.

    trueVillagers = traverse . filtered (is trueVillager)

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

The traversal of `villageDrunk` `Player`s.

    villageDrunks = traverse . filtered (is villageDrunk)

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

The traversal of `witch` `Player`s.

    witches = traverse . filtered (is witch)

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

The traversal of `zombie` `Player`s.

    zombies = traverse . filtered (is zombie)

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

The traversal of `loner` `Player`s.

    loners = traverse . filtered . (is loner)

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

The traversal of `villager` `Player`s.

    villagers = traverse . filtered (is villager)

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

The traversal of `werewolf` `Player`s.

    werewolves = traverse . filtered (is werewolf)

alive :: Traversal' Player Player Source #

The traversal of `Alive` `Player`s.

    alive = filtered (has $ state . _Alive)

dead :: Traversal' Player Player Source #

The traversal of `Dead` `Player`s.

    dead = filtered (has $ state . _Dead)