From 90c94957cb7f1fef4df051d18700a34ecb797293 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 9 Jul 2016 12:49:05 +0200 Subject: unified damage dealing & healing --- src/Main.hs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 46f1fa6..4b78ae2 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -99,7 +99,8 @@ main = do , cmd "delay" delay "Spend AP until the current focusĀ“ sequence is no higher than the next highest and focus that one" , cmd "note" addNote "Add a note to the current focus" , cmd "hit" takeHit "Damage the focused entity" - , cmd "fatigue" takeFatigue "Inflict fatigue damage upon the focused entity" + , cmd "heal" healDmg "Heal the focused entity" + , cmd "heal'" healFatigue "Heal the focused entity of fatigue" , cmd "log" dumpLog "Print the combat log" , cmd "val" printVal "Find the distribution of a specific value of the current entities" ] @@ -375,11 +376,17 @@ takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> with _ -> lift $ do doShock dmg (sCripple . ix zone) doShock dmg sPainShock - -takeFatigue :: Int -> Sh GameState () -takeFatigue dmg = withFocus $ \focusId -> do - gEntities . ix focusId . eStats . sFatigue += dmg - doShock dmg sFatigueShock + +healDmg :: Int -> Completable (Set Hitzone) -> Sh GameState () +healDmg n = withArg $ \zones -> withFocus $ \focusId -> do + gLog <>= pure (focusId, "Heal " ++ show (map (review hitzone) $ toList zones) ++ " for " ++ show n ++ " each") + forM_ zones $ \zone -> do + gEntities . ix focusId . eStats . sDamage . ix zone -= n + +healFatigue :: Int -> Sh GameState () +healFatigue n = withFocus $ \focusId -> do + gLog <>= pure (focusId, "Heal for " ++ show n ++ " Fatigue") + gEntities . ix focusId . eStats . sFatigue -= n dumpLog :: Sh GameState () dumpLog = use gLog >>= mapMOf (each . _1) toName >>= shellPutStrLn . toTable -- cgit v1.2.3