From 8a4220df830adb6f1616ca02dd06902474fd25df Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 13 Oct 2019 12:37:08 -0400 Subject: 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. --- src/Xanthous/Entities/RawTypes.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/Xanthous/Entities/RawTypes.hs') diff --git a/src/Xanthous/Entities/RawTypes.hs b/src/Xanthous/Entities/RawTypes.hs index f1f5e05f7aac..fd66140376bb 100644 --- a/src/Xanthous/Entities/RawTypes.hs +++ b/src/Xanthous/Entities/RawTypes.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE DuplicateRecordFields #-} -------------------------------------------------------------------------------- module Xanthous.Entities.RawTypes @@ -8,6 +8,7 @@ module Xanthous.Entities.RawTypes , isEdible , EntityRaw(..) + , _Creature -- * Lens classes , HasName(..) , HasDescription(..) @@ -17,7 +18,7 @@ module Xanthous.Entities.RawTypes , HasEatMessage(..) , HasHitpointsHealed(..) , HasEdible(..) - , _Creature + , HasSpeed(..) ) where -------------------------------------------------------------------------------- import Xanthous.Prelude @@ -28,16 +29,18 @@ import Data.Aeson (ToJSON, FromJSON) -------------------------------------------------------------------------------- import Xanthous.Entities (EntityChar, HasChar(..)) import Xanthous.Messages (Message(..)) +import Xanthous.Data (TicksPerTile) -------------------------------------------------------------------------------- data CreatureType = CreatureType - { _name :: Text - , _description :: Text - , _char :: EntityChar - , _maxHitpoints :: Word - , _friendly :: Bool + { _name :: !Text + , _description :: !Text + , _char :: !EntityChar + , _maxHitpoints :: !Word + , _friendly :: !Bool + , _speed :: !TicksPerTile } deriving stock (Show, Eq, Generic) - deriving anyclass (NFData) + deriving anyclass (NFData, CoArbitrary, Function) deriving (ToJSON, FromJSON) via WithOptions '[ FieldLabelModifier '[Drop 1] ] CreatureType -- cgit 1.4.1