From 486604532fa99fd294bb2d0c4166d815de6d4fde Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 10 Jun 2016 14:20:08 +0200 Subject: entity notes --- src/Main.hs | 20 ++++++++++++++++++-- src/Sequence/Contact/Archetypes.hs | 5 +++++ src/Sequence/Types.hs | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Main.hs b/src/Main.hs index e6d694a..36f2687 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -59,7 +59,10 @@ main = do description = initialShellDescription { historyFile = Just historyFile , prompt = \st -> return $ maybe "" (++ " ") ((evalState ?? st) . toName <$> view gFocus st) ++ "→ " - , beforePrompt = gets stateOutline >>= (\str -> if null str then return () else shellPutStrLn str) + , beforePrompt = do + { gets stateOutline >>= (\str -> if null str then return () else shellPutStr str) + ; gets focusNotes >>= (\str -> if null str then return () else shellPutStrLn str) + } , commandStyle = OnlyCommands , shellCommands = [ exitCommand "exit" , helpCommand "help" @@ -80,6 +83,7 @@ main = do , cmd "combat'" factionSeqVal "Roll sequence values for all members of a faction and have them enter 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" + , cmd "note" addNote "Add a note to the current focus" ] } void $ runShell description haskelineBackend (def :: GameState) @@ -106,6 +110,15 @@ stateOutline st roundStr n = show n ++ " Rounds later" factions = map (view faction') $ st ^. inhabitedFactions +focusNotes :: GameState -> String +focusNotes = maybe "" (unlines . map dotted) . preview (gFocus' . eNotes) + where + dotted "" = " • " + dotted str + | fstL : [] <- lines str = " • " ++ fstL + | fstL : tailL <- lines str = " • " ++ fstL ++ "\n" ++ unlines (map (" " ++ ) tailL) + | otherwise = "" + -- Query state listFactions, listEntities :: Sh GameState () listFactions = use inhabitedFactions >>= mapM_ (shellPutStrLn . view faction') @@ -119,7 +132,7 @@ blur = gFocus .= Nothing -- Manual focus setFocus :: Completable EntityIdentifier -> Sh GameState () setFocus = withArg $ \ident -> gFocus ?= ident - + -- Drop information remove :: Sh GameState () remove = withFocus $ \ident -> do @@ -228,3 +241,6 @@ delay = withFocus $ \focusId -> () <$ runMaybeT (delay' focusId) focusSeq <- MaybeT . preuse $ gEntities . ix focusId . eStats . sSequence . _Just . seqVal . _Just guard $ focusSeq > tipSeq lift . spendSeq $ focusSeq - tipSeq + +addNote :: String -> Sh GameState () +addNote note = withFocus $ \focusId -> gEntities . ix focusId . eNotes %= (note :) diff --git a/src/Sequence/Contact/Archetypes.hs b/src/Sequence/Contact/Archetypes.hs index 32cfa22..30aa2b6 100644 --- a/src/Sequence/Contact/Archetypes.hs +++ b/src/Sequence/Contact/Archetypes.hs @@ -96,6 +96,7 @@ human = Humanoid , _sPainTolerance = vMass `quot'` 2 + vWillpower , _sFatigueTolerance = vWillpower `quot'` 2 + vEndurance + , _sSeqEpsilon = False , _sHitzones = cTable [ (1, 5, "Kopf") , (6, 54, "Torso") @@ -173,6 +174,8 @@ dog = Quadruped , _sPainTolerance = vMass `quot'` 2 + vWillpower , _sFatigueTolerance = vWillpower `quot'` 2 + vEndurance + , _sSeqEpsilon = False + , _sHitzones = [ ("Kopf", 0.05) , ("Torso", 0.49) , ("Rechter Vorderlauf", 0.08) @@ -208,6 +211,8 @@ dolphin = Dolphin , _sPainTolerance = vMass `quot'` 2 + vWillpower , _sFatigueTolerance = vWillpower `quot'` 2 + vEndurance + , _sSeqEpsilon = False + , _sHitzones = [ ("Kopf", 0.10) , ("Rumpf", 0.65) , ("Schwanz", 0.25) diff --git a/src/Sequence/Types.hs b/src/Sequence/Types.hs index f5bf010..6594f78 100644 --- a/src/Sequence/Types.hs +++ b/src/Sequence/Types.hs @@ -3,7 +3,7 @@ module Sequence.Types ( GameState, gEntities, gEntityNames, gFocus, gNextId' , Faction, faction, faction' - , Entity(..), eFaction, eSeqVal, eStats + , Entity(..), eFaction, eSeqVal, eStats, eNotes , EntityName(..), entityName , EntityIdentifier(..), entityId, entityId' , inhabitedFactions, priorityQueue, tip, insertEntity, gFocus', gRounds, gRounds', gRound -- cgit v1.2.3