From 7b90b02049f891f752fff7e0e228511077bbcb84 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 15 Nov 2019 21:20:01 -0500 Subject: Recover character hitpoints over time Wrap hitpoints in a newtype, and recover character hitpoints over time --- src/Xanthous/Entities/Creature.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Xanthous/Entities/Creature.hs') diff --git a/src/Xanthous/Entities/Creature.hs b/src/Xanthous/Entities/Creature.hs index 4ad751a58240..11cad1ce6b8b 100644 --- a/src/Xanthous/Entities/Creature.hs +++ b/src/Xanthous/Entities/Creature.hs @@ -78,7 +78,7 @@ initialHippocampus = Hippocampus Nothing data Creature = Creature { _creatureType :: !CreatureType - , _hitpoints :: !Word + , _hitpoints :: !Hitpoints , _hippocampus :: !Hippocampus } deriving stock (Eq, Show, Generic) @@ -99,7 +99,7 @@ newWithType _creatureType = _hippocampus = initialHippocampus in Creature {..} -damage :: Word -> Creature -> Creature +damage :: Hitpoints -> Creature -> Creature damage amount = hitpoints %~ \hp -> if hp <= amount then 0 -- cgit 1.4.1