Fix dependency loop

This commit is contained in:
Tibo De Peuter 2022-12-22 13:31:46 +01:00
parent b7278d6afc
commit f529fc5237
25 changed files with 251 additions and 199 deletions

View file

@ -11,24 +11,24 @@ import RPGEngine.Data
Item(itemId, itemX, itemY, itemName, itemDescription, itemValue,
itemActions, useTimes),
Level(layout, items, entities),
Game (..), State (..), StateBase (..) )
Game (..), State (..) )
import RPGEngine.Parse.TextToStructure
( Value(Infinite, Action, Layout, String, Direction, Integer),
Key(Tag, ConditionList),
Structure(..) )
import RPGEngine.Data.Default (defaultPlayer, defaultLevel, defaultItem, defaultEntity)
import RPGEngine.Render.Playing (renderPlaying)
import RPGEngine.Input.Playing (handleInputPlaying)
------------------------------ Exported ------------------------------
structureToGame :: Structure -> Game
structureToGame (Block [(Entry(Tag "player") playerBlock), (Entry(Tag "levels") levelsBlock)]) = game
where game = Game{ state = newState, levels = newLevels, player = newPlayer }
newState = Playing{ base = playingBase, level = currentLevel }
playingBase = StateBase{ renderer = renderPlaying, inputHandler = handleInputPlaying }
newLevels = structureToLevels levelsBlock
currentLevel = head newLevels
-- structureToGame [Entry(Tag "player") playerBlock, Entry(Tag "levels") levelsBlock] = game
structureToGame (Entry (Tag "player") playerBlock) = game
where game = Game{ state = newState }
newState = Playing{ levels = newLevels, level = currentLevel, player = newPlayer, restart = newState }
-- newLevels = structureToLevels levelsBlock
-- currentLevel = head newLevels
newLevels = [defaultLevel]
currentLevel = defaultLevel
newPlayer = structureToPlayer playerBlock
------------------------------- Player -------------------------------

View file

@ -27,9 +27,9 @@ import Text.Parsec.String ( Parser )
-- See documentation for more details, only a short description is
-- provided here.
data Structure = Block [Structure]
| Entry Key Structure -- Key + Value
| Regular Value -- Regular value, Integer or String or Infinite
deriving (Eq, Show)
| Entry Key Structure -- Key + Value
| Regular Value -- Regular value, Integer or String or Infinite
deriving (Eq, Show)
----------------------------------------------------------------------