#18 Started conversion to Game

This commit is contained in:
Tibo De Peuter 2022-12-20 19:53:40 +01:00
parent d4fbcda73b
commit de02c7113f
11 changed files with 300 additions and 112 deletions

View file

@ -0,0 +1,60 @@
module RPGEngine.Data.Defaults where
import RPGEngine.Data
defaultEntity :: Entity
defaultEntity = Entity {
entityId = "",
entityX = 0,
entityY = 0,
entityName = "Default",
entityDescription = "",
entityActions = [],
entityValue = Prelude.Nothing,
entityHp = Prelude.Nothing,
direction = Center
}
-- Initialize the game
initGame :: Game
initGame = Game {
state = defaultState,
playing = defaultLevel,
levels = [defaultLevel]
}
defaultItem :: Item
defaultItem = Item {
itemId = "",
itemX = 0,
itemY = 0,
itemName = "Default",
itemDescription = "",
itemActions = [],
itemValue = Prelude.Nothing,
useTimes = Prelude.Nothing
}
defaultLayout :: Layout
defaultLayout = [
[Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked],
[Blocked, Entrance, Walkable, Walkable, Walkable, Walkable, Exit, Blocked],
[Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked, Blocked]
]
defaultLevel :: Level
defaultLevel = Level {
layout = defaultLayout,
items = [],
entities = []
}
defaultPlayer :: Player
defaultPlayer = Player {
playerHp = Prelude.Nothing, -- Compares to infinity
inventory = []
}
-- Default state of the game, Menu
defaultState :: State
defaultState = Menu

View file

@ -1,25 +0,0 @@
-- Representation of all the game's data
module RPGEngine.Data.Game
( Game(..)
,initGame
) where
import RPGEngine.Data
import RPGEngine.Data.State
----------------------------------------------------------------------
-- Initialize the game
initGame :: Game
initGame = Game {
state = defaultState,
playing = head levels,
levels = levels
}
where levels = [emptyLevel]
emptyLevel = Level {
layout = [],
items = [],
entities = []
}

View file

@ -4,19 +4,12 @@
module RPGEngine.Data.State
( State(..)
, defaultState
, nextState
) where
import RPGEngine.Data
----------------------------- Constants ------------------------------
-- Default state of the game, Menu
defaultState :: State
defaultState = Menu
----------------------------------------------------------------------
-- Get the next state based on the current state