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

@ -136,7 +136,8 @@ diffPositions (Position x₁ y₁) (Position x₂ y₂) = Position (x₁ - x₂)
--
-- ∀ dir :: Direction. isUnit ('asPosition' dir)
isUnit :: Position -> Bool
isUnit (Position px py) = abs px == 1 || abs py == 1
isUnit (Position px py) =
abs px `elem` [0,1] && abs py `elem` [0, 1] && (px, py) /= (0, 0)
--------------------------------------------------------------------------------