diff options
author | Griffin Smith <root@gws.fyi> | 2019-11-16T02·20-0500 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-11-16T02·20-0500 |
commit | 7b90b02049f891f752fff7e0e228511077bbcb84 (patch) | |
tree | 306b998143a9b19a6ea496a8becc86a4ce0303ae /src/Xanthous/Data.hs | |
parent | 87fedcb6c9bc251a5a23a632ccf985b674b84bc7 (diff) |
Recover character hitpoints over time
Wrap hitpoints in a newtype, and recover character hitpoints over time
Diffstat (limited to 'src/Xanthous/Data.hs')
-rw-r--r-- | src/Xanthous/Data.hs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Xanthous/Data.hs b/src/Xanthous/Data.hs index 569922843644..b0d865fa5d79 100644 --- a/src/Xanthous/Data.hs +++ b/src/Xanthous/Data.hs @@ -59,6 +59,9 @@ module Xanthous.Data , edges , neighborDirections , neighborPositions + + -- * + , Hitpoints(..) ) where -------------------------------------------------------------------------------- import Xanthous.Prelude hiding (Left, Down, Right) @@ -344,7 +347,7 @@ neighborPositions pos = (`move` pos) <$> neighborDirections newtype Per a b = Rate Double deriving stock (Show, Eq, Generic) deriving anyclass (NFData, CoArbitrary, Function) - deriving (Num, Ord, Enum, Real, ToJSON, FromJSON) via Double + deriving (Num, Ord, Enum, Real, Fractional, ToJSON, FromJSON) via Double deriving (Semigroup, Monoid) via Product Double instance Arbitrary (Per a b) where arbitrary = genericArbitrary @@ -378,3 +381,13 @@ type TilesPerTick = Tiles `Per` Ticks timesTiles :: TicksPerTile -> Tiles -> Ticks timesTiles = (|*|) + +-------------------------------------------------------------------------------- + +newtype Hitpoints = Hitpoints Word + deriving stock (Show, Eq, Generic) + deriving anyclass (NFData, CoArbitrary, Function) + deriving (Arbitrary, Num, Ord, Bounded, Enum, Integral, Real, ToJSON, FromJSON) + via Word + deriving (Semigroup, Monoid) via Sum Word + |