about summary refs log tree commit diff
path: root/src/Xanthous/Monad.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-12-23T15·59-0500
committerGriffin Smith <root@gws.fyi>2019-12-23T15·59-0500
commitbf7d139c1a17fe55921fb807aa249e93288d3e4d (patch)
treea91dd3b91d4ca4e70b800d684b5dd1faffaaee6c /src/Xanthous/Monad.hs
parent8ecefddbd4cc9c79478003781877d37b3c80fcc4 (diff)
Use attack messages when attacking
When attacking, use either:
- the message defined on the entity raw of the wielded item, if any
- the generic attack message, if an item without an attack message is wielded
- the fists attack message, if no item is wielded
Diffstat (limited to 'src/Xanthous/Monad.hs')
-rw-r--r--src/Xanthous/Monad.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Xanthous/Monad.hs b/src/Xanthous/Monad.hs
index c11cb0e2d4df..1138a7a5a09b 100644
--- a/src/Xanthous/Monad.hs
+++ b/src/Xanthous/Monad.hs
@@ -10,6 +10,7 @@ module Xanthous.Monad
   , say_
   , message
   , message_
+  , writeMessage
   ) where
 --------------------------------------------------------------------------------
 import           Xanthous.Prelude
@@ -37,19 +38,18 @@ continue = lift . Brick.continue =<< get
 
 say :: (MonadRandom m, ToJSON params, MonadState GameState m)
     => [Text] -> params -> m ()
-say msgPath params = do
-  msg <- Messages.message msgPath params
-  messageHistory %= pushMessage msg
+say msgPath = writeMessage <=< Messages.message msgPath
 
 say_ :: (MonadRandom m, MonadState GameState m) => [Text] -> m ()
 say_ msgPath = say msgPath $ object []
 
 message :: (MonadRandom m, ToJSON params, MonadState GameState m)
         => Message -> params -> m ()
-message msg params = do
-  m <- Messages.render msg params
-  messageHistory %= pushMessage m
+message msg = writeMessage <=< Messages.render msg
 
 message_ :: (MonadRandom m, MonadState GameState m)
          => Message ->  m ()
 message_ msg = message msg $ object []
+
+writeMessage :: MonadState GameState m => Text -> m ()
+writeMessage m = messageHistory %= pushMessage m