Allow for concurrent effects

This commit is contained in:
2022-08-16 16:02:09 +01:00
parent 919a179283
commit 26e88f059a
14 changed files with 181 additions and 53 deletions
+13 -4
View File
@@ -1,21 +1,30 @@
module Dodge.StartNewGame where
import Dodge.Save
import Control.Lens
import Dodge.Data.Universe
import Dodge.LevelGen
import System.Random
startNewGame :: Universe -> Universe
startNewGame u = startSeedGame i u
startNewGame u = case u ^. uvWorld . gameSlot of
GameNum i -> startNewGameInSlot i u
GameLoading{} -> u
GameStartScreen -> startNewGameInSlot 0 u -- this needs to be changed
startNewGameInSlot :: Int -> Universe -> Universe
startNewGameInSlot slot u = startSeedGame slot i u
where
i = fst $ randomR (0, maxBound) (_randGen (_uvWorld u))
startSeedGame :: Int -> Universe -> Universe
startSeedGame i u =
startSeedGame :: Int -> Int -> Universe -> Universe
startSeedGame slot i u =
u
& menuLayers .~ [WaitScreen (const "GENERATING...") 1]
& uvIOEffects .~ \_ -> do
w <- generateWorldFromSeed i
return $
u & menuLayers .~ [] & uvWorld .~ w
& savedWorlds . at LevelStartSlot ?~ w
& uvWorld . gameSlot .~ GameNum slot
& saveWorldInSlot (LevelStartSlot slot)
-- & savedWorlds . at LevelStartSlot ?~ w