diff options
author | Griffin Smith <grfn@gws.fyi> | 2021-06-18T16·42-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2021-06-18T17·51+0000 |
commit | fb5bec8d952b57fe4afa0d842ee606cf4e548563 (patch) | |
tree | 8bde10c0136c5913ef8f3afd2c2b3beba1571c47 /users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs | |
parent | 88b0d0eecc8ea87e848f2e78ebae08f3361dbeaa (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/Entities/RawTypes.hs')
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs b/users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs index ea5a90136e..b7c5fe31c9 100644 --- a/users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs +++ b/users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs @@ -13,6 +13,8 @@ module Xanthous.Entities.RawTypes -- ** Language , LanguageName(..) , getLanguage + -- ** Attacks + , Attack(..) -- * Items , ItemType(..) @@ -25,6 +27,7 @@ module Xanthous.Entities.RawTypes , isWieldable -- * Lens classes + , HasAttacks(..) , HasAttackMessage(..) , HasChar(..) , HasDamage(..) @@ -52,6 +55,7 @@ import Xanthous.Data (TicksPerTile, Hitpoints) import Xanthous.Data.EntityChar import Xanthous.Util.QuickCheck import Xanthous.Generators.Speech (Language, gormlak, english) +import Xanthous.Orphans () -------------------------------------------------------------------------------- -- | Identifiers for languages that creatures can speak. @@ -73,6 +77,23 @@ getLanguage :: LanguageName -> Language getLanguage Gormlak = gormlak getLanguage English = english +-- | Natural attacks for creature types +data Attack = Attack + { -- | the @{{creature}}@ @{{description}}@ + _description :: !Message + -- | Damage dealt + , _damage :: !Hitpoints + } + deriving stock (Show, Eq, Ord, Generic) + deriving anyclass (NFData, CoArbitrary, Function) + deriving Arbitrary via GenericArbitrary Attack + deriving (ToJSON, FromJSON) + via WithOptions '[ FieldLabelModifier '[Drop 1] + , OmitNothingFields 'True + ] + Attack +makeFieldsNoPrefix ''Attack + data CreatureType = CreatureType { _name :: !Text , _description :: !Text @@ -81,8 +102,10 @@ data CreatureType = CreatureType , _friendly :: !Bool , _speed :: !TicksPerTile , _language :: !(Maybe LanguageName) - , _sayVerb :: !(Maybe Text) -- ^ The verb, in present tense, for when the - -- creature says something + , -- | The verb, in present tense, for when the creature says something + _sayVerb :: !(Maybe Text) + , -- | The creature's natural attacks + _attacks :: !(NonNull (Vector Attack)) } deriving stock (Show, Eq, Ord, Generic) deriving anyclass (NFData, CoArbitrary, Function) |