Only allow adjacent gormlaks to attack

Previously the isUnit function was falsely returning `True` for
positions that were one tile off in *either* direction from the
character, when it should've been *both*. Oops.
This commit is contained in:
Griffin Smith 2019-10-06 13:13:00 -04:00
parent a57e36dca8
commit 6ab7cdfdc9
2 changed files with 10 additions and 2 deletions

View file

@ -26,7 +26,14 @@ test = testGroup "Xanthous.Data"
directionOf pos (move dir pos) == dir
, testProperty "diffPositions is add inverse" $ \pos pos ->
diffPositions pos pos == addPositions pos (invert pos)
, testGroup "isUnit"
[ testProperty "double direction is never unit" $ \dir ->
not . isUnit $ move dir (asPosition dir)
, testCase "examples" $ do
isUnit (Position 1 1) @? "not . isUnit $ Position 1 1"
isUnit (Position 0 (-1)) @? "not . isUnit $ Position 0 (-1)"
(not . isUnit) (Position 1 13) @? "isUnit $ Position 1 13"
]
]
, testGroup "Direction"
[ testProperty "opposite is involutive" $ \(dir :: Direction) ->