ritchie/engine
Driver of the main game logic.
Types
Driver of the main game logic. This has the following main functions:
register_action: GivenState, is someActionvalid?register_reaction: GivenStateand a validAction, is someReactionvalid?step: GivenState, a validAction, and any validReactions, proceed to the next state.
pub opaque type Engine
Result of advancing one turn.
pub type StepOutcome {
StepOutcome(
engine: Engine,
game_step: history.GameStep,
round_end: option.Option(boundary.RoundEnd),
)
}
Constructors
-
StepOutcome( engine: Engine, game_step: history.GameStep, round_end: option.Option(boundary.RoundEnd), )
Values
pub fn begin_round(
engine: Engine,
begin: boundary.RoundBegin,
) -> Engine
Starts a new round, resetting any pending turn and history.
pub fn current_state(
engine: Engine,
) -> option.Option(state.State)
pub fn jump_to_state(
engine: Engine,
current: state.State,
) -> Result(Engine, error.EngineError)
Replaces the current round state, e.g. for replay or testing.
pub fn pending_action(
engine: Engine,
) -> option.Option(action.Action)
pub fn register_action(
engine: Engine,
act: action.Action,
) -> Result(Engine, error.EngineError)
Validates and stores an action for the current turn. Any previously registered reactions are discarded.
pub fn register_reaction(
engine: Engine,
reactor: player.Player,
reaction: reaction.Reaction,
) -> Result(Engine, error.EngineError)
Validates and stores one player’s reaction to the pending action.
pub fn round_begin(
engine: Engine,
) -> option.Option(boundary.RoundBegin)
pub fn round_end(
engine: Engine,
) -> option.Option(boundary.RoundEnd)
pub fn round_history(
engine: Engine,
) -> option.Option(history.RoundHistory)
pub fn step(
engine: Engine,
) -> Result(StepOutcome, error.EngineError)
Resolves the pending action and reactions, advancing the engine by one turn or ending the round.