77 lines
2.3 KiB
Haskell
77 lines
2.3 KiB
Haskell
-- Represents an item in the game.
|
|
|
|
module RPGEngine.Internals.Data.Internals
|
|
( Action(..)
|
|
, Condition(..)
|
|
, Object(..)
|
|
, EntityId
|
|
, ItemId
|
|
) where
|
|
|
|
----------------------------- Constants ------------------------------
|
|
|
|
type EntityId = String
|
|
type ItemId = String
|
|
|
|
data Object =
|
|
Item { -- All fields are required
|
|
-- Easy way to identify items
|
|
id :: ItemId,
|
|
-- Horizontal coördinate in the level
|
|
x :: Int,
|
|
-- Vertical coördinate in the level
|
|
y :: Int,
|
|
name :: String,
|
|
-- Short description of the object
|
|
description :: String,
|
|
-- Counts how often the object can be used by the player. Either
|
|
-- infinite or a natural number
|
|
useTimes :: Maybe Int,
|
|
-- List of conditional actions when the player is standing on this object
|
|
actions :: [([Condition], Action)],
|
|
-- Interpretation depends on action with this object.
|
|
value :: Maybe Int
|
|
}
|
|
| Entity {
|
|
-- Required fields
|
|
-- Easy way to identify items
|
|
id :: EntityId,
|
|
-- Horizontal coördinate in the level
|
|
x :: Int,
|
|
-- Vertical coördinate in the level
|
|
y :: Int,
|
|
name :: String,
|
|
-- Short description of the object
|
|
description :: String,
|
|
-- List of conditional actions when the player is standing on this object
|
|
actions :: [([Condition], Action)],
|
|
-- Optional fields
|
|
-- The direction of the item. e.g. a door has a direction.
|
|
direction :: Maybe Direction,
|
|
-- Some entities have health points.
|
|
hp :: Maybe Int,
|
|
-- Interpretation depends on action with this object.
|
|
value :: Maybe Int
|
|
}
|
|
|
|
data Direction = North
|
|
| East
|
|
| South
|
|
| West
|
|
deriving (Show)
|
|
|
|
data Action = Leave
|
|
| RetrieveItem ItemId
|
|
| UseItem ItemId
|
|
| DecreaseHp EntityId ItemId
|
|
| IncreasePlayerHp ItemId
|
|
| Nothing
|
|
deriving (Show, Eq)
|
|
|
|
data Condition = InventoryFull
|
|
| InventoryContains ItemId
|
|
| Not Condition
|
|
| AlwaysFalse
|
|
deriving (Show, Eq)
|
|
|
|
----------------------------------------------------------------------
|