#18 & massive structure overhaul

This commit is contained in:
Tibo De Peuter 2022-12-19 22:54:42 +01:00
parent 83659e69b4
commit 3b0de65de1
16 changed files with 397 additions and 221 deletions

View file

@ -1,61 +0,0 @@
-- Represents an item in the game.
module Internals
( Action(..)
, Object(..)
) where
----------------------------- Constants ------------------------------
data Object =
Item { -- All fields are required
-- Easy way to identify items
id :: String,
-- 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 :: [Action],
-- Interpretation depends on action with this object.
value :: Maybe Int
}
| Entity {
-- Required fields
-- Easy way to identify items
id :: String,
-- 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 :: [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)
type Action = ([Condition], Event)
type Condition = Bool
type Event = *