swarm-0.5.0.0: 2D resource gathering game with programmable robots
LicenseBSD-3-Clause
Safe HaskellSafe-Inferred
LanguageHaskell2010

Swarm.TUI.Model.StateUpdate

Description

 
Synopsis

Documentation

initAppState :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => AppOpts -> m AppState Source #

Initialize the AppState from scratch.

initPersistentState :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => AppOpts -> m (RuntimeState, UIState) Source #

Initialize the more persistent parts of the app state, i.e. the RuntimeState and UIState. This is split out into a separate function so that in the integration test suite we can call this once and reuse the resulting states for all tests.

constructAppState :: (Has (Throw SystemFailure) sig m, Has (Lift IO) sig m) => RuntimeState -> UIState -> AppOpts -> m AppState Source #

Construct an AppState from an already-loaded RuntimeState and UIState, given the AppOpts the app was started with.

initAppStateForScenario :: String -> Maybe Seed -> Maybe FilePath -> ExceptT Text IO AppState Source #

Create an initial app state for a specific scenario. Note that this function is used only for unit tests, integration tests, and benchmarks.

In normal play, an AppState already exists and we simply need to update it using scenarioToAppState.

classicGame0 :: ExceptT Text IO AppState Source #

For convenience, the AppState corresponding to the classic game with seed 0. This is used only for benchmarks and unit tests.

startGame :: (MonadIO m, MonadState AppState m) => ScenarioInfoPair -> Maybe CodeToRun -> m () Source #

Load a Scenario and start playing the game.

startGameWithSeed :: (MonadIO m, MonadState AppState m) => ScenarioInfoPair -> ValidatedLaunchParams -> m () Source #

Load a Scenario and start playing the game, with the possibility for the user to override the seed.

restartGame :: (MonadIO m, MonadState AppState m) => Seed -> ScenarioInfoPair -> m () Source #

Re-initialize the game from the stored reference to the current scenario.

Note that "restarting" is intended only for "scenarios"; with some scenarios, it may be possible to get stuck so that it is either impossible or very annoying to win, so being offered an option to restart is more user-friendly.

Since scenarios are stored as a Maybe in the UI state, we handle the Nothing case upstream so that the Scenario passed to this function definitely exists.

scenarioToAppState :: (MonadIO m, MonadState AppState m) => ScenarioInfoPair -> ValidatedLaunchParams -> m () Source #

Modify the AppState appropriately when starting a new scenario.