úÎ züC¾      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½ -Simplistic role data structure and instances.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneOThe 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 name as a role's  allegiance# may change throughout the game. 5A list containing all the roles defined in this file. JA list containing roles that are restricted to a single instance per game. FrestrictedRoles = allRoles \\ [simpleVillagerRole, simpleWerewolfRole] ;A list containing all the allegiances defined in this file.+TODO (hjw): use reflection to get this list \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.gOn the first night, he 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.\Ah! How sweet it is, in my memory, the sound of chains slipping onto the cobblestones of the ]"Three Road" plaza, accompanied by the grunting of Ursus. Ah! How long ago it was that Titan, [the Bear Tamer, would lead his companion in a ballet so gravious that we'd cry every summer [in Miller's Hollow. Ursus even had the oh-so-previous ability to detect lycanthropes hidden  near him.ÛEach morning, right after the revelation of any possible nocturnal victims, if at least one Werewolf is or ends up directly next to the Bear Tamer, then Ursus grunts to indicate danger to all of the other players.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.\It's sad to say, but in Miller's Hollow, when something doesn't go right it's always him who "unjustly suffers the consequences.\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.TA fortunate teller by other names, with the ability to see into fellow townsfolk and determine their allegiance.BEach night the Seer sees the allegiance of a player of her choice.ZA simple, ordinary townsperson in every way. Their only weapons are the ability to analyze Ubehaviour to identify Werewolves, and the strength of their conviction to prevent the +execution of the innocents like themselves.VWhat is a village without an idiot? He does pretty much nothing important, but he's so ,charming that no one would want to hurt him.žIf the village votes against the Village Idiot, his identity is revealed. At that moment the Villagers understand their mistake and immediately let him be.kThe Village Idiot continues to play but may no longer vote, as what would the vote of an idiot be worth?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.XShe knows how to brew two extremely powerful potions: a healing potion, to resurrect the \player devoured by the Werewolves, and a poison potion, used at night to eliminate a player.†The Witch is called after the Werewolves. She is allowed to use both potions in the same night and is also allowed to heal herself.[Each night they devour a Villager. During the day they try to hide their nocturnal identity to avoid mob justice.-A Werewolf may never devour another Werewolf. ¾¿ÀÁÂÃ Ä   ¾¿ÀÁÂà ÄuSimplistic player data structure with functions for searching, filtering and querying lists of players.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone0Surprise surprise, players may be dead or alive.A player has a name, role and stateH. 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 as a player's role# may change throughout the game. Creates a new  player.!BAttempts to find the first player in the list with the given name."7Finds the first player in the list with the given name. -findByName_ name = fromJust . findByName name#BAttempts to find the first player in the list with the given role.$7Finds the first player in the list with the given role. -findByRole_ role = fromJust . findByRole role%Filters players by role.&SFilters players by allegiance, not role. If you're after filtering by role, try filterByRole simpleWerewolfRole. $filterWerewolves = filter isWerewolf' filterAlive = filter isAlive( filterDead = filter isDead) #isAngel player = player ^. role == * 'isBearTamer player = player ^. role == + &isDefender player = player ^. role == , 'isScapegoat player = player ^. role == - "isSeer player = player ^. role == . ,isSimpleVillager player = player ^. role == / ,isSimpleWerewolf player = player ^. role == 0 *isVillageIdiot player = player ^. role == 1 .isVillagerVillager player = player ^. role == 2 'isWildChild player = player ^. role ==  3 #isWitch player = player ^. role == 4 'isWolfHound player = player ^. role == 5UQueries a player's allegiance, not role. If you're after querying their role, try .. <isVillager player = player ^. role . allegiance == Villagers6UQueries a player's allegiance, not role. If you're after querying their role, try /. =isWerewolf player = player ^. role . allegiance == Werewolves7 )isAlive player = player ^. state == Alive8 'isDead player = player ^. state == Dead%ÅÆÇÈ !"#$%&'()*+,-./012345678É  !"#$%&'()*+,-./012345678  !"#$%&'()*+,-./012345678ÅÆÇÈ !"#$%&'()*+,-./012345678ÉPGame data structure with functions for manipulating and querying the game state.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone-9 Events occur after: a stage is advanced. This is automatically handled in 7, while an event's specific behaviour is defined by  and  .ÿFor the most part events are used to allow something to happen on a stage different to when it was triggered. E.g., the devour event 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). B and CS are provided as meaningful breaks between the day and night as, for example, a E? 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.JVThere are a few key pieces of information that a game always needs to hold. These are:the stage,the round number,the players andthe events.¨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 seeM) while others are kept around for the whole game (e.g., the Wild-child's  roleModel).&In order to advance a game's state, 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 stage. It also runs any relevant events.  Y will check to see if any of the win conditions are met and if so, advance the game's stage to >.Ê ScapegoatËWitchÌWitchÍWitchÎWitchÏWitchÐDefenderÑDefenderÒ Wild-childÓ ScapegoatÔSeerÕ Village IdiotÖVillagers and Werewolves\6All of the stages in the order that they should occur.]DAn infinite cycle of all stages in the order that they should occur.^«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 most complex checks here is for the E'. If the Angel is in play, then the EF is available on the first day rather than only after the first night._cCreates a new game 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.a¯Fudges the player's role by completely setting it to something new. This function is useful for roles such as the Angel where they become something else given some trigger.b—Fudges the player's allegiance. This function is useful for roles such as the Wild-child where they align themselves differently given some trigger.d Gets all the passes? in a game (which is names only) and maps them to their player.eGets a player's vote.f Gets all the  allowedVoters? in a game (which is names only) and maps them to their player.g-Gets all alive players that have yet to vote.hGets all players that had theh highest vote count. This could be 1 or more players depending on whether the votes were in conflict.i#Gets the devour event if it exists.j 5isDefendersTurn game = game ^. stage == DefendersTurnk +isGameOver game = game ^. stage == GameOverl 7isScapegoatsTurn game = game ^. stage == ScapegoatsTurnm -isSeersTurn game = game ^. stage == SeersTurnn )isSunrise game = game ^. stage == Sunriseo 'isSunset game = game ^. stage == Sunsetp 3isVillagesTurn game = game ^. stage == VillagesTurnq 7isWerewolvesTurn game = game ^. stage == WerewolvesTurnr 7isWildChildsTurn game = game ^. stage == WildChildsTurns /isWitchsTurn game = game ^. stage == WitchsTurnt 7isWolfHoundsTurn game = game ^. stage == WolfHoundsTurnu &isFirstRound game = game ^. round == 0v*Queries whether the player is in the game.P9:;<=>?@ABCDEFGHIJרÙÚÛÊËÌÍÎÏÐÑÒÓÔÕÖKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv>9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv>JYVPLOKMNQRSTUWXZ[=>?@ABCDEFGHI\]^9:;<_`abcidefghjklmnopqrstuv/9:;<= >?@ABCDEFGHIJרÙÚÛÊËÌÍÎÏÐÑÒÓÔÕÖKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuv-Simplistic role data structure and instances.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone    %Response and message data structures.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone0 w=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.yThe message recipient: Ü for a public message, Ý for a private message.zThe message text.{#When a user sends a command to the werewolf' binary, a response is always returned.0The chat client 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.wxyz{|}~€‚ƒ„Þßàáwxyz{|}~€‚ƒ„{|}~€wxyz‚ƒ„ wxyz{|}~€‚ƒ„Þßàá+Suite of messages used throughout the game.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone<âãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ     )âæóö÷øùúûüýþÿ     <âãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ     !Simplistic player data structure.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNoneGame data structure.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone/9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[jklmnopqrstv/JYVPLOKMNQRSTUWXZ[=>?@ABCDEFGHI9:;<jklmnopqrstvEngine functions.(c) Henry J. Wylde, 2016BSD3public@hjwylde.comNone472… !"#$†‡ˆ‰%Š‹&ŒŽ‘’“”'•–—˜™(š›œžŸ ¡¢£¤¥¦§¨©ª«'…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«'…†‡ˆ‰Š‹”ŒŽ‘’“•–—˜™›šœžŸ ¡¢£¤¥¦§¨©ª«2… !"#$†‡ˆ‰%Š‹&ŒŽ‘’“”'•–—˜™(š›œžŸ ¡¢£¤¥¦§¨©ª«Command 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~ 9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[jklmnopqrstvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½+ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰ŠŠ‹ŒŽ‘’“”•  st–—}€ƒ„…†‡~xyz{˜™š›œ|‰žŸ ¡¢£¤¥¦§¨   ©ª«¬­®¯°±²³´µ¶·¸¹º»¼0·½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌ]ÍÎÏÐÑÒÓÑÒÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ      uwwerew_3qhh4L6iD0K3dxeJZwBN8FGame.Werewolf.Internal.RoleGame.Werewolf.Internal.PlayerGame.Werewolf.Internal.GameGame.Werewolf.ResponseGame.Werewolf.EngineGame.Werewolf.Command checkStageeventAvailable applyEventCommandapply checkGameOver startGame quitCommandGame.Werewolf.RoleGame.Werewolf.MessagesGame.Werewolf.PlayerGame.Werewolf.Game Game.Werewolf AllegianceAngel Villagers WerewolvesRoleadvice allegiancebalance descriptionnameallRolesrestrictedRolesallAllegiances wildChildRole wolfHoundRole angelRole bearTamerRole defenderRole scapegoatRoleseerRolesimpleVillagerRolevillageIdiotRolevillagerVillagerRole witchRolesimpleWerewolfRoleStateAliveDeadPlayerrolestate newPlayer findByName findByName_ findByRole findByRole_ filterByRolefilterWerewolves filterAlive filterDeadisAngel isBearTamer isDefender isScapegoatisSeerisSimpleVillagerisSimpleWerewolfisVillageIdiotisVillagerVillager isWildChildisWitch isWolfHound isVillager isWerewolfisAliveisDeadEvent DevourEvent NoDevourEvent PoisonEventStageGameOver DefendersTurnScapegoatsTurn SeersTurnSunriseSunset UrsussGrunt VillagesTurnWerewolvesTurnWildChildsTurn WitchsTurnWolfHoundsTurnGame allowedVoterseventshealhealUsedpassesplayerspoison poisonUsed priorProtectprotect roleModelroundscapegoatBlamedseestagevillageIdiotRevealedvotes allStages stageCyclestageAvailablenewGame killPlayer setPlayerRolesetPlayerAllegiancegetAdjacentAlivePlayers getPassers getPlayerVotegetAllowedVotersgetPendingVoters getVoteResultgetDevourEventisDefendersTurn isGameOverisScapegoatsTurn isSeersTurn isSunriseisSunsetisVillagesTurnisWerewolvesTurnisWildChildsTurn isWitchsTurnisWolfHoundsTurn isFirstRounddoesPlayerExistMessagetomessageResponseokmessagessuccessfailureexitWith publicMessageprivateMessage groupMessagesfindPlayerByName_findPlayerByRole_defaultFilePathreadGame writeGame deleteGame doesGameExist createPlayersisPlayerDefenderisPlayerScapegoat isPlayerSeerisPlayerVillageIdiotisPlayerWildChild isPlayerWitchisPlayerWolfHoundisPlayerWerewolf isPlayerAlive isPlayerDeadpadRoleschooseAllegianceCommandchoosePlayerCommandchoosePlayersCommand circleCommand healCommand noopCommand passCommand pingCommand poisonCommandprotectCommand seeCommand statusCommandvoteDevourCommandvoteLynchCommand_name _allegiance_balance _description_advice$fEqRole_role_state $fEqPlayer_allowedVoters_heal _healUsed_passes_poison _poisonUsed _priorProtect_protect _roleModel_scapegoatBlamed_see_villageIdiotRevealed_votes_stage_round_players_eventsbaseGHC.BaseNothingJust$fToJSONMessage$fFromJSONMessage$fToJSONResponse$fFromJSONResponsenewGameMessagesnewPlayersInGameMessagenewPlayerMessagevillagerVillagerMessage stageMessagesdefendersTurnMessagesscapegoatsTurnMessagesseersTurnMessagessunriseMessagenightFallsMessagefirstVillagesTurnMessagesvillagesTurnMessagesfirstWerewolvesTurnMessageswerewolvesTurnMessageswildChildsTurnMessageswitchsTurnMessageswolfHoundsTurnMessagesgameOverMessagesplayerWonMessageplayerLostMessageplayerQuitMessagegameIsOverMessageplayerDoesNotExistMessageplayerCannotDoThatMessage!playerCannotDoThatRightNowMessageplayerIsDeadMessagetargetIsDeadMessage circleMessagepingPlayerMessagepingRoleMessagecurrentStageMessagesrolesInGameMessageplayersInGameMessagewaitingOnMessageangelJoinedVillagersMessageursusGruntsMessage/playerCannotProtectSamePlayerTwiceInARowMessage"scapegoatChoseAllowedVotersMessage'playerMustChooseAtLeastOneTargetMessage%playerCannotChooseVillageIdiotMessageplayerSeenMessageplayerMadeLynchVoteMessageplayerLynchedMessagenoPlayerLynchedMessagescapegoatLynchedMessagevillageIdiotLynchedMessageplayerHasAlreadyVotedMessage$playerCannotLynchVillageIdiotMessageplayerMadeDevourVoteMessageplayerDevouredMessagenoPlayerDevouredMessage(playerCannotDevourAnotherWerewolfMessageplayerJoinedPackMessagewildChildJoinedPackMessagesplayerCannotChooseSelfMessageplayerPoisonedMessageplayerHasAlreadyHealedMessageplayerHasAlreadyPoisonedMessageallegianceDoesNotExistMessagearticle checkStage' lynchVotees devourVotees advanceStage checkEventsfindAlivePlayerByRoledefaultFileNamevalidatePlayervalidateWitchsCommand