games.monopoly.utils¶
Monopoly game utilities and board logic.
- This module provides utility functions for the monopoly game, including:
Board setup and property definitions
Game logic calculations
Card definitions and handling
Rent calculations
Functions¶
|
Calculate rent for a property. |
|
Check if two properties can be traded. |
|
Check if the game should end. |
Create the initial board with all properties. |
|
|
Create initial players. |
|
Calculate cost to build houses or hotel. |
|
Get all property names for a color group. |
|
Get property information at a board position. |
|
Handle special board positions like GO, Jail, etc. |
|
Move a player based on dice roll. |
Roll two dice. |
|
Shuffle and return chance and community chest cards. |
Module Contents¶
- games.monopoly.utils.calculate_rent(property, state, dice_roll=None)¶
Calculate rent for a property.
- games.monopoly.utils.can_trade_properties(prop1, prop2, state)¶
Check if two properties can be traded.
- Parameters:
prop1 (haive.games.monopoly.models.Property)
prop2 (haive.games.monopoly.models.Property)
state (haive.games.monopoly.state.MonopolyState)
- Return type:
- games.monopoly.utils.check_game_end(state)¶
Check if the game should end.
- games.monopoly.utils.create_board()¶
Create the initial board with all properties.
- games.monopoly.utils.create_players(player_names)¶
Create initial players.
- games.monopoly.utils.get_building_cost(property, buildings, is_hotel=False)¶
Calculate cost to build houses or hotel.
- games.monopoly.utils.get_properties_by_color(color)¶
Get all property names for a color group.
- games.monopoly.utils.get_property_at_position(position)¶
Get property information at a board position.
- games.monopoly.utils.handle_special_position(position, player, state)¶
Handle special board positions like GO, Jail, etc.
- games.monopoly.utils.move_player(player, dice_roll)¶
Move a player based on dice roll.
- games.monopoly.utils.roll_dice()¶
Roll two dice.
- Return type:
haive.games.monopoly.models.DiceRoll