From 62a2e05ef222dd69263b819a400a83f8910816f9 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Thu, 19 Sep 2019 13:56:14 -0400 Subject: 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. --- src/Xanthous/Entities/Creature.hs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/Xanthous/Entities/Creature.hs') 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 -- cgit 1.4.1