mundane.engine.rules¶
The one door: apply_action(state, action) validates a move, then transitions.
Every state change in the game goes through here. Each branch runs its _require preconditions
first (which raise IllegalAction on a bad move, mutating nothing) and only then mutates.
The function returns the state so it composes as a reducer:
final = reduce(partial(apply_action, cards=pool), actions, initial).
Functions¶
|
Reject the action with |
|
Validate |
|
Put a card on the stack with a fresh id, then hand priority back to the active player. |
After anything goes on the stack, the active player gets priority and the pass count resets. |
|
|
Resolve the top stack item (LIFO): permanents hit the board, others fire then go to discard. |
|
Move to the next phase, or end the turn after the last phase. |
|
Hand the turn to the next player and run Wake Up housekeeping (refresh Time, draw). |
|
Set the winner if any player's Composure has dropped to 0. |
Module Contents¶
- mundane.engine.rules._require(condition: bool, message: str) None[source]¶
Reject the action with
IllegalAction(message)whenconditionis false.
- mundane.engine.rules.apply_action(state: mundane.engine.state.GameState, action: mundane.engine.actions.Action, cards: dict[str, mundane.engine.state.Card]) mundane.engine.state.GameState[source]¶
Validate
actionagainststate, then transition. Returnsstate.
- mundane.engine.rules._push_stack(state: mundane.engine.state.GameState, card_id: str, controller: int, target_id: int | None = None) None[source]¶
Put a card on the stack with a fresh id, then hand priority back to the active player.
- mundane.engine.rules._grant_priority_after_stack_change(state: mundane.engine.state.GameState) None[source]¶
After anything goes on the stack, the active player gets priority and the pass count resets.
- mundane.engine.rules._resolve_top(state: mundane.engine.state.GameState, cards: dict[str, mundane.engine.state.Card]) None[source]¶
Resolve the top stack item (LIFO): permanents hit the board, others fire then go to discard.
- mundane.engine.rules._advance_phase(state: mundane.engine.state.GameState) None[source]¶
Move to the next phase, or end the turn after the last phase.
- mundane.engine.rules._end_turn(state: mundane.engine.state.GameState) None[source]¶
Hand the turn to the next player and run Wake Up housekeeping (refresh Time, draw).
- mundane.engine.rules._check_win(state: mundane.engine.state.GameState) None[source]¶
Set the winner if any player’s Composure has dropped to 0.