diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-12 03:44:53 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-12 03:44:53 +0200 |
commit | 0802edda630246a0ff9f82196e55f09780ffa965 (patch) | |
tree | fe85c33b11afd69fa4ead5cba7a74c18b092ca9a /src/Main.hs | |
parent | bf24ff9ffd25841da5e20386548fb63ff191ed9a (diff) | |
download | 2017-01-16_17:13:37-0802edda630246a0ff9f82196e55f09780ffa965.tar 2017-01-16_17:13:37-0802edda630246a0ff9f82196e55f09780ffa965.tar.gz 2017-01-16_17:13:37-0802edda630246a0ff9f82196e55f09780ffa965.tar.bz2 2017-01-16_17:13:37-0802edda630246a0ff9f82196e55f09780ffa965.tar.xz 2017-01-16_17:13:37-0802edda630246a0ff9f82196e55f09780ffa965.zip |
Armour
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs index f409a04..a38b514 100644 --- a/src/Main.hs +++ b/src/Main.hs | |||
@@ -308,16 +308,31 @@ doShock dmg efLens = withFocus $ \focusId -> do | |||
308 | if cripple ^. seApplied | 308 | if cripple ^. seApplied |
309 | then guard $ dmg >= reBar | 309 | then guard $ dmg >= reBar |
310 | else guard $ val >= bar | 310 | else guard $ val >= bar |
311 | lStats . efLens . seApplied .= True | ||
311 | (CI.original -> effectName, effect) <- view _Effect <$> (evalF . table $ cripple ^. seEffect) | 312 | (CI.original -> effectName, effect) <- view _Effect <$> (evalF . table $ cripple ^. seEffect) |
312 | lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect) | 313 | lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect) |
313 | lift $ shellPutStrLn effectName | 314 | lift $ shellPutStrLn effectName |
314 | lift . addNote $ "Effect: " ++ effectName | 315 | lift . addNote $ "Effect: " ++ effectName |
315 | 316 | ||
316 | takeHit :: Int -> Completable (Set Hitzone) -> Sh GameState () | 317 | takeHit :: Int -> Completable (Set Hitzone) -> Completable DamageType -> Sh GameState () |
317 | takeHit dmg = withArg $ \zones -> withFocus $ \focusId -> forM_ zones $ \zone -> do | 318 | takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> withFocus $ \focusId -> forM_ zones $ \zone -> void . runMaybeT $ do |
318 | gEntities . ix focusId . eStats . sDamage . ix zone += dmg | 319 | let |
319 | doShock dmg (sCripple . ix zone) | 320 | lStats :: Traversal' GameState Stats |
320 | doShock dmg sPainShock | 321 | lStats = gEntities . ix focusId . eStats |
322 | name <- toName focusId | ||
323 | armor <- MaybeT . preuse $ lStats . sArmor . ix zone | ||
324 | dmg' <- MaybeT . focusState lStats . evalFormula' name $ absorb armor dType dmg | ||
325 | forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do | ||
326 | guard $ dmg > 0 | ||
327 | lift $ shellPutStrLn $ name ++ " took " ++ show dmg ++ " " ++ show dType | ||
328 | case dType of | ||
329 | Fatigue -> lStats . sFatigue += dmg | ||
330 | _ -> lStats . sDamage . ix zone += dmg | ||
331 | case dType of | ||
332 | Fatigue -> lift $ doShock dmg sFatigueShock | ||
333 | _ -> lift $ do | ||
334 | doShock dmg (sCripple . ix zone) | ||
335 | doShock dmg sPainShock | ||
321 | 336 | ||
322 | takeFatigue :: Int -> Sh GameState () | 337 | takeFatigue :: Int -> Sh GameState () |
323 | takeFatigue dmg = withFocus $ \focusId -> do | 338 | takeFatigue dmg = withFocus $ \focusId -> do |