From aa814c0f6275aa3648b1716dd096cc40401d25ba Mon Sep 17 00:00:00 2001 From: "Henry J. Wylde" Date: Thu, 4 Feb 2016 23:59:40 +1300 Subject: [PATCH 1/2] (#76) allowed the Witch to heal themselves --- CHANGELOG.md | 4 ++++ src/Game/Werewolf/Game.hs | 10 +++------- test/app/Main.hs | 2 +- test/src/Game/Werewolf/Test/Engine.hs | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0df11b..53fb2aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ #### Upcoming +*Revisions* + +* Fixed a bug causing the Witch being unable to heal themselves. ([#76](https://github.com/hjwylde/werewolf/issues/76)) + #### v0.4.1.0 *Minor* diff --git a/src/Game/Werewolf/Game.hs b/src/Game/Werewolf/Game.hs index 2f14502..8fb06d2 100644 --- a/src/Game/Werewolf/Game.hs +++ b/src/Game/Werewolf/Game.hs @@ -139,13 +139,9 @@ stageAvailable _ Sunrise = True stageAvailable _ Sunset = True stageAvailable _ VillagesTurn = True stageAvailable game WerewolvesTurn = any isWerewolf (filterAlive $ game ^. players) -stageAvailable game WitchsTurn = and [ - any isWitch (filterAlive $ game ^. players), - not (game ^. healUsed) || not (game ^. poisonUsed), - (witch ^. name `notElem` [name | (DevourEvent name) <- game ^. events]) - ] - where - witch = head . filterWitches $ game ^. players +stageAvailable game WitchsTurn = + (any isWitch (filterAlive $ game ^. players)) + && (not (game ^. healUsed) || not (game ^. poisonUsed)) getDevourEvent :: Game -> Maybe Event getDevourEvent game = listToMaybe [event | event@(DevourEvent _) <- game ^. events] diff --git a/test/app/Main.hs b/test/app/Main.hs index df2a372..729402b 100644 --- a/test/app/Main.hs +++ b/test/app/Main.hs @@ -115,7 +115,7 @@ allEngineTests = [ testProperty "check villages' turn does nothing unless all voted" prop_checkVillagesTurnDoesNothingUnlessAllVoted, testProperty "check werewolves' turn advances to witch's turn" prop_checkWerewolvesTurnAdvancesToWitchsTurn, - testProperty "check werewolves' turn skips witch's turn when witch devoured" prop_checkWerewolvesTurnSkipsWitchsTurnWhenWitchDevoured, + testProperty "check werewolves' turn doesn't skip witch's turn when witch devoured" prop_checkWerewolvesTurnDoesntSkipWitchsTurnWhenWitchDevoured, testProperty "check werewolves' turn skips witch's turn when healed and poisoned" prop_checkWerewolvesTurnSkipsWitchsTurnWhenHealedAndPoisoned, testProperty "check werewolves' turn kills one player when consensus" prop_checkWerewolvesTurnKillsOnePlayerWhenConsensus, testProperty "check werewolves' turn kills no one when conflicted" prop_checkWerewolvesTurnKillsNoOneWhenConflicted, diff --git a/test/src/Game/Werewolf/Test/Engine.hs b/test/src/Game/Werewolf/Test/Engine.hs index f7e619f..eb55564 100644 --- a/test/src/Game/Werewolf/Test/Engine.hs +++ b/test/src/Game/Werewolf/Test/Engine.hs @@ -22,7 +22,7 @@ module Game.Werewolf.Test.Engine ( prop_checkVillagesTurnDoesNothingUnlessAllVoted, prop_checkWerewolvesTurnAdvancesToWitchsTurn, - prop_checkWerewolvesTurnSkipsWitchsTurnWhenWitchDevoured, + prop_checkWerewolvesTurnDoesntSkipWitchsTurnWhenWitchDevoured, prop_checkWerewolvesTurnSkipsWitchsTurnWhenHealedAndPoisoned, prop_checkWerewolvesTurnKillsOnePlayerWhenConsensus, prop_checkWerewolvesTurnKillsNoOneWhenConflicted, prop_checkWerewolvesTurnResetsVotes, @@ -178,12 +178,12 @@ prop_checkWerewolvesTurnAdvancesToWitchsTurn game = game' = game { _stage = WerewolvesTurn } n = length . filterWerewolves $ game' ^. players -prop_checkWerewolvesTurnSkipsWitchsTurnWhenWitchDevoured :: Game -> Property -prop_checkWerewolvesTurnSkipsWitchsTurnWhenWitchDevoured game = +prop_checkWerewolvesTurnDoesntSkipWitchsTurnWhenWitchDevoured :: Game -> Property +prop_checkWerewolvesTurnDoesntSkipWitchsTurnWhenWitchDevoured game = forAll (arbitraryWitch game) $ \witch -> let devourVoteCommands = map (\werewolf -> devourVoteCommand (werewolf ^. name) (witch ^. name)) (filterWerewolves $ game ^. players) game'' = foldl (flip $ run_ . apply) game' devourVoteCommands - in not . isWitchsTurn $ run_ checkStage game'' + in isWitchsTurn $ run_ checkStage game'' where game' = game { _stage = WerewolvesTurn } From 65cba11b1e5afddc8b6052fcbca908310a7f8973 Mon Sep 17 00:00:00 2001 From: "Henry J. Wylde" Date: Fri, 5 Feb 2016 00:01:13 +1300 Subject: [PATCH 2/2] Version bump --- CHANGELOG.md | 2 ++ werewolf.cabal | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53fb2aa..ab45bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ #### Upcoming +#### v0.4.1.1 + *Revisions* * Fixed a bug causing the Witch being unable to heal themselves. ([#76](https://github.com/hjwylde/werewolf/issues/76)) diff --git a/werewolf.cabal b/werewolf.cabal index 80a532d..644fdfd 100644 --- a/werewolf.cabal +++ b/werewolf.cabal @@ -1,5 +1,5 @@ name: werewolf -version: 0.4.1.0 +version: 0.4.1.1 author: Henry J. Wylde maintainer: public@hjwylde.com