haive.games.risk.state_manager ============================== .. py:module:: haive.games.risk.state_manager .. autoapi-nested-parse:: State manager for the Risk game. This module defines the RiskStateManager class that manages game state transitions, rule enforcement, and game progression. Classes ------- .. autoapisummary:: haive.games.risk.state_manager.RiskStateManager Module Contents --------------- .. py:class:: RiskStateManager(/, **data) Bases: :py:obj:`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. .. attribute:: state The current game state. .. attribute:: config Configuration settings for the game. .. attribute:: 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. .. py:method:: apply_move(move) Apply a move to the current game state. :param move: The move to apply. :returns: The updated game state after applying the move. :raises ValueError: If the move is invalid or violates game rules. .. py:method:: initialize(player_names, config = None) :classmethod: Initialize a new Risk game state manager. :param player_names: List of player names. :param config: Optional configuration for the game. If not provided, classic Risk rules will be used. :returns: A new RiskStateManager with initialized state. :raises ValueError: If the number of players is invalid.