diff options
author | Griffin Smith <root@gws.fyi> | 2019-09-19T17·56-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-09-19T17·56-0400 |
commit | 62a2e05ef222dd69263b819a400a83f8910816f9 (patch) | |
tree | b81ee35bcc1f6f20290e6347e5b6ceff8a9fff12 /src/Xanthous/Entities/Creature.hs | |
parent | 15895c69fe8f1415f45fe33f7b3d564f4239496e (diff) |
Add items and inventory
Add a new "Item" entity, which pulls from the previously-existent ItemType raw, and add a "PickUp" command which takes the (currently *only*) item off the ground and puts it into the inventory.
Diffstat (limited to 'src/Xanthous/Entities/Creature.hs')
-rw-r--r-- | src/Xanthous/Entities/Creature.hs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/Xanthous/Entities/Creature.hs b/src/Xanthous/Entities/Creature.hs index 5af24a8cd3eb..024859473f21 100644 --- a/src/Xanthous/Entities/Creature.hs +++ b/src/Xanthous/Entities/Creature.hs @@ -1,28 +1,33 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TemplateHaskell #-} --- | - -module Xanthous.Entities.Creature where - -import Data.Word - +-------------------------------------------------------------------------------- +module Xanthous.Entities.Creature + ( Creature(..) + , creatureType + , hitpoints + , newWithType + , damage + ) where +-------------------------------------------------------------------------------- import Xanthous.Prelude +-------------------------------------------------------------------------------- +import Data.Word +-------------------------------------------------------------------------------- import Xanthous.Entities.RawTypes hiding (Creature) -import Xanthous.Entities (Draw(..), Entity(..)) +import Xanthous.Entities (Draw(..), Entity(..), DrawRawChar(..)) +-------------------------------------------------------------------------------- data Creature = Creature { _creatureType :: CreatureType , _hitpoints :: Word16 } deriving stock (Eq, Show, Generic) + deriving Draw via DrawRawChar "_creatureType" Creature makeLenses ''Creature instance Entity Creature where blocksVision _ = False -instance Draw Creature where - draw = draw .view (creatureType . char) - newWithType :: CreatureType -> Creature newWithType _creatureType = let _hitpoints = _creatureType ^. maxHitpoints |