about summary refs log tree commit diff
path: root/users/grfn/xanthous/src/Xanthous/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous/Entities')
-rw-r--r--users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs27
-rw-r--r--users/grfn/xanthous/src/Xanthous/Entities/Raws/gormlak.yaml9
-rw-r--r--users/grfn/xanthous/src/Xanthous/Entities/Raws/ooze.yaml3
3 files changed, 35 insertions, 4 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs b/users/grfn/xanthous/src/Xanthous/Entities/RawTypes.hs
index ea5a90136e4e..b7c5fe31c995 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)
diff --git a/users/grfn/xanthous/src/Xanthous/Entities/Raws/gormlak.yaml b/users/grfn/xanthous/src/Xanthous/Entities/Raws/gormlak.yaml
index 8cddf85394a6..ad3d9cb147da 100644
--- a/users/grfn/xanthous/src/Xanthous/Entities/Raws/gormlak.yaml
+++ b/users/grfn/xanthous/src/Xanthous/Entities/Raws/gormlak.yaml
@@ -2,8 +2,8 @@ Creature:
   name: gormlak
   description: a gormlak
   longDescription: |
-    A chittering imp-like creature with bright yellow horns. It adores shiny objects
-    and gathers in swarms.
+    A chittering imp-like creature with bright yellow horns and sharp claws. It
+    adores shiny objects and gathers in swarms.
   char:
     char: g
     style:
@@ -13,3 +13,8 @@ Creature:
   friendly: false
   language: Gormlak
   sayVerb: yells
+  attacks:
+  - description:
+      - claws you
+      - slashes you with its claws
+    damage: 1
diff --git a/users/grfn/xanthous/src/Xanthous/Entities/Raws/ooze.yaml b/users/grfn/xanthous/src/Xanthous/Entities/Raws/ooze.yaml
index d13b5881dfdc..fe427c94abf7 100644
--- a/users/grfn/xanthous/src/Xanthous/Entities/Raws/ooze.yaml
+++ b/users/grfn/xanthous/src/Xanthous/Entities/Raws/ooze.yaml
@@ -10,3 +10,6 @@ Creature:
   maxHitpoints: 3
   speed: 100
   friendly: false
+  attacks:
+  - description: slams into you
+    damage: 1