Player Module
This module defines the Player class, representing a participant in the game. It stores player-specific data like name, money, position, owned properties, and status (e.g., in jail, bankrupt). It also handles player movement animation, visual representation, and interactions related to property ownership and finances. For AI players, it holds a reference to an AI controller.
The Player module provides:
Representation of a player’s state (money, properties, position, jail status, etc.).
Methods for financial transactions (pay, receive, can_afford).
Methods for property management (buy_property, add_property, remove_property, asset calculation).
Methods for handling jail status (add_jail_card, use_jail_card, handle_jail_turn).
Logic for player movement on the board, including animation (move, start_move, update_animation, generate_move_path).
Visual drawing logic (draw_player, load_player_image, create_fallback_token).
Handling of game-ending states like bankruptcy and voluntary exit (handle_bankruptcy, handle_voluntary_exit).
Integration with AI controllers for AI players.
- class src.Player.Player(name, player_number=1, is_ai=False, ai_difficulty='easy')[source]
Bases:
object
Detailed Design
Player Class Diagram
Player Class Diagram
Player State Diagram
Player State Diagram
Player Initialization
Sequence Diagram: Player Initialization
Player Movement
Sequence Diagram: Player Movement
Property Purchase
Sequence Diagram: Buying a Property
Jail Turn Handling
Sequence Diagram: Jail Turn Handling
Asset Calculation
Sequence Diagram: Total Asset Calculation
Player Drawing
Sequence Diagram: Player Drawing
Bankruptcy Handling
Sequence Diagram: Handling Bankruptcy
AI Player Turn
Sequence Diagram: AI Player Turn (Conceptual)