summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-08 01:31:19 +0200
committerGregor Kleen <pngwjpgh@users.noreply.github.com>2016-07-08 01:32:01 +0200
commitf235d13556440d9ae6e4cf0885f68e1794b81e61 (patch)
treee20f310b7421b25b72dc97a2bbb3e2ad9551fb39
parent3496781f3ebad2901b60f19b388c893d8ad8aa37 (diff)
download2017-01-16_17:13:37-f235d13556440d9ae6e4cf0885f68e1794b81e61.tar
2017-01-16_17:13:37-f235d13556440d9ae6e4cf0885f68e1794b81e61.tar.gz
2017-01-16_17:13:37-f235d13556440d9ae6e4cf0885f68e1794b81e61.tar.bz2
2017-01-16_17:13:37-f235d13556440d9ae6e4cf0885f68e1794b81e61.tar.xz
2017-01-16_17:13:37-f235d13556440d9ae6e4cf0885f68e1794b81e61.zip
More logging
-rw-r--r--sequence.cabal1
-rw-r--r--sequence.nix10
-rw-r--r--src/Main.hs5
-rw-r--r--src/Sequence/Utils.hs8
4 files changed, 17 insertions, 7 deletions
diff --git a/sequence.cabal b/sequence.cabal
index 931cba6..740a975 100644
--- a/sequence.cabal
+++ b/sequence.cabal
@@ -39,5 +39,6 @@ executable sequence
39 , ansi-terminal 39 , ansi-terminal
40 , text 40 , text
41 , template 41 , template
42 , regex-compat
42 hs-source-dirs: src 43 hs-source-dirs: src
43 default-language: Haskell2010 \ No newline at end of file 44 default-language: Haskell2010 \ No newline at end of file
diff --git a/sequence.nix b/sequence.nix
index ae75127..e0d93b7 100644
--- a/sequence.nix
+++ b/sequence.nix
@@ -1,8 +1,8 @@
1{ mkDerivation, ansi-terminal, base, bimap, case-insensitive 1{ mkDerivation, ansi-terminal, base, bimap, case-insensitive
2, containers, data-default, directory, filepath, game-probability 2, containers, data-default, directory, filepath, game-probability
3, lens, mtl, readline, Shellac, Shellac-haskeline, stdenv 3, lens, mtl, readline, regex-compat, Shellac, Shellac-haskeline
4, table-layout, template, text, transformers, transformers-base 4, stdenv, table-layout, template, text, transformers
5, xdg-basedir 5, transformers-base, xdg-basedir
6}: 6}:
7mkDerivation { 7mkDerivation {
8 pname = "sequence"; 8 pname = "sequence";
@@ -12,8 +12,8 @@ mkDerivation {
12 isExecutable = true; 12 isExecutable = true;
13 executableHaskellDepends = [ 13 executableHaskellDepends = [
14 ansi-terminal base bimap case-insensitive containers data-default 14 ansi-terminal base bimap case-insensitive containers data-default
15 directory filepath game-probability lens mtl readline Shellac 15 directory filepath game-probability lens mtl readline regex-compat
16 Shellac-haskeline table-layout template text transformers 16 Shellac Shellac-haskeline table-layout template text transformers
17 transformers-base xdg-basedir 17 transformers-base xdg-basedir
18 ]; 18 ];
19 license = stdenv.lib.licenses.mit; 19 license = stdenv.lib.licenses.mit;
diff --git a/src/Main.hs b/src/Main.hs
index 449e21d..de90b80 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -297,6 +297,7 @@ entitySeqVal' ident = void . runMaybeT $ do
297 & set seqVal (Just sNum) 297 & set seqVal (Just sNum)
298 & set seqEpsilon (entity ^. eStats . sSeqEpsilon) 298 & set seqEpsilon (entity ^. eStats . sSeqEpsilon)
299 gEntities . at ident .= Just (newEntity & set eSeqVal val) 299 gEntities . at ident .= Just (newEntity & set eSeqVal val)
300 gLog <>= pure (ident, "Sequence: " ++ show sNum)
300 301
301spendSeq :: Int -> String -> Sh GameState () 302spendSeq :: Int -> String -> Sh GameState ()
302spendSeq n logStr = withFocus $ \focusId -> do 303spendSeq n logStr = withFocus $ \focusId -> do
@@ -342,7 +343,7 @@ doShock dmg efLens = withFocus $ \focusId -> do
342 lStats . efLens . seApplied .= True 343 lStats . efLens . seApplied .= True
343 Effect (CI.original -> effectName) effect <- evalF . table $ cripple ^. seEffect 344 Effect (CI.original -> effectName) effect <- evalF . table $ cripple ^. seEffect
344 lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect) 345 lStats <~ (MaybeT . fmap join . runMaybeT $ evalF effect)
345 lift $ shellPutStrLn effectName 346 lift . outputLogged focusId $ "Effect: " ++ effectName
346 lift . addNote $ "Effect: " ++ effectName 347 lift . addNote $ "Effect: " ++ effectName
347 348
348takeHit :: Int -> Completable (Set Hitzone) -> Completable DamageType -> Sh GameState () 349takeHit :: Int -> Completable (Set Hitzone) -> Completable DamageType -> Sh GameState ()
@@ -355,7 +356,7 @@ takeHit dmg a1 a2 = flip withArg a1 $ \zones -> flip withArg a2 $ \dType -> with
355 dmg' <- MaybeT . focusState lStats . evalFormula' [name] $ absorb armor dType dmg 356 dmg' <- MaybeT . focusState lStats . evalFormula' [name] $ absorb armor dType dmg
356 forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do 357 forM_ (Map.toList dmg') $ \(dType, dmg) -> lift . runMaybeT $ do
357 guard $ dmg > 0 358 guard $ dmg > 0
358 lift $ shellPutStrLn $ name ++ " took " ++ show dmg ++ " " ++ show dType 359 lift . outputLogged focusId $ name ++ " took " ++ show dmg ++ " " ++ show dType
359 case dType of 360 case dType of
360 Fatigue -> lStats . sFatigue += dmg 361 Fatigue -> lStats . sFatigue += dmg
361 _ -> lStats . sDamage . ix zone += dmg 362 _ -> lStats . sDamage . ix zone += dmg
diff --git a/src/Sequence/Utils.hs b/src/Sequence/Utils.hs
index 1d34a4f..fbf3c7d 100644
--- a/src/Sequence/Utils.hs
+++ b/src/Sequence/Utils.hs
@@ -4,6 +4,7 @@ module Sequence.Utils
4 ( withArg, withFocus, withFocus' 4 ( withArg, withFocus, withFocus'
5 , focusState 5 , focusState
6 , toName, toDesc 6 , toName, toDesc
7 , outputLogged
7 , Argument(..) 8 , Argument(..)
8 , Completion(..) 9 , Completion(..)
9 , module Sequence.Utils.Ask 10 , module Sequence.Utils.Ask
@@ -47,6 +48,8 @@ import Sequence.Utils.Ask
47import Sequence.Contact.Types 48import Sequence.Contact.Types
48import Sequence.Formula 49import Sequence.Formula
49 50
51import Text.Regex (mkRegex, subRegex)
52
50class Argument a st | a -> st where 53class Argument a st | a -> st where
51 arg :: String -> Sh st (Maybe a) 54 arg :: String -> Sh st (Maybe a)
52 55
@@ -85,6 +88,11 @@ toDesc ident = do
85 Just dmg -> return $ name ++ " " ++ show dmg 88 Just dmg -> return $ name ++ " " ++ show dmg
86 Nothing -> return name 89 Nothing -> return name
87 90
91outputLogged :: EntityIdentifier -> String -> Sh GameState ()
92outputLogged id str = gLog <>= pure (id, clean str) >> shellPutStrLn str
93 where
94 clean str = subRegex (mkRegex "(\x9B|\x1B\\[)[0-?]*[ -/]*[@-~]") str "" -- remove ANSI escapes
95
88instance Completion EntityIdentifier GameState where 96instance Completion EntityIdentifier GameState where
89 completableLabel _ = "<entity>" 97 completableLabel _ = "<entity>"
90 complete _ st prefix = return . filter ((isPrefixOf `on` CI.foldCase) prefix) . map ((evalState ?? st) . toName) . Map.keys $ st ^. gEntities 98 complete _ st prefix = return . filter ((isPrefixOf `on` CI.foldCase) prefix) . map ((evalState ?? st) . toName) . Map.keys $ st ^. gEntities