Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.4.1' into release/0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry J. Wylde committed Feb 4, 2016
2 parents a1fc3c2 + 65cba11 commit 6808cf3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@

#### Upcoming

*Revisions*

* Fixed a bug causing the Witch being unable to heal themselves. ([#76](https://github.com/hjwylde/werewolf/issues/76))

#### v0.4.2.0

*Minor*

* Added the Villager role. ([#37](https://github.com/hjwylde/werewolf/issues/37))

#### v0.4.1.1

*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*
Expand Down
10 changes: 3 additions & 7 deletions src/Game/Werewolf/Game.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion test/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions test/src/Game/Werewolf/Test/Engine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -179,12 +179,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 }

Expand Down

0 comments on commit 6808cf3

Please sign in to comment.