6%&      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ -Simplistic role data structure and instances.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneINOThe Loner allegiances are seldom used, rather they are present for correctness.uRole definitions require only a few pieces of information. Most of the game logic behind a role is implemented in Game.Werewolf.Command and Game.Werewolf.Engine.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  as a role's # may change throughout the game. 5A list containing all the roles defined in this file.EA list containing roles that are restricted to a single instance per Game.   =   \\ [, ] ;A list containing all the allegiances defined in this file.+TODO (hjw): use reflection to get this listXWho could dream of a better servant than one willing to give up her life for that of her \masters? Don't rejoice too fast, as the devouring ambition within her could spell the end of  the village!*Before the revelation of the card of the player eliminated by the village's vote, the Devoted Servant can reveal herself by showing her card and taking on the role of the eliminated player. Upon taking on her master's role, any special abilities are reset and any first turns are replayed.\Abandoned in the woods by his parents at a young age, he was raised by wolves. As soon as he \learned how to walk on all fours, the Wild-child began to wander around Miller's Hollow. One Vday, fascinated by an inhabitant of the village who was walking upright with grace and [presence, he made them his secret role model. He then decided to integrate himself into the ]community of Miller's Hollow and entered, worried, in the village. The community was moved by Yhis frailty, adopted him, and welcomed him in their fold. What will become of him: honest ZVillager or terrible Werewolf? For all of his life, the heart of the Wild-child will swing Sbetween these two alternatives. May his model confirm him in his newfound humanity.wOn the first night, the Wild-child may choose a player to become his role model. If during the game the chosen player is eliminated, the Wild-child becomes a Werewolf. He will then wake up the next night with his peers and will devour with them each night until the end of the game. However for as long as the Wild-child's role model is alive, he remains a Villager.XAll dogs know in the depths of their soul that their ancestors were wolves and that it's Zmankind who has kept them in the state of childishness and fear, the faithful and generous ]companions. In any case, only the Wolf-hound can decide if he'll obey his human and civilized Gmaster or if he'll listen to the call of wild nature buried within him.sOn the first night, the Wolf-hound chooses if he wants to be a Simple Villager or Werewolf. The choice is final.[The muddy life of a village infested with evil creatures repulses him; he wishes to believe \he's the victim of a terrible nightmare, in order to finally wake up in his comfortable bed.When the Angel is in play, the game always begins with the village's debate followed by an elimination vote, and then the first night.The Angel wins if he manages to get eliminated on the first round (day or night). If he fails, then he becomes a Simple Villager for the rest of the game.FThis character can save the Villagers from the bite of the Werewolves.Each night the Defender is called before the Werewolves to select a player deserving of his protection. That player is safe during the night (and only that night) against the Werewolves.AThe Defender may not protect the same person two nights in a row.YHow honoured we are to be in the presence of such a noble leader. The return of the Druid \marks an exceptional time in Fougres's history! Friend of the woodland creatures, practiced Vphilosopher 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 Zproximity! Listen for her grunt and heed the Druid's words for they 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 then Ferina will grunt in warning.ZWerewolves don't just spring up out of the ground! That's where dwarves come from. Clearly Ysomeone is to blame for this affliction to Fougres. Ah! Unluckily, since no-one actually Iknows who brought them here, the blame is always laid upon the Scapegoat.\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: he must choose whom is permitted to vote or not on the next day.\Frequently misunderstood and thought to be a fortune teller, 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! Visions will always be true, but only for the present as /not even the Seer knowns what the future holds.DEach night the Seer sees the allegiance of a player of their choice.XA 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 Fougres unites them in this unfortunate time.A Simple Villager has no special abilities, they must use their guile to determine whom among them is not who they say they are.]Every village needs a Jester, they're so stupid but provide so much entertainment! The Jester Ymay not have any special abilities, but at least no one in the village would want to hurt him.If the village votes to lynch the Jester, his identity is revealed. The village realise there's no point in burning him and so he is set free.UThe Jester continues to play but may no longer vote as no one can take him seriously.YThis person has a soul as clear and transparent as the water from a mountain stream. They Zwill deserve the attentive ear of their peers and will make their word decisive in crucial moments.When the game begins, the village is told the identity of the Villager-Villager, thus ensuring certainty that its owner is truly an innocent Villager.]Somehow forgotten with the coming of the Werewolves, the Witch has a chance to prove themself \valuable to the village. The Witch is blessed (or maybe cursed) with the ability to make two \powerful potions; one of which may heal a victim of the Werewolves, the other able to poison [a player. The use of these potions could alter the village's currently misguided perception  of the Witch.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 to heal themself.YIt's difficult to tell, but a Werewolf is merely a Villager underneath; unfortunately one Vthat has been afflicted with lycanthropy and consequently transforms each night into a Xfearsome lupine. Not all hope is yet lost, some Villagers would like to try and cure the Bcurse of lycanthropy. Perhaps one day this dream will be realised.-A Werewolf may never devour another Werewolf.The counter-part to !, but more general as it takes a  instead.A re-write of  to be more general by taking a  instead.A companion to M that, rather than using a predicate, filters on the given lens for matches.'       %Response and message data structures.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone0 =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."The message recipient:  for a public message,  for a private message.#The message text.$#When a user sends a command to the werewolf' binary, a response is always returned.)The chat interface should then relay any messagesN 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.&!Boolean flag to indicate success.'List of messages.(A successful, empty response.) An unsuccessful, empty response.*PExits 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.+-Creates a public message with the given text., privateMessage to messageCreates a private message to to with the given text.- groupMessages tos messageLCreates multiple private messages (1 to each recipient) with the given text. !"#$%&'()*+,- !"#$%&'()*+,-$%&'()* !"#+,- !"#$%&'()*+,-uSimplistic player data structure with functions for searching, filtering and querying lists of players.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47IN&."Surprise surprise, players may be 0 or /.1A player has a 2, 3 and 42. Any stateful information needed for a player's role is held on the Game itself.-N.B., player equality is defined on just the 2.7Creates a new / player.8The traversal of 1 s with an . 8 = 3 .   9The traversal of 1 s with a . 9 = 3 .   :The traversal of 1 s with a . : = 3 .   ;The traversal of 1 s with a . ; = 3 .   <The traversal of 1 s with a . < = 3 .   =The traversal of 1 s with a . = = 3 .   >The traversal of 1 s with a . > = 3 .   ?The traversal of 1 s with a . ? = 3 .   @The traversal of 1 s with a . @ = 3 .   AThe traversal of 1 s with a . A = 3 .   BThe traversal of 1 s with a . B = 3 .   CThe traversal of 1 s with a . C = 3 .   DThe traversal of 1 s with a . D = 3 .   EThe traversal of 1s aligned with the . E = 3 .  .   FThe traversal of 1s aligned with the . F = 3 .  .   GThis  provides the traversal of 1 names. G =  . 2 HThis  provides the traversal of 1 roles. H =  . 3 IThis  provides the traversal of 1 states. I =  . 4 JThis  provides the traversal of 8 1s. J =  .  ( 8) KThis  provides the traversal of 9 1s. K =  .  ( 9) LThis  provides the traversal of : 1s. L =  .  ( :) MThis  provides the traversal of ; 1s. M =  .  ( ;) NThis  provides the traversal of < 1s. N =  .  ( <) OThis  provides the traversal of = 1s. O =  .  ( =) PThis  provides the traversal of > 1s. P =  .  ( >) QThis  provides the traversal of ? 1s. Q =  .  ( ?) RThis  provides the traversal of @ 1s. R =  .  ( @) SThis  provides the traversal of A 1s. S =  .  ( A) TThis  provides the traversal of B 1s. T =  .  ( B) UThis  provides the traversal of C 1s. U =  .  ( C) VThis  provides the traversal of D 1s. V =  .  ( D) WThis  provides the traversal of E 1s. W =  .  ( E) XThis  provides the traversal of F 1s. X =  .  ( F) YThis  provides the traversal of / 1s. Y =  ( $ 4 . 5) ZThis  provides the traversal of 0 1s. Z =  ( $ 4 . 6) 2./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ0./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ01234./056789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ,./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZPGame data structure with functions for manipulating and querying the game state.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone"[ Events occur after a _2 is advanced. This is automatically handled in 7, while an event's specific behaviour is defined by  and .DFor the most part events are used to allow something to happen on a _2 different to when it was triggered. E.g., the  DeovurEvent~ occurs after the village wakes up rather than when the Werewolves' vote, this gives the Witch a chance to heal the victim.\ Werewolves]Defender, Werewolves and Witch^Witch_<Most of these are fairly self-sufficient (the turn stages). g and hS are provided as meaningful breaks between the day and night as, for example, a i? may not always be available (curse that retched Scapegoat).2Once the game reaches a turn stage, it requires a d to help push it past. Often only certain roles and commands may be performed at any given stage.nVThere are a few key pieces of information that a game always needs to hold. These are:the ,the } number,the w andthe r.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 M) while others are kept around for the whole game (e.g., the Wild-child's |).In order to advance a game's 4, a Y from a user needs to be received. Afterwards the following steps should be performed:  the .run .run .g will perform any additional checks and manipulations to the game state before advancing the game's . It also runs any relevant r. Y will check to see if any of the win conditions are met and if so, advance the game's  to c. Wolf-hound ScapegoatWitchWitchJesterWitchWitchWitchDefenderDefender Wild-child ScapegoatSeerVillagers and Werewolves All of the _&s in the order that they should occur.An infinite cycle of all _&s in the order that they should occur.4Checks whether the stage is available for the given ns. 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 i'. If the Angel is in play, then the iF is available on the first day rather than only after the first night.Creates a new nQ with the given players. No validations are performed here, those are left to .Kills the given player! This function should be used carefully as it doesn't clear any state that the player's role may use. If you're after just removing a player from a game for a test, try using a  instead. Gets all the p? in a game (which is names only) and maps them to their player. Gets all / players that have yet to vote.Gets all players that had theh highest vote count. This could be 1 or more players depending on whether the votes were in conflict.  game = game ^. } == 0*Queries whether the player is in the game.Queries whether anyone has won.pQueries whether the Angel has won. The Angel wins if they manage to get themselves killed on the first round.&N.B., we check that the Angel isn't a E5 as the Angel's role is altered if they don't win.Queries whether the  have won. The / win if they are the only players surviving.Queries whether the  have won. The / win if they are the only players surviving.Z[\]^_`abcdefghijklmnopqrstuvwxyz{|}~F[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Fn}wrqvopstuxyz{|~_`abcdefghijklm[\]^5[\]^_`abcdefghijklmnopqrstuvwxyz{|}~+Suite of messages used throughout the game.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneA      !"#$%&-      !"#$%A      !"#$%&$Utility functions for working in a (' n) environment.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47IN(Fudges the player's allegiance. This function is useful for roles such as the Wild-child where they align themselves differently given some trigger.)Fudges the player's role. This function is useful for roles such as the Devoted Servant where they take on a different role.&*+(),-./0123456789:;<=>?@ABCDEFGHIJKLM&*+(),-./0123456789:;<=>?@ABCDEFGHIJKLM&*+(),-./0123456789:;<=>?@ABCDEFGHIJKLMEngine functions.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47 NOPQRSTU NOPQRSTUCommand data structure.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47IN+Re-exports all of the public modules under  Game.Werewolf.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Defender commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneDevoted Servant commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47VWVW Global commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone Scapegoat commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone Seer commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone Status commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone Villager commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneWerewolf commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneWild-child commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneWitch commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone47XXWolf-hound commands.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneY !"#$%&'()*+,-./0123456789:;<=>>?@AABCDEFGHIJKLM'NOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  #M      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a`bwerew_6Aw2z75vSXa2XzxU6I7bKiGame.Werewolf.RoleGame.Werewolf.ResponseGame.Werewolf.PlayerGame.Werewolf.GameGame.Werewolf.EngineGame.Werewolf.CommandGame.Werewolf.Command.Defender$Game.Werewolf.Command.DevotedServantGame.Werewolf.Command.GlobalGame.Werewolf.Command.ScapegoatGame.Werewolf.Command.SeerGame.Werewolf.Command.StatusGame.Werewolf.Command.VillagerGame.Werewolf.Command.WerewolfGame.Werewolf.Command.WildChildGame.Werewolf.Command.WitchGame.Werewolf.Command.WolfHoundControl.Lens.Prismisn't checkStageeventAvailable applyEventCommandapply checkGameOver startGame quitCommandGame.Werewolf.MessagesGame.Werewolf.Util Game.Werewolf AllegianceAngel Villagers WerewolvesRole allegiancebalance descriptionnamerules_Angel _Villagers _WerewolvesallRolesrestrictedRolesallAllegiancesdevotedServantRole wildChildRole wolfHoundRole angelRole defenderRole druidRole scapegoatRoleseerRolesimpleVillagerRole jesterRolevillagerVillagerRole witchRolesimpleWerewolfRoleis filteredByMessagetomessageResponseokmessagessuccessfailureexitWith publicMessageprivateMessage groupMessagesStateAliveDeadPlayerrolestate_Alive_Dead newPlayerangeldefenderdevotedServantdruidjester scapegoatseersimpleVillagersimpleWerewolfvillagerVillager wildChildwitch wolfHoundvillagerwerewolfnamesrolesstatesangels defendersdevotedServantsdruidsjesters scapegoatsseerssimpleVillagerssimpleWerewolvesvillagerVillagers wildChildrenwitches wolfHounds villagers werewolvesalivedeadEvent DevourEvent NoDevourEvent PoisonEventStage DefendersTurnDevotedServantsTurn FerinasGruntGameOverLynchingScapegoatsTurn SeersTurnSunriseSunset VillagesTurnWerewolvesTurnWildChildsTurn WitchsTurnWolfHoundsTurnGameallegianceChosen allowedVotersbootseventshealhealUsedjesterRevealedpassesplayerspoison poisonUsed priorProtectprotect roleModelroundscapegoatBlamedseestagevotes_DefendersTurn_DevotedServantsTurn _FerinasGrunt _GameOver _Lynching_ScapegoatsTurn _SeersTurn_Sunrise_Sunset _VillagesTurn_WerewolvesTurn_WildChildsTurn _WitchsTurn_WolfHoundsTurn _DevourEvent_NoDevourEvent _PoisonEvent allStages stageCyclestageAvailablenewGame killPlayergetAllowedVotersgetPendingVoters getVoteResult isFirstRounddoesPlayerExist hasAnyoneWon hasAngelWonhasVillagersWonhasWerewolvesWon noopCommandvalidatePlayerprotectCommand passCommand revealCommand bootCommand chooseCommand seeCommand circleCommand pingCommand statusCommand voteCommand healCommand poisonCommandlens_CQGTvKhRr3o7ECIQ5skDMYControl.Lens.GetterGettingControl.Lens.Foldfiltered_name _allegiance_balance _description_rules$fEqRolebaseGHC.BaseNothingJust$fToJSONMessage$fFromJSONMessage$fToJSONResponse$fFromJSONResponseonlyControl.Lens.Type TraversalData.Traversabletraversehas_role_state $fEqPlayer_allegianceChosen_allowedVoters_heal _healUsed_jesterRevealed_passes_poison _poisonUsed _priorProtect_protect _roleModel_scapegoatBlamed_see_votes_stage_round_players_events_bootsnewGameMessagesnewPlayersInGameMessagenewPlayerMessagevillagerVillagerMessage stageMessagesdefendersTurnMessagesdevotedServantsTurnMessagesscapegoatsTurnMessagesseersTurnMessagessunriseMessagenightFallsMessagefirstVillagesTurnMessagesvillagesTurnMessagesfirstWerewolvesTurnMessageswerewolvesTurnMessageswildChildsTurnMessageswitchsTurnMessageswolfHoundsTurnMessagesgameOverMessagesplayerWonMessageplayerContributedMessageplayerLostMessageplayerQuitMessagegameIsOverMessageplayerDoesNotExistMessageplayerCannotDoThatMessage!playerCannotDoThatRightNowMessageplayerIsDeadMessagetargetIsDeadMessageplayerVotedToBootMessageplayerBootedMessage"playerHasAlreadyVotedToBootMessage circleMessagepingPlayerMessagepingRoleMessagecurrentStageMessagesrolesInGameMessageplayersInGameMessagewaitingOnMessageangelJoinedVillagersMessage/playerCannotProtectSamePlayerTwiceInARowMessagedevotedServantRevealedMessage devotedServantJoinedPackMessagesferinaGruntsMessage"scapegoatChoseAllowedVotersMessage'playerMustChooseAtLeastOneTargetMessageplayerCannotChooseJesterMessageplayerSeenMessageplayerMadeLynchVoteMessageplayerLynchedMessagenoPlayerLynchedMessagejesterLynchedMessagescapegoatLynchedMessageplayerHasAlreadyVotedMessageplayerMadeDevourVoteMessageplayerDevouredMessagenoPlayerDevouredMessage(playerCannotDevourAnotherWerewolfMessagewildChildJoinedPackMessagesplayerCannotChooseSelfMessageplayerPoisonedMessageplayerHasAlreadyHealedMessageplayerHasAlreadyPoisonedMessageallegianceDoesNotExistMessagearticlemtl_Aue4leSeVkpKLsfHIV51E8Control.Monad.State.Class MonadStatesetPlayerAllegiance setPlayerRole removePlayer findPlayerBy_getAdjacentAlivePlayers getPassers getPlayerVoteisDefendersTurnisDevotedServantsTurn isGameOverisScapegoatsTurn isSeersTurn isSunriseisVillagesTurnisWerewolvesTurnisWildChildsTurn isWitchsTurnisWolfHoundsTurnisPlayerDefenderisPlayerDevotedServantisPlayerJesterisPlayerScapegoat isPlayerSeerisPlayerWildChild isPlayerWitchisPlayerWolfHoundisPlayerWerewolf isPlayerAlive isPlayerDead checkBoots checkStage' lynchVotees devourVotees advanceStage checkEventsvalidateCommand resetRole