summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-10 19:14:50 +0200
committerGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-10 19:14:50 +0200
commit10945609fe1e5f32ff8f5ca606ad098df7b2c794 (patch)
tree7b6b887c7dfde61ddb9408c2e816bfa6f7d3cb87
parentd4a5f97465cb58c05e17dcf65db573b154cbac35 (diff)
download2017-01-16_17:13:37-10945609fe1e5f32ff8f5ca606ad098df7b2c794.tar
2017-01-16_17:13:37-10945609fe1e5f32ff8f5ca606ad098df7b2c794.tar.gz
2017-01-16_17:13:37-10945609fe1e5f32ff8f5ca606ad098df7b2c794.tar.bz2
2017-01-16_17:13:37-10945609fe1e5f32ff8f5ca606ad098df7b2c794.tar.xz
2017-01-16_17:13:37-10945609fe1e5f32ff8f5ca606ad098df7b2c794.zip
Fix handling of death, unconsciousness, etc.
-rw-r--r--src/Main.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 3d098e2..279a65d 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -163,11 +163,12 @@ stateMaintenance = do
163 (nStats, x) <- (evalFormula [name] :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula 163 (nStats, x) <- (evalFormula [name] :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula
164 lStats .= nStats 164 lStats .= nStats
165 return x 165 return x
166 isDead <- evalF =<< MaybeT (preuse $ lStats . sDead) 166 safe a = lift $ fromMaybe False <$> runMaybeT a
167 isUnconscious <- evalF =<< MaybeT (preuse $ lStats . sUnconscious) 167 isDead <- safe $ evalF =<< MaybeT (preuse $ lStats . sDead)
168 isDestroyed <- evalF =<< MaybeT (preuse $ lStats . sDestroyed) 168 isUnconscious <- safe $ evalF =<< MaybeT (preuse $ lStats . sUnconscious)
169 isDestroyed <- safe $ evalF =<< MaybeT (preuse $ lStats . sDestroyed)
169 guard $ isDead || isUnconscious || isDestroyed 170 guard $ isDead || isUnconscious || isDestroyed
170 case (isDead, isDestroyed, isUnconscious) of 171 case (isDead, isUnconscious, isDestroyed) of
171 (True, _, _) -> lift . shellPutStrLn $ name ++ " is dead" 172 (True, _, _) -> lift . shellPutStrLn $ name ++ " is dead"
172 (_, True, _) -> lift . shellPutStrLn $ name ++ " is unconscious" 173 (_, True, _) -> lift . shellPutStrLn $ name ++ " is unconscious"
173 (_, _, True) -> lift . shellPutStrLn $ name ++ " is destroyed" 174 (_, _, True) -> lift . shellPutStrLn $ name ++ " is destroyed"