ritchie/engine/step

Turn resolution:

Types

pub type StepResult {
  StepResult(
    state: state.State,
    game_step: history.GameStep,
    round_end: option.Option(boundary.RoundEnd),
  )
}

Constructors

Values

pub fn next_abort(
  begin: boundary.RoundBegin,
  current: state.State,
  act: action.Action,
  reason: action_result.AbortReason,
) -> boundary.RoundEnd

Computes the end-of-round result for an abort.

pub fn next_agari(
  begin: boundary.RoundBegin,
  current: state.State,
  act: action.Action,
  kind: agari.AgariKind,
  tsumo_inputs: List(agari.AgariInput),
  validated_reactions: List(
    option.Option(reaction_check.ValidatedReaction),
  ),
  rons: List(player.Player),
) -> boundary.RoundEnd

Computes the end-of-round result for a win.

pub fn next_normal(
  begin: boundary.RoundBegin,
  current: state.State,
  act: action.Action,
  result: action_result.ActionResult,
  action_meld: option.Option(meld.Meld),
  reaction_meld: option.Option(meld.Meld),
) -> state.StateCore

Computes the next core state for a turn that does not end the round.

pub fn next_round_id_or_game_end(
  rules: rules.Ruleset,
  points: List(Int),
  button: player.Player,
  renchan: Bool,
  next_round_id: boundary.RoundId,
) -> option.Option(boundary.RoundId)

Determines the next round, or None if the game has ended.

pub fn step(
  begin: boundary.RoundBegin,
  current: state.State,
  act: action.Action,
  validated_action: action_check.ValidatedAction,
  validated_reactions: List(
    option.Option(reaction_check.ValidatedReaction),
  ),
  resolved: reaction_resolve.ResolvedReaction,
) -> StepResult

Resolves one turn. For a normal turn, returns the evolved state, for a win or abort, returns the round end.

✨ Search Document