Game Event Handler Module
This module defines the GameEventHandler class, responsible for capturing and processing all user inputs (keyboard, mouse clicks, mouse movement) during the main game loop. It acts as a central dispatcher, interpreting events based on the current game state and delegating actions to other game components like GameActions, GameLogic, DevelopmentManager, and the main Game object.
High-Level Design
Dependency Diagram
Visualizes the primary dependencies of the GameEventHandler.
GameEventHandler Dependencies
Simplified State Handling
Shows the main game states the GameEventHandler explicitly checks and how input handling differs.
Simplified State Handling in GameEventHandler
Detailed Design
Class Diagram
GameEventHandler Class Diagram
Activity Diagrams
Overall Click Handling Flow (`handle_click`)
Provides a high-level view of the decision-making process within handle_click.
Activity Diagram: handle_click Logic Flow
Sequence Diagrams
Main Input Loop Dispatch
Sequence Diagram: Input Handling Dispatch
Click Handling (ROLL State)
Sequence Diagram - Handle Click (Normal Turn)
Click Handling (BUY State)
Sequence Diagram: Click Handling (BUY State)
Auction Click Handling
Sequence Diagram: Auction Click Handling
Key Handling (ROLL State)
Illustrates the primary key presses handled when the game state is ROLL.
Sequence Diagram: Key Handling (ROLL State)
Key Handling (AUCTION State)
Sequence Diagram - Handle Auction Input
Key Methods Overview
handle_input(): The main event loop processor. Iterates through Pygame events and calls specific handlers (handle_click, handle_motion, handle_key) or handles QUIT events directly. Returns game over status if detected.
handle_click(pos): Processes left mouse clicks. Behavior depends heavily on game.state (ROLL, BUY, AUCTION), game.development_mode, game.show_popup, game.show_card, and which UI element (buttons, AI mood UI) is clicked. Delegates actions to GameActions, DevelopmentManager, or handle_auction_click.
handle_motion(pos): Processes mouse movement, primarily to update hover states for buttons and AI mood UI elements.
handle_key(event): Processes keyboard presses. Behavior depends on game.state, active popups/cards, and development mode. Handles rolling dice, buying/passing, auction input, quitting, pausing, camera movement, and development actions. Delegates actions to GameActions, DevelopmentManager, or handle_auction_input.
handle_auction_input(event): Specifically handles keyboard input during an auction (numeric keys for bid amount, Enter to submit, Esc to pass, Backspace). Calls _process_auction_bid.
_process_auction_bid(current_bidder): Validates and submits the entered bid amount to GameLogic.
handle_auction_click(pos): Specifically handles mouse clicks during an auction (Bid button, Pass button). Calls _process_auction_bid or GameLogic.process_auction_pass. Checks for auction completion.