diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-12-02 13:26:55 +0100 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-12-02 13:26:55 +0100 |
commit | cc4e079be3d0e918119c08301595460c3e91ef3c (patch) | |
tree | 753c48c922253c9b1ff6fe2d00f1b6d8898bc973 /src/Main.hs | |
parent | 7ecbf4f5c7bd0c3c2f92559a2313274b6d075e6c (diff) | |
download | 2017-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.hs | 14 |
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 | |||
577 | printVals :: Sh GameState () | ||
578 | printVals = 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 | ||