display.simulation documentation - wladekpal/The-Lazy-Snek GitHub Wiki
SimulationState
Enum type class describing all possible level simulation states. Inherits from enum.Enum
.
Variants
INACTIVE
- level is displayed but no simulation is currently in progress.RUNNING
- simulation is in progress and next simulation steps will be displayed if simulation state isn't changed.PAUSED
- simulation is in progress, but paused. Next steps won't be displayed until simulation state isn't changed toRUNNING
WIN
- simulation has ended, resulting in succesful level solve. Can't be resumed, but can be run again.LOSS
- simulation has ended, resulting in unsuccesful level solve. Can't be resumed, but can be run again.
Simulation
Class representing and allowing to manage simulation of level with current board state, displayed on screen.
Properties
- state - current simulation state of type
gameplay.simulation.SimulationState
. - levelView -
gameplay.level_view.LevelView
type screen that current level that is managed by the simulation is displayed on.
Simulation(level, levelView)
Sets properties values corresponding to arguments` names.
play()
Sets current simulation state to RUNNING
, if simulation was paused. Otherwise, if simulation hasn't ended, resumes it.
restart()
Restarts simulation if it's currently running or has ended, but wasn't restarted yet.
cancel()
Cancels simulation if it's currently running. If simulation has ended, restarts it.
get_state()
Returns current simulation state, which is gameplay.simulation.SimulationState
type.
tick()
Process simulation next tick request. Proceeds to next simulation step only if simulation is active. After each step checks if simulation has ended. If so, sets current state to WIN
or LOSS
.