diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-09 12:23:07 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-09 12:23:07 +0200 |
commit | a8b735183cc3a137b463d61305e2287e4ffa350f (patch) | |
tree | 7e06ebc1347a2377bfb81951ac3a148caa6d5f58 /src | |
parent | 384f07dd08569212c0384b299b7824ba4f36ba55 (diff) | |
download | 2017-01-16_17:13:37-a8b735183cc3a137b463d61305e2287e4ffa350f.tar 2017-01-16_17:13:37-a8b735183cc3a137b463d61305e2287e4ffa350f.tar.gz 2017-01-16_17:13:37-a8b735183cc3a137b463d61305e2287e4ffa350f.tar.bz2 2017-01-16_17:13:37-a8b735183cc3a137b463d61305e2287e4ffa350f.tar.xz 2017-01-16_17:13:37-a8b735183cc3a137b463d61305e2287e4ffa350f.zip |
more transparent damage handling
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/Main.hs b/src/Main.hs index 55c0d8b..46f1fa6 100644 --- a/src/Main.hs +++ b/src/Main.hs | |||
@@ -165,10 +165,10 @@ stateMaintenance = do | |||
165 | isDead <- evalF =<< MaybeT (preuse $ lStats . sDead) | 165 | isDead <- evalF =<< MaybeT (preuse $ lStats . sDead) |
166 | isUnconscious <- evalF =<< MaybeT (preuse $ lStats . sUnconscious) | 166 | isUnconscious <- evalF =<< MaybeT (preuse $ lStats . sUnconscious) |
167 | guard $ isDead || isUnconscious | 167 | guard $ isDead || isUnconscious |
168 | when isDead . lift . shellPutStrLn $ name ++ " died" | 168 | when isDead . lift . shellPutStrLn $ name ++ " is dead" |
169 | when (isUnconscious && not isDead) . lift . shellPutStrLn $ name ++ " is unconscious" | 169 | when (isUnconscious && not isDead) . lift . shellPutStrLn $ name ++ " is unconscious" |
170 | gFocus' . eSeqVal .= Nothing | 170 | gFocus' . eSeqVal .= Nothing |
171 | gFocus .= Nothing | 171 | -- gFocus .= Nothing |
172 | void $ do | 172 | void $ do |
173 | round <- use gRound | 173 | round <- use gRound |
174 | let | 174 | let |
@@ -354,24 +354,27 @@ doShock dmg efLens = withFocus $ \focusId -> do | |||
354 | lift . addNote $ "Effect: " ++ effectName | 354 | lift . addNote $ "Effect: " ++ effectName |
355 | 355 | ||
356 | takeHit :: Int -> Completable (Set Hitzone) -> Completable DamageType -> Sh GameState () | 356 | takeHit :: Int -> Completable (Set Hitzone) -> Completable DamageType -> Sh GameState () |
357 | takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> withFocus $ \focusId -> forM_ zones $ \zone -> void . runMaybeT $ do | 357 | takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> withFocus $ \focusId -> do |
358 | let | ||
359 | lStats :: Traversal' GameState Stats | ||
360 | lStats = gEntities . ix focusId . eStats | ||
361 | name <- toName focusId | 358 | name <- toName focusId |
362 | armor <- MaybeT . preuse $ lStats . sArmor . ix zone | 359 | let zones' = map (review hitzone) $ toList zones |
363 | dmg' <- MaybeT . focusState lStats . evalFormula' [name] $ absorb armor dType dmg | 360 | gLog <>= pure (focusId, "Hit for " ++ show dmg ++ " " ++ show dType ++ " to " ++ show zones') |
364 | forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do | 361 | forM_ zones $ \zone -> void . runMaybeT $ do |
365 | guard $ dmg > 0 | 362 | let |
366 | lift . outputLogged focusId $ name ++ " took " ++ show dmg ++ " " ++ show dType | 363 | lStats :: Traversal' GameState Stats |
367 | case dType of | 364 | lStats = gEntities . ix focusId . eStats |
368 | Fatigue -> lStats . sFatigue += dmg | 365 | armor <- MaybeT . preuse $ lStats . sArmor . ix zone |
369 | _ -> lStats . sDamage . ix zone += dmg | 366 | dmg' <- MaybeT . focusState lStats . evalFormula' [name] $ absorb armor dType dmg |
370 | case dType of | 367 | forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do |
371 | Fatigue -> lift $ doShock dmg sFatigueShock | 368 | guard $ dmg > 0 |
372 | _ -> lift $ do | 369 | lift . outputLogged focusId $ show dmg ++ " " ++ show dType ++ " to " ++ show (review hitzone zone) |
373 | doShock dmg (sCripple . ix zone) | 370 | case dType of |
374 | doShock dmg sPainShock | 371 | Fatigue -> lStats . sFatigue += dmg |
372 | _ -> lStats . sDamage . ix zone += dmg | ||
373 | case dType of | ||
374 | Fatigue -> lift $ doShock dmg sFatigueShock | ||
375 | _ -> lift $ do | ||
376 | doShock dmg (sCripple . ix zone) | ||
377 | doShock dmg sPainShock | ||
375 | 378 | ||
376 | takeFatigue :: Int -> Sh GameState () | 379 | takeFatigue :: Int -> Sh GameState () |
377 | takeFatigue dmg = withFocus $ \focusId -> do | 380 | takeFatigue dmg = withFocus $ \focusId -> do |