From 7cb729577b26ce53ecd9c497be2e496b984f66d7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 25 Jul 2016 12:56:47 +0200 Subject: Allow dropping out of combat --- src/Main.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index 8f44db8..9a6a486 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -95,6 +95,8 @@ main = do , cmd "test" rollTest "Roll a test using the stats of the currently focused entity" , cmd "combat" entitySeqVal "Roll sequence value for the current focus and enter combat" , cmd "combat'" factionSeqVal "Roll sequence values for all members of a faction and have them enter combat" + , cmd "uncombat" clearEntitySeqVal "Drop the focused entity out of combat" + , cmd "uncombat'" clearFactionSeqVal "Drop all members of a faction out of combat" , cmd "spend" spendSeq "Spend some of the current focusĀ“ AP" , cmd "delay" delay "Spend AP until the current focusĀ“ sequence is no higher than the next highest and focus that one" , cmd "note" addNote "Add a note to the current focus" @@ -307,7 +309,13 @@ entitySeqVal = withFocus entitySeqVal' factionSeqVal :: Completable Faction -> Sh GameState () factionSeqVal = withArg $ \qFaction -> use gEntities >>= mapM_ (entitySeqVal') . Map.keys . Map.filter ((==) qFaction . view eFaction) -entitySeqVal' :: EntityIdentifier -> Sh GameState () +clearEntitySeqVal :: Sh GameState () +clearEntitySeqVal = withFocus clearEntitySeqVal' + +clearFactionSeqVal :: Completable Faction -> Sh GameState () +clearFactionSeqVal = withArg $ \qFaction -> use gEntities >>= mapM_ (clearEntitySeqVal') . Map.keys . Map.filter ((==) qFaction . view eFaction) + +entitySeqVal', clearEntitySeqVal' :: EntityIdentifier -> Sh GameState () entitySeqVal' ident = void . runMaybeT $ do entity <- MaybeT $ preuse (gEntities . ix ident) let sVal = fromMaybe (val ignored ["Sequenzwert"] False) $ preview (eStats . sSeqVal) entity @@ -320,6 +328,7 @@ entitySeqVal' ident = void . runMaybeT $ do & set seqEpsilon (entity ^. eStats . sSeqEpsilon) gEntities . at ident .= Just (newEntity & set eSeqVal val) gLog <>= pure (ident, "Sequence: " ++ show sNum) +clearEntitySeqVal' ident = gEntities . ix ident . eSeqVal .= Nothing spendSeq :: Int -> String -> Sh GameState () spendSeq n logStr = withFocus $ \focusId -> do -- cgit v1.2.3