summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-06-14 03:26:18 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2016-06-14 03:26:18 +0200
commitd196ace4100ec5f8cfb0fad265d3baa44873fc9d (patch)
tree6f6714769e2d539b70aef2f06ea0d7e16e46855e /src/Main.hs
parent0c5fe56414a323f49d7b086c0a64a216443a22bb (diff)
download2017-01-16_17:13:37-d196ace4100ec5f8cfb0fad265d3baa44873fc9d.tar
2017-01-16_17:13:37-d196ace4100ec5f8cfb0fad265d3baa44873fc9d.tar.gz
2017-01-16_17:13:37-d196ace4100ec5f8cfb0fad265d3baa44873fc9d.tar.bz2
2017-01-16_17:13:37-d196ace4100ec5f8cfb0fad265d3baa44873fc9d.tar.xz
2017-01-16_17:13:37-d196ace4100ec5f8cfb0fad265d3baa44873fc9d.zip
fixed questions
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 3e6b750..636e5ea 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -62,8 +62,6 @@ import qualified Data.Text.Lazy as Lazy (Text)
62import qualified Data.Text.Lazy as Lazy.Text 62import qualified Data.Text.Lazy as Lazy.Text
63import Data.Text.Template 63import Data.Text.Template
64 64
65import Debug.Trace
66
67main :: IO () 65main :: IO ()
68main = do 66main = do
69 historyFile <- getUserCacheFile "sequence" "history" 67 historyFile <- getUserCacheFile "sequence" "history"
@@ -158,7 +156,7 @@ stateMaintenance = do
158 lStats = gEntities . ix focusId . eStats 156 lStats = gEntities . ix focusId . eStats
159 evalF formula = do 157 evalF formula = do
160 stats <- MaybeT $ preuse lStats 158 stats <- MaybeT $ preuse lStats
161 (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula 159 (nStats, x) <- (evalFormula [name] :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula
162 lStats .= nStats 160 lStats .= nStats
163 return x 161 return x
164 isDead <- evalF =<< MaybeT (preuse $ lStats . sDead) 162 isDead <- evalF =<< MaybeT (preuse $ lStats . sDead)
@@ -182,7 +180,7 @@ stateMaintenance = do
182 cVal <- MaybeT . preuse $ eStats . sSequence . _Just . seqVal . _Just 180 cVal <- MaybeT . preuse $ eStats . sSequence . _Just . seqVal . _Just
183 name <- lift . lift $ toName ident 181 name <- lift . lift $ toName ident
184 nVal' <- MaybeT . preuse $ eStats . sSeqVal 182 nVal' <- MaybeT . preuse $ eStats . sSeqVal
185 nVal <- MaybeT . focusState eStats $ evalFormula' name nVal' 183 nVal <- MaybeT . focusState eStats $ evalFormula' [name] nVal'
186 eStats . sSequence . _Just . seqVal . _Just += nVal 184 eStats . sSequence . _Just . seqVal . _Just += nVal
187 eStats . sSequence . _Just . seqRound . _Wrapped += 1 185 eStats . sSequence . _Just . seqRound . _Wrapped += 1
188 gRounds -= 1 186 gRounds -= 1
@@ -274,7 +272,7 @@ rollTest = withArg $ enactTest' >=> maybe (return ()) (shellPutStrLn . ppResult)
274enactTest' :: (FormulaM Stats Test) -> Sh GameState (Maybe TestResult) 272enactTest' :: (FormulaM Stats Test) -> Sh GameState (Maybe TestResult)
275enactTest' test = withFocus' $ \focus -> do 273enactTest' test = withFocus' $ \focus -> do
276 focusName <- use gFocus >>= toName . fromJust 274 focusName <- use gFocus >>= toName . fromJust
277 (newFocus, result) <- evalFormula focusName focus (enactTest =<< test) 275 (newFocus, result) <- evalFormula [focusName] focus (enactTest =<< test)
278 gFocus' .= newFocus 276 gFocus' .= newFocus
279 return result 277 return result
280 278
@@ -290,7 +288,7 @@ entitySeqVal' ident = void . runMaybeT $ do
290 sVal <- MaybeT . return $ preview (eStats . sSeqVal) entity 288 sVal <- MaybeT . return $ preview (eStats . sSeqVal) entity
291 name <- toName ident 289 name <- toName ident
292 round <- use gRound 290 round <- use gRound
293 (newEntity, sNum) <- evalFormula name entity sVal 291 (newEntity, sNum) <- evalFormula [name] entity sVal
294 let val = Just $ def 292 let val = Just $ def
295 & set (seqRound . _Wrapped) round 293 & set (seqRound . _Wrapped) round
296 & set seqVal (Just sNum) 294 & set seqVal (Just sNum)
@@ -329,7 +327,7 @@ doShock dmg efLens = withFocus $ \focusId -> do
329 -- (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula 327 -- (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula
330 -- lStats .= nStats 328 -- lStats .= nStats
331 -- return x 329 -- return x
332 evalF = MaybeT . focusState lStats . evalFormula' name 330 evalF = MaybeT . focusState lStats . evalFormula' [name]
333 cVar cLens = evalF =<< MaybeT (preuse $ lStats . (cripple ^. cLens)) 331 cVar cLens = evalF =<< MaybeT (preuse $ lStats . (cripple ^. cLens))
334 bar <- cVar seBar 332 bar <- cVar seBar
335 val <- cVar seVal 333 val <- cVar seVal
@@ -350,7 +348,7 @@ takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> with
350 lStats = gEntities . ix focusId . eStats 348 lStats = gEntities . ix focusId . eStats
351 name <- toName focusId 349 name <- toName focusId
352 armor <- MaybeT . preuse $ lStats . sArmor . ix zone 350 armor <- MaybeT . preuse $ lStats . sArmor . ix zone
353 dmg' <- MaybeT . focusState lStats . evalFormula' name $ absorb armor dType dmg 351 dmg' <- MaybeT . focusState lStats . evalFormula' [name] $ absorb armor dType dmg
354 forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do 352 forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do
355 guard $ dmg > 0 353 guard $ dmg > 0
356 lift $ shellPutStrLn $ name ++ " took " ++ show dmg ++ " " ++ show dType 354 lift $ shellPutStrLn $ name ++ " took " ++ show dmg ++ " " ++ show dType