From d196ace4100ec5f8cfb0fad265d3baa44873fc9d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 14 Jun 2016 03:26:18 +0200 Subject: fixed questions --- src/Main.hs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/Main.hs') 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) import qualified Data.Text.Lazy as Lazy.Text import Data.Text.Template -import Debug.Trace - main :: IO () main = do historyFile <- getUserCacheFile "sequence" "history" @@ -158,7 +156,7 @@ stateMaintenance = do lStats = gEntities . ix focusId . eStats evalF formula = do stats <- MaybeT $ preuse lStats - (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula + (nStats, x) <- (evalFormula [name] :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula lStats .= nStats return x isDead <- evalF =<< MaybeT (preuse $ lStats . sDead) @@ -182,7 +180,7 @@ stateMaintenance = do cVal <- MaybeT . preuse $ eStats . sSequence . _Just . seqVal . _Just name <- lift . lift $ toName ident nVal' <- MaybeT . preuse $ eStats . sSeqVal - nVal <- MaybeT . focusState eStats $ evalFormula' name nVal' + nVal <- MaybeT . focusState eStats $ evalFormula' [name] nVal' eStats . sSequence . _Just . seqVal . _Just += nVal eStats . sSequence . _Just . seqRound . _Wrapped += 1 gRounds -= 1 @@ -274,7 +272,7 @@ rollTest = withArg $ enactTest' >=> maybe (return ()) (shellPutStrLn . ppResult) enactTest' :: (FormulaM Stats Test) -> Sh GameState (Maybe TestResult) enactTest' test = withFocus' $ \focus -> do focusName <- use gFocus >>= toName . fromJust - (newFocus, result) <- evalFormula focusName focus (enactTest =<< test) + (newFocus, result) <- evalFormula [focusName] focus (enactTest =<< test) gFocus' .= newFocus return result @@ -290,7 +288,7 @@ entitySeqVal' ident = void . runMaybeT $ do sVal <- MaybeT . return $ preview (eStats . sSeqVal) entity name <- toName ident round <- use gRound - (newEntity, sNum) <- evalFormula name entity sVal + (newEntity, sNum) <- evalFormula [name] entity sVal let val = Just $ def & set (seqRound . _Wrapped) round & set seqVal (Just sNum) @@ -329,7 +327,7 @@ doShock dmg efLens = withFocus $ \focusId -> do -- (nStats, x) <- (evalFormula name :: Stats -> FormulaM Stats a -> MaybeT (Sh GameState) (Stats, a)) stats formula -- lStats .= nStats -- return x - evalF = MaybeT . focusState lStats . evalFormula' name + evalF = MaybeT . focusState lStats . evalFormula' [name] cVar cLens = evalF =<< MaybeT (preuse $ lStats . (cripple ^. cLens)) bar <- cVar seBar val <- cVar seVal @@ -350,7 +348,7 @@ takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> with lStats = gEntities . ix focusId . eStats name <- toName focusId armor <- MaybeT . preuse $ lStats . sArmor . ix zone - dmg' <- MaybeT . focusState lStats . evalFormula' name $ absorb armor dType dmg + dmg' <- MaybeT . focusState lStats . evalFormula' [name] $ absorb armor dType dmg forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do guard $ dmg > 0 lift $ shellPutStrLn $ name ++ " took " ++ show dmg ++ " " ++ show dType -- cgit v1.2.3