From 7bd64df07668883920be7e0bf9d6eaea96dfba12 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 10 Jul 2016 19:15:08 +0200 Subject: correctly handle electrical damage --- src/Main.hs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index 279a65d..ace3ef2 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -373,13 +373,22 @@ takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> with guard $ dmg > 0 lift . outputLogged focusId $ show dmg ++ " " ++ show dType ++ " to " ++ show (review hitzone zone) case dType of - Fatigue -> lStats . sFatigue += dmg - _ -> lStats . sDamage . ix zone += dmg - case dType of - Fatigue -> lift $ doShock dmg sFatigueShock - _ -> lift $ do - doShock dmg (sCripple . ix zone) - doShock dmg sPainShock + Electric -> do + lStats . sFatigue += dmg + lift $ doShock dmg sFatigueShock + mass <- (MaybeT . focusState lStats . evalFormula' [name]) =<< MaybeT (preuse $ lStats . sAMass) + willpower <- (MaybeT . focusState lStats . evalFormula' [name]) =<< MaybeT (preuse $ lStats . sAWillpower) + let loss = max 0 $ dmg - mass - willpower + lStats . sSequence . _Just . seqVal . _Just -= loss + guard $ loss > willpower + lift $ addNote "prone" + Fatigue -> do + lStats . sFatigue += dmg + lift $ doShock dmg sFatigueShock + _ -> do + lStats . sDamage . ix zone += dmg + lift $ doShock dmg (sCripple . ix zone) + lift $ doShock dmg sPainShock healDmg :: Int -> Completable (Set Hitzone) -> Sh GameState () healDmg n = withArg $ \zones -> withFocus $ \focusId -> do -- cgit v1.2.3