about summary refs log tree commit diff
path: root/users/grfn/xanthous/src/Xanthous/Messages.hs
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-06-18T16·42-0400
committergrfn <grfn@gws.fyi>2021-06-18T17·51+0000
commitfb5bec8d952b57fe4afa0d842ee606cf4e548563 (patch)
tree8bde10c0136c5913ef8f3afd2c2b3beba1571c47 /users/grfn/xanthous/src/Xanthous/Messages.hs
parent88b0d0eecc8ea87e848f2e78ebae08f3361dbeaa (diff)
feat(xanthous): Add configurable natural attacks r/2674
Allow configuring the natural attacks (eg, part of their body rather
than an item) of a creature. Each attack has a description and a damage
associated with it.

Change-Id: I69698a8ac4ee2da91e4c88e419593627519522a5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3220
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Messages.hs')
-rw-r--r--users/grfn/xanthous/src/Xanthous/Messages.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Messages.hs b/users/grfn/xanthous/src/Xanthous/Messages.hs
index 2b1b3da1e8c1..985694139783 100644
--- a/users/grfn/xanthous/src/Xanthous/Messages.hs
+++ b/users/grfn/xanthous/src/Xanthous/Messages.hs
@@ -9,6 +9,7 @@ module Xanthous.Messages
     -- * Game messages
   , messages
   , render
+  , render_
   , lookup
   , message
   , message_
@@ -17,7 +18,7 @@ module Xanthous.Messages
 import Xanthous.Prelude hiding (lookup)
 --------------------------------------------------------------------------------
 import           Control.Monad.Random.Class (MonadRandom)
-import           Data.Aeson (FromJSON, ToJSON, toJSON)
+import           Data.Aeson (FromJSON, ToJSON, toJSON, object)
 import qualified Data.Aeson as JSON
 import           Data.Aeson.Generic.DerivingVia
 import           Data.FileEmbed
@@ -89,6 +90,10 @@ render msg params = do
   tpl <- resolve msg
   pure . toStrict . renderMustache tpl $ toJSON params
 
+-- | Render a message with an empty set of params
+render_ :: (MonadRandom m) => Message -> m Text
+render_ msg = render msg $ object []
+
 lookup :: [Text] -> Message
 lookup path = fromMaybe notFound $ messages ^? ix path
   where notFound