haive.games.risk.state ====================== .. py:module:: haive.games.risk.state .. autoapi-nested-parse:: State model for the Risk game. This module defines the state model for the Risk game, tracking the game board, player information, and game status. Classes ------- .. autoapisummary:: haive.games.risk.state.RiskState Module Contents --------------- .. py:class:: RiskState(/, **data) Bases: :py:obj:`pydantic.BaseModel` State for the Risk game. .. attribute:: territories Dictionary of territory objects, keyed by name. .. attribute:: continents Dictionary of continent objects, keyed by name. .. attribute:: players Dictionary of player objects, keyed by name. .. attribute:: current_player Name of the player whose turn it is. .. attribute:: phase Current phase of the game. .. attribute:: game_status Current status of the game. .. attribute:: turn_number Current turn number. .. attribute:: deck List of cards in the deck. .. attribute:: next_card_set_value Value of the next set of cards to be traded in. .. attribute:: move_history List of moves that have been made. .. attribute:: player_analyses Dictionary of player analyses, keyed by player name. .. attribute:: attacker_captured_territory Whether the attacker captured a territory this turn. 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:: get_controlled_continents(player_name) Get all continents controlled by a player. :param player_name: Name of the player. :returns: List of continents controlled by the player. .. py:method:: get_controlled_territories(player_name) Get all territories controlled by a player. :param player_name: Name of the player. :returns: List of territories controlled by the player. .. py:method:: get_winner() Get the winner of the game. :returns: Name of the winner, or None if the game is not over. .. py:method:: initialize(player_names) :classmethod: Initialize a new Risk game state. :param player_names: List of player names. :returns: A new RiskState object with default values. .. py:method:: is_game_over() Check if the game is over. :returns: True if the game is over, False otherwise.