about summary refs log tree commit diff
path: root/src/Xanthous/Entities
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-09-20T23·38-0400
committerGriffin Smith <root@gws.fyi>2019-09-20T23·38-0400
commitdd1616666593f65bab70f1363b5d040fe5edd054 (patch)
tree4009c7004ad2becd2b316c9212a8c778a8c646ce /src/Xanthous/Entities
parent4db3a68efec079bdb8723f377929bfa05860bdc2 (diff)
Describe what you see when you walk over items
Every step the character takes, describe the entities at that position
excluding the character.
Diffstat (limited to 'src/Xanthous/Entities')
-rw-r--r--src/Xanthous/Entities/Character.hs1
-rw-r--r--src/Xanthous/Entities/Creature.hs12
-rw-r--r--src/Xanthous/Entities/Environment.hs2
-rw-r--r--src/Xanthous/Entities/Item.hs15
-rw-r--r--src/Xanthous/Entities/Raws/noodles.yaml2
5 files changed, 20 insertions, 12 deletions
diff --git a/src/Xanthous/Entities/Character.hs b/src/Xanthous/Entities/Character.hs
index 695d7bb0d0d1..924c1857a8ae 100644
--- a/src/Xanthous/Entities/Character.hs
+++ b/src/Xanthous/Entities/Character.hs
@@ -41,6 +41,7 @@ instance Draw Character where
 
 instance Entity Character where
   blocksVision _ = False
+  description _ = "yourself"
 
 instance Arbitrary Character where
   arbitrary = genericArbitrary
diff --git a/src/Xanthous/Entities/Creature.hs b/src/Xanthous/Entities/Creature.hs
index b59cceab4045..c660a6cdf5d4 100644
--- a/src/Xanthous/Entities/Creature.hs
+++ b/src/Xanthous/Entities/Creature.hs
@@ -9,13 +9,14 @@ module Xanthous.Entities.Creature
   , damage
   ) where
 --------------------------------------------------------------------------------
-import Xanthous.Prelude
+import           Xanthous.Prelude
 --------------------------------------------------------------------------------
-import Data.Word
-import Test.QuickCheck.Arbitrary.Generic
+import           Data.Word
+import           Test.QuickCheck.Arbitrary.Generic
 --------------------------------------------------------------------------------
-import Xanthous.Entities.RawTypes hiding (Creature)
-import Xanthous.Entities (Draw(..), Entity(..), DrawRawChar(..))
+import           Xanthous.Entities.RawTypes hiding (Creature, description)
+import qualified Xanthous.Entities.RawTypes as Raw
+import           Xanthous.Entities (Draw(..), Entity(..), DrawRawChar(..))
 --------------------------------------------------------------------------------
 
 data Creature = Creature
@@ -31,6 +32,7 @@ instance Arbitrary Creature where
 
 instance Entity Creature where
   blocksVision _ = False
+  description = view $ creatureType . Raw.description
 
 newWithType :: CreatureType -> Creature
 newWithType _creatureType =
diff --git a/src/Xanthous/Entities/Environment.hs b/src/Xanthous/Entities/Environment.hs
index d9275266b0f4..4ef67a577dbb 100644
--- a/src/Xanthous/Entities/Environment.hs
+++ b/src/Xanthous/Entities/Environment.hs
@@ -24,6 +24,7 @@ data Wall = Wall
 
 instance Entity Wall where
   blocksVision _ = True
+  description _ = "a wall"
 
 instance Arbitrary Wall where
   arbitrary = pure Wall
@@ -65,3 +66,4 @@ instance Draw Door where
 
 instance Entity Door where
   blocksVision = not . view open
+  description _ = "a door"
diff --git a/src/Xanthous/Entities/Item.hs b/src/Xanthous/Entities/Item.hs
index baf4be2f5426..6b50f50ad83c 100644
--- a/src/Xanthous/Entities/Item.hs
+++ b/src/Xanthous/Entities/Item.hs
@@ -1,17 +1,19 @@
 {-# LANGUAGE TemplateHaskell #-}
+--------------------------------------------------------------------------------
 module Xanthous.Entities.Item
   ( Item(..)
   , itemType
   , newWithType
   ) where
 --------------------------------------------------------------------------------
-import Xanthous.Prelude
-import Test.QuickCheck
-import Data.Aeson (ToJSON, FromJSON)
-import Data.Aeson.Generic.DerivingVia
+import           Xanthous.Prelude
+import           Test.QuickCheck
+import           Data.Aeson (ToJSON, FromJSON)
+import           Data.Aeson.Generic.DerivingVia
 --------------------------------------------------------------------------------
-import Xanthous.Entities.RawTypes hiding (Item)
-import Xanthous.Entities (Draw(..), Entity(..), DrawRawChar(..))
+import           Xanthous.Entities.RawTypes hiding (Item, description)
+import qualified Xanthous.Entities.RawTypes as Raw
+import           Xanthous.Entities (Draw(..), Entity(..), DrawRawChar(..))
 --------------------------------------------------------------------------------
 
 data Item = Item
@@ -30,6 +32,7 @@ instance Arbitrary Item where
 
 instance Entity Item where
   blocksVision _ = False
+  description = view $ itemType . Raw.description
 
 newWithType :: ItemType -> Item
 newWithType = Item
diff --git a/src/Xanthous/Entities/Raws/noodles.yaml b/src/Xanthous/Entities/Raws/noodles.yaml
index 120087d48357..91a0a35388ad 100644
--- a/src/Xanthous/Entities/Raws/noodles.yaml
+++ b/src/Xanthous/Entities/Raws/noodles.yaml
@@ -1,6 +1,6 @@
 Item:
   name: noodles
-  description: a big bowl o' noodles
+  description: "a big bowl o' noodles"
   longDescription: You know exactly what kind of noodles
   char:
     char: 'n'