summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index eeed4d9..169c900 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -35,6 +35,7 @@ import Data.List
35import Data.Maybe 35import Data.Maybe
36import Data.Bool 36import Data.Bool
37import Data.Monoid (All(..)) 37import Data.Monoid (All(..))
38import Data.Ord
38 39
39import Data.Foldable (toList) 40import Data.Foldable (toList)
40 41
@@ -376,4 +377,12 @@ dumpLog = use gLog >>= mapMOf (each . _1) toName >>= shellPutStrLn . toTable
376printVal :: Completable (Formula Stats) -> Sh GameState () 377printVal :: Completable (Formula Stats) -> Sh GameState ()
377printVal = withArg $ \formula -> withFocus $ \focusId -> do 378printVal = withArg $ \formula -> withFocus $ \focusId -> do
378 name <- toName focusId 379 name <- toName focusId
379 shellPutStrLn . show =<< focusState (gEntities . ix focusId . eStats) (findDistribution' [name] formula) 380 outline =<< focusState (gEntities . ix focusId . eStats) (findDistribution' [name] formula)
381 where
382 outline Nothing = shellPutErrLn "No such value"
383 outline (Just (Map.toList -> [(v, _)])) = shellPutStrLn $ show v
384 outline (Just (sortBy (comparing snd) . Map.toList -> vals)) = mapM_ (shellPutStrLn . outline') vals
385 outline' (v, prob) = pad' 3 (show $ round' prob) ++ " → " ++ show v
386 round' :: RealFrac a => a -> Float
387 round' = (/ 10) . fromIntegral . (round :: RealFrac a => a -> Integer) . (* 10)
388 pad' m ys = replicate (m - length (take m ys)) ' ' ++ ys