diff --git a/lib/data/Internals.hs b/lib/data/Internals.hs new file mode 100644 index 0000000..68f1a8d --- /dev/null +++ b/lib/data/Internals.hs @@ -0,0 +1,61 @@ +-- 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 = * \ No newline at end of file diff --git a/lib/data/Player.hs b/lib/data/Player.hs new file mode 100644 index 0000000..642a6c3 --- /dev/null +++ b/lib/data/Player.hs @@ -0,0 +1,15 @@ +-- Represents a player in the game. This player can move around, pick +-- up items and interact with the world. + +module Player +( Player(..) +) where + +import Internals + +----------------------------- Constants ------------------------------ + +data Player = Player { + hp :: Int, + inventory :: [Object] +} \ No newline at end of file diff --git a/rpg-engine.cabal b/rpg-engine.cabal index 28aea68..cf4a6f8 100644 --- a/rpg-engine.cabal +++ b/rpg-engine.cabal @@ -11,8 +11,11 @@ library gloss >= 1.11 && < 1.14, gloss-juicy >= 0.2.3 exposed-modules: RPGEngine, + -- Control Input, InputHandling, - Game, State, + -- Data + Game, Internals, Player, State, + -- Render Render executable rpg-engine