Implement speed and ticks

Gormlaks now move 1/8th the speed of the character, which means we can
run away from them - yay!

Unfortunately this also introduces a bug where they'll eventually get
stuck and not do anything, so I'll be tackling that next.
This commit is contained in:
Griffin Smith 2019-10-13 12:37:08 -04:00
parent 8d36fb4af2
commit 8a4220df83
11 changed files with 277 additions and 84 deletions

View file

@ -24,15 +24,15 @@ test = testGroup "Xanthous.Data"
]
, testProperty "directionOf laws" $ \pos dir ->
directionOf pos (move dir pos) == dir
, testProperty "diffPositions is add inverse" $ \pos pos ->
, testProperty "diffPositions is add inverse" $ \(pos :: Position) 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"
isUnit (Position @Int 1 1) @? "not . isUnit $ Position 1 1"
isUnit (Position @Int 0 (-1)) @? "not . isUnit $ Position 0 (-1)"
(not . isUnit) (Position @Int 1 13) @? "isUnit $ Position 1 13"
]
]
, testGroup "Direction"