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:
parent
a57e36dca8
commit
6ab7cdfdc9
2 changed files with 10 additions and 2 deletions
|
|
@ -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) ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue