Game Module
The Game module serves as the central coordinator of the Property Tycoon game, managing the overall game flow, state transitions, and integration of various subsystems. It initializes all necessary components, processes player actions through the game logic system, and ensures proper synchronization between the user interface, board representation, and game rules.
Core Responsibilities:
Initialization: Sets up the Pygame screen, loads assets (backgrounds, board, dice images), initializes fonts, sound, players, board, game logic, card decks, and UI elements (buttons).
State Management: Controls the main game state (ROLL, BUY, AUCTION, DEVELOPMENT, JAIL_CHOICE, CARD_DISPLAY, POPUP, GAME_OVER, etc.) and transitions between them based on game events.
Game Loop Coordination: While the main loop resides in Main.py, the Game object holds the state and data used by GameRenderer, GameEventHandler, and GameActions within that loop.
Player Management: Holds the list of Player objects, tracks the current player, and synchronizes player data (position, money, status) between the UI representation (Player class) and the core logic (GameLogic).
Rule Enforcement & Logic Delegation: Delegates core game rule processing (rent calculation, property transactions, card effects, bankruptcy) to the GameLogic instance.
Event Handling (Indirect): Holds data necessary for GameEventHandler to process user input (clicks, keys) relevant to the current game state (e.g., clicking buy/pass buttons, handling auction input).
Rendering Coordination (Indirect): Holds data necessary for GameRenderer to draw the current game state (board, players, UI elements, popups, dice).
Action Execution (Indirect): Holds data and state for GameActions to execute complex game actions (rolling dice, handling turns, buying/auctioning properties, managing development).
UI Display: Manages the display of popups, card information, notifications, and AI emotion indicators.
Game Mode & Timing: Manages different game modes (Full, Abridged) and enforces time limits in Abridged mode, including checking for game end conditions.
AI Integration: Initializes AI controllers within Player objects (via Player.__init__) and coordinates AI turn execution via check_and_trigger_ai_turn and GameActions.
- class src.Game.Game(players, game_mode='full', time_limit=None, ai_difficulty='easy')[source]
Bases:
object
Detailed Design
Game Class Diagram
Game State Diagram
Game Initialization Sequence
Dice Roll and Landing Sequence
Card Draw and Action Sequence
Time Limit Check Sequence
Turn End and AI Trigger Sequence
Exit Confirmation Sequence
Player Data Synchronization Sequence
AI Mood Update Sequence