diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-11 01:40:44 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-06-11 01:40:44 +0200 |
commit | 1bdb2f64c92f79918ea5e1a3f98af45e06d4aae7 (patch) | |
tree | 821bd55fa0365ec5edb2acbffaafa2afdf8b8365 /src | |
parent | fb065aeac90ce0766a3f74b84c34547cd087da77 (diff) | |
download | 2017-01-16_17:13:37-1bdb2f64c92f79918ea5e1a3f98af45e06d4aae7.tar 2017-01-16_17:13:37-1bdb2f64c92f79918ea5e1a3f98af45e06d4aae7.tar.gz 2017-01-16_17:13:37-1bdb2f64c92f79918ea5e1a3f98af45e06d4aae7.tar.bz2 2017-01-16_17:13:37-1bdb2f64c92f79918ea5e1a3f98af45e06d4aae7.tar.xz 2017-01-16_17:13:37-1bdb2f64c92f79918ea5e1a3f98af45e06d4aae7.zip |
fix temporary insanity
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/src/Main.hs b/src/Main.hs index de97603..e8e0a49 100644 --- a/src/Main.hs +++ b/src/Main.hs | |||
@@ -1,4 +1,4 @@ | |||
1 | {-# LANGUAGE ViewPatterns, RecordWildCards, OverloadedStrings, FlexibleContexts #-} | 1 | {-# LANGUAGE ViewPatterns, RecordWildCards, OverloadedStrings, FlexibleContexts, RankNTypes #-} |
2 | 2 | ||
3 | import Control.Monad | 3 | import Control.Monad |
4 | 4 | ||
@@ -251,15 +251,14 @@ delay = withFocus $ \focusId -> () <$ runMaybeT (delay' focusId) | |||
251 | addNote :: String -> Sh GameState () | 251 | addNote :: String -> Sh GameState () |
252 | addNote note = withFocus $ \focusId -> gEntities . ix focusId . eNotes %= (note :) | 252 | addNote note = withFocus $ \focusId -> gEntities . ix focusId . eNotes %= (note :) |
253 | 253 | ||
254 | takeHit :: Int -> Completable (Set Hitzone) -> Sh GameState () | 254 | doShock :: Int -> Traversal' Stats ShockEffect -> Sh GameState () |
255 | takeHit dmg = withArg $ \zones -> withFocus $ \focusId -> forM_ zones $ \zone -> do | 255 | doShock dmg efLens = withFocus $ \focusId -> do |
256 | let | 256 | let |
257 | lStats :: Traversal' GameState Stats | 257 | lStats :: Traversal' GameState Stats |
258 | lStats = gEntities . ix focusId . eStats | 258 | lStats = gEntities . ix focusId . eStats |
259 | lStats . sDamage . ix zone += dmg | ||
260 | name <- toName focusId | 259 | name <- toName focusId |
261 | void . runMaybeT $ do | 260 | void . runMaybeT $ do |
262 | cripple <- MaybeT . preuse $ lStats . sCripple . ix zone | 261 | cripple <- MaybeT . preuse $ lStats . efLens |
263 | let evalF formula = do | 262 | let evalF formula = do |
264 | stats <- MaybeT $ preuse lStats | 263 | stats <- MaybeT $ preuse lStats |
265 | (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula | 264 | (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula |
@@ -276,30 +275,14 @@ takeHit dmg = withArg $ \zones -> withFocus $ \focusId -> forM_ zones $ \zone -> | |||
276 | lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect) | 275 | lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect) |
277 | lift $ shellPutStrLn effectName | 276 | lift $ shellPutStrLn effectName |
278 | lift . addNote $ "Effect: " ++ effectName | 277 | lift . addNote $ "Effect: " ++ effectName |
278 | |||
279 | takeHit :: Int -> Completable (Set Hitzone) -> Sh GameState () | ||
280 | takeHit dmg = withArg $ \zones -> withFocus $ \focusId -> forM_ zones $ \zone -> do | ||
281 | gEntities . ix focusId . eStats . sDamage . ix zone += dmg | ||
282 | doShock dmg (sCripple . ix zone) | ||
283 | doShock dmg sPainShock | ||
279 | 284 | ||
280 | takeFatigue :: Int -> Sh GameState () | 285 | takeFatigue :: Int -> Sh GameState () |
281 | takeFatigue dmg = withFocus $ \focusId -> do | 286 | takeFatigue dmg = withFocus $ \focusId -> do |
282 | let | ||
283 | lStats :: Traversal' GameState Stats | ||
284 | lStats = gEntities . ix focusId . eStats | ||
285 | gEntities . ix focusId . eStats . sFatigue += dmg | 287 | gEntities . ix focusId . eStats . sFatigue += dmg |
286 | name <- toName focusId | 288 | doShock dmg sFatigueShock |
287 | void . runMaybeT $ do | ||
288 | fShock <- MaybeT . preuse $ lStats . sFatigueShock | ||
289 | let evalF formula = do | ||
290 | stats <- MaybeT $ preuse lStats | ||
291 | (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula | ||
292 | lStats .= nStats | ||
293 | return x | ||
294 | fVar cLens = evalF =<< MaybeT (preuse $ lStats . (fShock ^. cLens)) | ||
295 | bar <- fVar seBar | ||
296 | val <- fVar seVal | ||
297 | reBar <- fVar seReBar | ||
298 | if fShock ^. seApplied | ||
299 | then guard $ dmg >= reBar | ||
300 | else guard $ val >= bar | ||
301 | (CI.original -> effectName, effect) <- view _Effect <$> (evalF . table $ fShock ^. seEffect) | ||
302 | lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect) | ||
303 | lift $ shellPutStrLn effectName | ||
304 | lift . addNote $ "Effect: " ++ effectName | ||
305 | |||