feat(xanthous): Add configurable natural attacks
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
This commit is contained in:
parent
88b0d0eecc
commit
fb5bec8d95
7 changed files with 69 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue