From ec57713b3d4acea066c30cf4285339303860df01 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 12 Nov 2016 22:25:47 +0100 Subject: Timers for use with probabilistic focus and without --- src/Sequence/Contact/Archetypes.hs | 4 ++++ src/Sequence/Contact/Types.hs | 15 +++++++++++++++ src/Sequence/Contact/Types/Internal.hs | 8 ++++++++ 3 files changed, 27 insertions(+) (limited to 'src/Sequence/Contact') diff --git a/src/Sequence/Contact/Archetypes.hs b/src/Sequence/Contact/Archetypes.hs index 1973b97..f8d4c9d 100644 --- a/src/Sequence/Contact/Archetypes.hs +++ b/src/Sequence/Contact/Archetypes.hs @@ -119,6 +119,7 @@ prop = Prop , _sFatigueShock = def , _sSequence = Nothing + , _sTimer = Nothing , _sExtraSkills = [] , _sModifiers = [] @@ -230,6 +231,7 @@ human = Humanoid , _sFatigue = 0 , _sSequence = Nothing + , _sTimer = Nothing , _sPainShock = def & set seReBar (vitBar 0.75) @@ -351,6 +353,7 @@ dog = Quadruped , _sFatigue = 0 , _sSequence = Nothing + , _sTimer = Nothing , _sPainShock = def , _sFatigueShock = def @@ -440,6 +443,7 @@ dolphin = Dolphin , _sFatigue = 0 , _sSequence = Nothing + , _sTimer = Nothing , _sPainShock = def , _sFatigueShock = def diff --git a/src/Sequence/Contact/Types.hs b/src/Sequence/Contact/Types.hs index 5f8808d..c69a698 100644 --- a/src/Sequence/Contact/Types.hs +++ b/src/Sequence/Contact/Types.hs @@ -123,6 +123,20 @@ instance Default SeqVal where } makeLenses ''ShockEffect + +absTime :: Lens' Timer Rational +absTime = lens get set + where + get (Constant n) = n + get (Scaled n) = n + set (Constant _) n = Constant n + set (Scaled _) n = Scaled n + +instance Eq Timer where + (==) = (==) `on` view absTime + +instance Ord Timer where + compare = comparing $ view absTime instance Default ShockEffect where def = ShockEffect { _seApplied = False @@ -148,6 +162,7 @@ instance Default Stats where , _sFatigue = 0 , _sSequence = Nothing + , _sTimer = Nothing , _sPainShock = def , _sFatigueShock = def diff --git a/src/Sequence/Contact/Types/Internal.hs b/src/Sequence/Contact/Types/Internal.hs index 7938a06..11116e9 100644 --- a/src/Sequence/Contact/Types/Internal.hs +++ b/src/Sequence/Contact/Types/Internal.hs @@ -83,6 +83,10 @@ data SeqVal = SeqVal } deriving (Show, Eq, Ord) +data Timer = Scaled Rational + | Constant Rational + deriving (Show) + data ShockEffect = ShockEffect { _seApplied :: Bool , _seVal @@ -107,6 +111,7 @@ data Stats = Prop , _sFatigueShock :: ShockEffect , _sSequence :: Maybe SeqVal + , _sTimer :: Maybe Timer , _sExtraSkills :: Map (CI String) (FormulaM Stats Test) , _sModifiers :: Set Modifier @@ -171,6 +176,7 @@ data Stats = Prop , _sFatigue :: Int , _sSequence :: Maybe SeqVal + , _sTimer :: Maybe Timer , _sPainShock :: ShockEffect , _sFatigueShock :: ShockEffect @@ -213,6 +219,7 @@ data Stats = Prop , _sFatigue :: Int , _sSequence :: Maybe SeqVal + , _sTimer :: Maybe Timer , _sPainShock :: ShockEffect , _sFatigueShock :: ShockEffect @@ -255,6 +262,7 @@ data Stats = Prop , _sFatigue :: Int , _sSequence :: Maybe SeqVal + , _sTimer :: Maybe Timer , _sPainShock :: ShockEffect , _sFatigueShock :: ShockEffect -- cgit v1.2.3