packages feed

werewolf 1.1.0.0 → 1.1.1.0

raw patch · 8 files changed

+69/−54 lines, 8 files

Files

CHANGELOG.md view
@@ -7,6 +7,13 @@  ### Upcoming +### v1.1.1.0++*Revisions*++* Updated minimum and maximum number of roles with `--random-extra-roles`.+* Updated Medusa's balance to 3.+ ### v1.1.0.0  *Major*
app/Game/Werewolf/Command.hs view
@@ -31,7 +31,7 @@  import Data.Text (Text) -import Game.Werewolf.Game     hiding (getPendingVoters)+import Game.Werewolf.Game import Game.Werewolf.Messages import Game.Werewolf.Response import Game.Werewolf.Util
app/Game/Werewolf/Messages.hs view
@@ -103,11 +103,10 @@ import           Data.Text            (Text) import qualified Data.Text            as T -import           Game.Werewolf.Game-import           Game.Werewolf.Player-import           Game.Werewolf.Response-import           Game.Werewolf.Role     hiding (name)-import qualified Game.Werewolf.Role     as Role+import Game.Werewolf.Game+import Game.Werewolf.Player+import Game.Werewolf.Response+import Game.Werewolf.Role     hiding (name)  newGameMessages :: Game -> [Message] newGameMessages game = concat@@ -123,13 +122,13 @@     where         players'                = game ^. players         beholderMessages        = case (,) <$> players' ^? beholders <*> players' ^? seers of-            Just (beholder, seer)   -> [beholderMessage (beholder ^. name) (seer ^. name)]+            Just (beholder, seer)   -> [beholderMessage (beholder ^. name) (humanise seer)]             _                       -> []         spitefulGhostMessages   = case players' ^? spitefulGhosts of             Just spitefulGhost  -> [spitefulGhostMessage (spitefulGhost ^. name) (players' \\ [spitefulGhost])]             _                   -> []         trueVillagerMessages    = case players' ^? trueVillagers of-            Just trueVillager   -> [trueVillagerMessage $ trueVillager ^. name]+            Just trueVillager   -> [trueVillagerMessage $ humanise trueVillager]             _                   -> []         fallenAngelMessages     = if has fallenAngels players'             then [fallenAngelMessage]@@ -141,7 +140,7 @@  newPlayerMessage :: Player -> Message newPlayerMessage player = privateMessage (player ^. name) $ T.intercalate "\n"-    [ T.concat ["You're ", article playerRole, " ", playerRole ^. Role.name, "."]+    [ T.concat ["You're ", article playerRole, " ", humanise playerRole, "."]     , playerRole ^. description     , playerRole ^. rules     ]@@ -161,7 +160,7 @@     ]     where         playerNamesWithRoles = concatList $ map-            (\player -> T.concat [player ^. name, " (", player ^. role . Role.name, ")"])+            (\player -> T.concat [humanise player, " (", humanise $ player ^. role, ")"])             players  trueVillagerMessage :: Text -> Message@@ -204,7 +203,7 @@         oraclesName         = players' ^?! oracles . name         orphansName         = players' ^?! orphans . name         protectorsName      = players' ^?! protectors . name-        scapegoatsName      = players' ^?! scapegoats . name+        scapegoatsName      = humanise $ players' ^?! scapegoats         seersName           = players' ^?! seers . name         aliveWerewolfNames  = players' ^.. werewolves . alive . name @@ -292,7 +291,7 @@         devourMessages  = case game ^? votee of             Just votee ->                 [ privateMessage witchsName $-                    T.unwords ["You see", votee ^. name, "sprawled outside bleeding uncontrollably."]+                    T.unwords ["You see", humanise votee, "sprawled outside bleeding uncontrollably."]                 ]             _               -> []         healMessages@@ -331,7 +330,7 @@         playerRolesMessage = publicMessage $ T.concat             [ "As I know you're all wondering who lied to you, here's the role allocations: "             , concatList $ map-                (\player -> T.concat [player ^. name, " (", player ^. role . Role.name, ")"])+                (\player -> T.concat [humanise player, " (", humanise $ player ^. role, ")"])                 (game ^. players)             , "."             ]@@ -362,8 +361,8 @@ playerQuitMessage :: Player -> Message playerQuitMessage player = publicMessage $ T.unwords [playerName, "the", playerRole, "has quit!"]     where-        playerName = player ^. name-        playerRole = player ^. role . Role.name+        playerName = humanise player+        playerRole = humanise $ player ^. role  gameIsOverMessage :: Text -> Message gameIsOverMessage to = privateMessage to "The game is over!"@@ -392,12 +391,10 @@  playerBootedMessage :: Player -> Message playerBootedMessage player = publicMessage $ T.unwords-    [ playerName, "the", playerRole ^. Role.name-    , "has been booted from the game!"-    ]+    [playerName, "the", playerRole , "has been booted from the game!"]     where-        playerName = player ^. name-        playerRole = player ^. role+        playerName = humanise player+        playerRole = humanise $ player ^. role  playerHasAlreadyVotedToBootMessage :: Text -> Text -> Message playerHasAlreadyVotedToBootMessage to targetName = privateMessage to $ T.concat@@ -409,7 +406,7 @@     , T.intercalate " <-> " (map playerName (players ++ [head players]))     ]     where-        playerName player = T.concat [player ^. name, if is dead player then " (dead)" else ""]+        playerName player = T.concat [humanise player, if is dead player then " (dead)" else ""]  pingPlayerMessage :: Text -> Message pingPlayerMessage to = privateMessage to "Waiting on you..."@@ -431,12 +428,12 @@ rolesInGameMessage mTo roles = Message mTo $ T.concat     [ "The roles in play are "     , concatList $ map (\(role, count) ->-        T.concat [role ^. Role.name, " (", T.pack $ show count, ")"])+        T.concat [humanise role, " (", T.pack $ show count, ")"])         roleCounts     , " for a total balance of ", T.pack $ show totalBalance, "."     ]     where-        roleCounts      = map (head &&& length) (groupSortOn (view Role.name) roles)+        roleCounts      = map (head &&& length) (groupSortOn (humanise :: Role -> Text) roles)         totalBalance    = sumOf (traverse . balance) roles  playersInGameMessage :: Text -> [Player] -> Message@@ -448,13 +445,13 @@          alivePlayersText            = T.concat             [ "The following players are still alive: "-            , concatList $ map (\player -> if is trueVillager player then playerNameWithRole player else player ^. name) alivePlayers, "."+            , concatList $ map (\player -> if is trueVillager player then playerNameWithRole player else humanise player) alivePlayers, "."             ]         deadPlayersText             = T.concat             [ "The following players are dead: "             , concatList $ map playerNameWithRole deadPlayers, "."             ]-        playerNameWithRole player   = T.concat [player ^. name, " (", player ^. role . Role.name, ")"]+        playerNameWithRole player   = T.concat [humanise player, " (", humanise $ player ^. role, ")"]  ferinaGruntsMessage :: Message ferinaGruntsMessage = publicMessage@@ -466,14 +463,14 @@     , "while blood slips between their fingers and pools around them."     ]     where-        targetName = target ^. name-        targetRole = target ^. role . Role.name+        targetName = humanise target+        targetRole = humanise $ target ^. role  playerDivinedMessage :: Text -> Player -> Message playerDivinedMessage to player = privateMessage to $ T.concat-    [playerName, " is ", article playerRole, " ", playerRole ^. Role.name, "."]+    [playerName, " is ", article playerRole, " ", humanise playerRole, "."]     where-        playerName = player ^. name+        playerName = humanise player         playerRole = player ^. role  orphanJoinedPackMessages :: Text -> [Text] -> [Message]@@ -511,7 +508,7 @@ playerSeenMessage to player = privateMessage to $ T.concat     [playerName, " is aligned with ", article, humanise allegiance', "."]     where-        playerName  = player ^. name+        playerName  = humanise player         allegiance'             | is alphaWolf player   = Villagers             | is lycan player       = Werewolves@@ -552,16 +549,16 @@         || is alphaWolf player  = publicMessage $ T.concat         [ playerName, " is tied up to a pyre and set alight. As they scream their body starts to "         , "contort and writhe, transforming into ", article playerRole, " "-        , playerRole ^. Role.name, ".", " Thankfully they go limp before breaking free of their "+        , humanise playerRole, ".", " Thankfully they go limp before breaking free of their "         , "restraints."         ]     | otherwise                 = publicMessage $ T.concat         [ playerName, " is tied up to a pyre and set alight. Eventually the screams start to die "         , "and with their last breath, they reveal themselves as ", article playerRole, " "-        , playerRole ^. Role.name, "."+        , humanise playerRole, "."         ]     where-        playerName = player ^. name+        playerName = humanise player         playerRole = player ^. role  noPlayerLynchedMessage :: Message@@ -600,10 +597,10 @@     [ "As you open them you notice a door broken down and "     , playerName, "'s guts half devoured and spilling out over the cobblestones."     , " From the look of their personal effects, you deduce they were "-    , article playerRole, " ", playerRole ^. Role.name, "."+    , article playerRole, " ", humanise playerRole, "."     ]     where-        playerName = player ^. name+        playerName = humanise player         playerRole = player ^. role  playerTurnedToStoneMessage :: Player -> Message@@ -612,8 +609,8 @@     , "must have looked into the eyes of the Medusa at the very end."     ]     where-        playerName = player ^. name-        playerRole = player ^. role . Role.name+        playerName = humanise player+        playerRole = humanise $ player ^. role  noPlayerDevouredMessage :: Message noPlayerDevouredMessage = publicMessage $ T.unwords@@ -633,8 +630,8 @@     , playerName, "the", playerRole, "is hanging over the side of their bed, poisoned."     ]     where-        playerName = player ^. name-        playerRole = player ^. role . Role.name+        playerName = humanise player+        playerRole = humanise $ player ^. role  playerHasAlreadyHealedMessage :: Text -> Message playerHasAlreadyHealedMessage to = privateMessage to "You've already healed someone!"
app/Werewolf/Command/Start.hs view
@@ -75,9 +75,10 @@  randomExtraRoles :: MonadRandom m => Int -> m [Role] randomExtraRoles n = do-    let minimum = n `div` 3+    let minimum = n `div` 4 + 1+    let maximum = n `div` 3 + 1 -    count <- getRandomR (minimum, minimum + 2)+    count <- getRandomR (minimum, maximum)      take count <$> shuffleM restrictedRoles 
src/Game/Werewolf/Game.hs view
@@ -30,7 +30,7 @@      newGame, -    -- ** Getters+    -- ** Folds     votee,      -- ** Prisms@@ -205,17 +205,19 @@     , _votes                = Map.empty     } --- | The traversal of the 'votes' victim. This is the player, if they exist, that received the---   majority of the votes.+-- | 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. votee :: Fold Game Player-votee = folding $ (\players -> if length players == 1 then take 1 players else []) . getVoteResult+votee = folding getVotee --- | Gets all players that had /the/ highest vote count. This could be 1 or more players depending---   on whether the votes were in conflict.-getVoteResult :: Game -> [Player]-getVoteResult game+-- | Gets 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.+getVotee :: Game -> [Player]+getVotee game     | Map.null (game ^. votes)  = []-    | otherwise                 = game ^.. players . traverse . filtered ((`elem` result) . view name)+    | length result /= 1        = []+    | otherwise                 = game ^.. players . traverse . named (head result)     where         votees = Map.elems $ game ^. votes         result = last $ groupSortOn (length . (`elemIndices` votees)) (nub votees)
src/Game/Werewolf/Player.hs view
@@ -46,7 +46,9 @@ import Control.Lens.Extra  import Data.Function-import Data.Text     (Text)+import Data.String+import Data.String.Humanise+import Data.Text            as T  import Game.Werewolf.Role hiding (name) @@ -69,6 +71,9 @@ instance Eq Player where     (==) = (==) `on` view name +instance Humanise Player where+    humanise player = fromString . T.unpack $ player ^. name+ makePrisms ''State  -- | Creates a new 'Alive' player, with one exception: a 'spitefulGhost' always starts 'Dead'.@@ -280,7 +285,7 @@ -- | This 'Traversal' provides the traversal of 'Player's with the given name. -- -- @--- 'named' name' = filteredBy' . 'name' name'+-- 'named' name' = 'filteredBy' . 'name' name' -- @ named :: Text -> Traversal' Player Player named name' = filteredBy name name'
src/Game/Werewolf/Role.hs view
@@ -98,6 +98,9 @@ instance Eq Role where     (==) = (==) `on` view name +instance Humanise Role where+    humanise role = fromString . T.unpack $ role ^. name+ makePrisms ''Allegiance  -- | A list containing all the roles defined in this file.@@ -399,7 +402,7 @@ medusaRole = Role     { _name         = "Medusa"     , _allegiance   = Villagers-    , _balance      = 4+    , _balance      = 3     , _description  = T.unwords         [ "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"
werewolf.cabal view
@@ -1,5 +1,5 @@ name:           werewolf-version:        1.1.0.0+version:        1.1.1.0  author:         Henry J. Wylde maintainer:     public@hjwylde.com