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.
This commit is contained in:
parent
15895c69fe
commit
62a2e05ef2
20 changed files with 365 additions and 106 deletions
35
src/Xanthous/Entities/Item.hs
Normal file
35
src/Xanthous/Entities/Item.hs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
{-# 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.Entities.RawTypes hiding (Item)
|
||||
import Xanthous.Entities (Draw(..), Entity(..), DrawRawChar(..))
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
data Item = Item
|
||||
{ _itemType :: ItemType
|
||||
}
|
||||
deriving stock (Eq, Show, Generic)
|
||||
deriving anyclass (CoArbitrary, Function)
|
||||
deriving Draw via DrawRawChar "_itemType" Item
|
||||
deriving (ToJSON, FromJSON)
|
||||
via WithOptions '[ FieldLabelModifier '[Drop 1] ]
|
||||
Item
|
||||
makeLenses ''Item
|
||||
|
||||
instance Arbitrary Item where
|
||||
arbitrary = Item <$> arbitrary
|
||||
|
||||
instance Entity Item where
|
||||
blocksVision _ = False
|
||||
|
||||
newWithType :: ItemType -> Item
|
||||
newWithType = Item
|
||||
Loading…
Add table
Add a link
Reference in a new issue