games.risk.state_manager¶

State manager for the Risk game.

This module defines the RiskStateManager class that manages game state transitions, rule enforcement, and game progression.

Classes¶

RiskStateManager

Manages state transitions and rule enforcement for the Risk game.

Module Contents¶

class games.risk.state_manager.RiskStateManager(/, **data)¶

Bases: pydantic.BaseModel

Manages state transitions and rule enforcement for the Risk game.

This class is responsible for applying moves to the game state, enforcing game rules, and managing game progression through different phases.

Parameters:

data (Any)

state¶

The current game state.

config¶

Configuration settings for the game.

move_history¶

History of all moves made in the game.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

apply_move(move)¶

Apply a move to the current game state.

Parameters:

move (haive.games.risk.models.RiskMove) – The move to apply.

Returns:

The updated game state after applying the move.

Raises:

ValueError – If the move is invalid or violates game rules.

Return type:

haive.games.risk.state.RiskState

classmethod initialize(player_names, config=None)¶

Initialize a new Risk game state manager.

Parameters:
Returns:

A new RiskStateManager with initialized state.

Raises:

ValueError – If the number of players is invalid.

Return type:

RiskStateManager