games.risk.state¶

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¶

RiskState

State for the Risk game.

Module Contents¶

class games.risk.state.RiskState(/, **data)¶

Bases: pydantic.BaseModel

State for the Risk game.

Parameters:

data (Any)

territories¶

Dictionary of territory objects, keyed by name.

continents¶

Dictionary of continent objects, keyed by name.

players¶

Dictionary of player objects, keyed by name.

current_player¶

Name of the player whose turn it is.

phase¶

Current phase of the game.

game_status¶

Current status of the game.

turn_number¶

Current turn number.

deck¶

List of cards in the deck.

next_card_set_value¶

Value of the next set of cards to be traded in.

move_history¶

List of moves that have been made.

player_analyses¶

Dictionary of player analyses, keyed by player name.

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.

get_controlled_continents(player_name)¶

Get all continents controlled by a player.

Parameters:

player_name (str) – Name of the player.

Returns:

List of continents controlled by the player.

Return type:

list[haive.games.risk.models.Continent]

get_controlled_territories(player_name)¶

Get all territories controlled by a player.

Parameters:

player_name (str) – Name of the player.

Returns:

List of territories controlled by the player.

Return type:

list[haive.games.risk.models.Territory]

get_winner()¶

Get the winner of the game.

Returns:

Name of the winner, or None if the game is not over.

Return type:

str | None

classmethod initialize(player_names)¶

Initialize a new Risk game state.

Parameters:

player_names (list[str]) – List of player names.

Returns:

A new RiskState object with default values.

Return type:

RiskState

is_game_over()¶

Check if the game is over.

Returns:

True if the game is over, False otherwise.

Return type:

bool