Move universe IO effects outside of world

This commit is contained in:
2022-07-23 12:53:20 +01:00
parent 2892bb25f0
commit 12fad676f2
12 changed files with 41 additions and 44 deletions
+10 -8
View File
@@ -62,7 +62,7 @@ updateUniverse u = case _menuLayers u of
{- | The update step. -}
functionalUpdate :: Universe -> Universe
functionalUpdate w = over uvWorld checkEndGame
functionalUpdate w = checkEndGame
-- . updateRandGen
. over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held
. over uvWorld (worldClock +~ 1)
@@ -364,13 +364,15 @@ markWallSeen !w !i = w { _walls = IM.adjust markSeen i $ _walls w }
markSeen :: Wall -> Wall
markSeen wl = wl {_wlSeen = True}
checkEndGame :: World -> World
checkEndGame w = case _deathDelay w of
Just x | x < 0 -> w & sideEffects %~ ( . (menuLayers .~ [gameOverMenu]))
& deathDelay .~ Nothing
Just _ -> w & deathDelay . _Just -~ 1
_ | _crHP (you w) < 1 -> w & deathDelay ?~ 50
_ -> w
checkEndGame :: Universe -> Universe
checkEndGame uv = case _deathDelay w of
Just x | x < 0 -> uv & menuLayers .~ [gameOverMenu]
& uvWorld . deathDelay .~ Nothing
Just _ -> uv & uvWorld . deathDelay . _Just -~ 1
_ | _crHP (you w) < 1 -> uv & uvWorld . deathDelay ?~ 50
_ -> uv
where
w = _uvWorld uv
updateGusts :: World -> World
updateGusts w = w