diff options
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 11 |
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 | |||
35 | import Data.Maybe | 35 | import Data.Maybe |
36 | import Data.Bool | 36 | import Data.Bool |
37 | import Data.Monoid (All(..)) | 37 | import Data.Monoid (All(..)) |
38 | import Data.Ord | ||
38 | 39 | ||
39 | import Data.Foldable (toList) | 40 | import Data.Foldable (toList) |
40 | 41 | ||
@@ -376,4 +377,12 @@ dumpLog = use gLog >>= mapMOf (each . _1) toName >>= shellPutStrLn . toTable | |||
376 | printVal :: Completable (Formula Stats) -> Sh GameState () | 377 | printVal :: Completable (Formula Stats) -> Sh GameState () |
377 | printVal = withArg $ \formula -> withFocus $ \focusId -> do | 378 | printVal = 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 | ||