Improve configuration handling

This commit is contained in:
jgk
2021-04-08 02:48:25 +02:00
parent ddb1171e2e
commit f1214c0584
14 changed files with 118 additions and 54 deletions
+8 -7
View File
@@ -23,14 +23,15 @@ import qualified Data.IntMap.Strict as IM
import qualified Data.Map as M
import Control.Lens
{- | The update step.
If the '_menuState' is not 'InGame', this is the identity.
This means that the only way to change the world is using event handling.
If '_menuLayers' is not empty, or the saving screen, this is the identity.
In such menus, the only way to change the world is using event handling.
-}
update :: World -> World
update w
| _menuState w /= InGame = w
| otherwise =
let w1 = updateParticles' . updateProjectiles
update w = case _menuLayers w of
(ConfigSaveScreen x: ls) -> w & menuLayers .~ (ConfigSaveScreen (x-1) : ls)
(ConfigSaveScreen 0: ls) -> w & menuLayers .~ ls
(_ : _) -> w
[] -> let w1 = updateParticles' . updateProjectiles
. updateLightSources
. zoneClouds
. updateClouds
@@ -101,7 +102,7 @@ setTestStringIO = fmap (\ w -> set testString (show $ s w) w)
where s w = (-.-) <$> (w ^? creatures . ix 0 . crPos) <*> (w ^? creatures . ix 0 . crOldPos)
checkEndGame :: World -> World
checkEndGame w | _crHP (you w) < 1 = haltSound $ w {_menuState = GameOverMenu}
checkEndGame w | _crHP (you w) < 1 = haltSound $ w {_menuLayers = [GameOverMenu]}
| otherwise = w
updateClouds :: World -> World