summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorGregor Kleen <pngwjpgh@users.noreply.github.com>2016-12-02 13:26:55 +0100
committerGregor Kleen <pngwjpgh@users.noreply.github.com>2016-12-02 13:26:55 +0100
commitcc4e079be3d0e918119c08301595460c3e91ef3c (patch)
tree753c48c922253c9b1ff6fe2d00f1b6d8898bc973 /src/Main.hs
parent7ecbf4f5c7bd0c3c2f92559a2313274b6d075e6c (diff)
download2017-01-16_17:13:37-cc4e079be3d0e918119c08301595460c3e91ef3c.tar
2017-01-16_17:13:37-cc4e079be3d0e918119c08301595460c3e91ef3c.tar.gz
2017-01-16_17:13:37-cc4e079be3d0e918119c08301595460c3e91ef3c.tar.bz2
2017-01-16_17:13:37-cc4e079be3d0e918119c08301595460c3e91ef3c.tar.xz
2017-01-16_17:13:37-cc4e079be3d0e918119c08301595460c3e91ef3c.zip
Print all applicable values
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 9a51332..1c2afd4 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -114,6 +114,7 @@ main = do
114 , cmd "heal'" healFatigue "Heal the focused entity of fatigue" 114 , cmd "heal'" healFatigue "Heal the focused entity of fatigue"
115 , cmd "log" dumpLog "Print the combat log" 115 , cmd "log" dumpLog "Print the combat log"
116 , cmd "val" printVal "Find the distribution of a specific value of the current entities" 116 , cmd "val" printVal "Find the distribution of a specific value of the current entities"
117 , cmd "summary" printVals "Find the averages of applicable all values"
117 ] 118 ]
118 , wordBreakChars = wordBreakChars initialShellDescription \\ [',', '\''] 119 , wordBreakChars = wordBreakChars initialShellDescription \\ [',', '\'']
119 } 120 }
@@ -572,3 +573,16 @@ printVal = withArg $ \formula -> withFocus $ \focusId -> do
572 lengths = map (length . show . fst) vals 573 lengths = map (length . show . fst) vals
573 -- normalize p = p / maximum (map snd vals) 574 -- normalize p = p / maximum (map snd vals)
574 normalize = id 575 normalize = id
576
577printVals :: Sh GameState ()
578printVals = withFocus $ \focusId -> do
579 name <- toName focusId
580 sheet <- Map.mapMaybe id <$> mapM (\l -> preuse $ gFocus' . eStats . to l . _Just) statAccessors
581 let
582 maxLength = maximum . map (length . CI.original) $ Map.keys sheet
583 printAvg (str, formula) = do
584 result <- focusState (gFocus' . eStats) (findAverage [name] formula)
585 case result of
586 Just avg -> shellPutStrLn $ printf "%*s: %.2f" maxLength (CI.original str) (fromRational avg :: Double)
587 Nothing -> return ()
588 mapM_ printAvg $ Map.toList sheet