Game Logic Module
This module implements the core rules and mechanics of the Property Tycoon game. It manages player turns, property transactions, rent calculation, card draws, auctions, and game state progression according to the established rules. The central class, GameLogic , orchestrates these elements.
High-Level Design
Use Case Diagram
—————————————————~
Illustrates the main actions managed or initiated by the Game Logic.
Game Logic Use Cases
Dependency Diagram
—————————————————~~~
Shows the primary dependencies of the Game Logic module.
Game Logic Dependencies
Class and Data Structures
GameLogic Class
The core class managing the game state and rules.
GameLogic Class Diagram
Simplified Game State
Shows the main states the game can be in, focusing on turn progression and auctions.
Simplified Game State Diagram
Activity Diagrams
—————————————————~~
Play Turn Flow
Illustrates the sequence of actions within a single player’s turn.
Activity Diagram: Play Turn
Handle Landed Space Flow
Details the logic when a player lands on a specific board space.
Activity Diagram: Handle Landed Space
Auction Flow (Simplified)
Outlines the basic steps of the property auction process using the current_auction state.
Activity Diagram: Auction Process
Sequence Diagrams
—————————————————~~
Player Buys Property
Sequence Diagram: Player Buys Property
Rent Payment
Sequence Diagram: Rent Payment
Card Draw
Sequence Diagram: Card Draw
Auction Bid Process
Sequence Diagram: Auction Bid
Key Classes/Data Overview
GameLogic : The main orchestrator class holding game state and rules logic.
Player Dictionary : Represents a player’s state (money, position, properties, AI status, jail status, etc.).
Property Dictionary : Represents a property’s state (owner, houses, mortgage status, rent levels, etc.), keyed by board position.
Card Dictionary : Represents a Pot Luck or Opportunity Knocks card, containing its text and an action (lambda function) to execute.
Auction Dictionary (`current_auction`) : Holds the state of an ongoing auction (property, bidders, current bid, etc.).
API Documentation
class src.Game_Logic. GameLogic [source]
Bases: object
BANK_LIMIT = 50000
GAME_TOKENS = ['boot', 'smartphone', 'ship', 'hatstand', 'cat', 'iron']
MAX_HOTELS_PER_PROPERTY = 1
MAX_HOUSES_PER_PROPERTY = 4
add_message ( message ) [source]
add_player ( player ) [source]
advance_to_next_player ( ) [source]
auction ( property_data ) [source]
auction_property ( position ) [source]
build_hotel ( property_data , player ) [source]
build_house ( property_data , player ) [source]
buy_property ( player ) [source]
buy_property_after_auction ( player , property_data ) [source]
calculate_house_difference ( color_group_properties ) [source]
calculate_repair_cost ( player , house_cost , hotel_cost ) [source]
calculate_space_rent ( space , player ) [source]
can_build_hotel ( property_data , player ) [source]
can_build_house ( property_data , player ) [source]
check_auction_end ( ) [source]
check_game_over ( ) [source]
check_property_group_completion ( player_name ) [source]
game_start ( ) [source]
get_ai_auction_bid ( player , property_data , current_bid ) [source]
get_ai_bid ( player , current_minimum , property_data ) [source]
get_human_bid ( player , current_minimum , property_data ) [source]
get_winner ( ) [source]
handle_ai_bankruptcy_prevention ( player , amount_needed ) [source]
handle_ai_turn ( player ) [source]
handle_bankruptcy ( player ) [source]
handle_birthday_collection ( birthday_player ) [source]
handle_buy_decision ( player , decision ) [source]
handle_card_draw ( player , card_type ) [source]
handle_jail ( player ) [source]
handle_payment_to_bank ( player , amount , to_free_parking = False ) [source]
handle_rent_payment ( landing_player , property_data ) [source]
handle_repair_assessment ( player , house_cost , hotel_cost ) [source]
handle_space ( player ) [source]
is_game_over ( ) [source]
mortgage_property ( property_data , player ) [source]
move_to_next_bidder ( ) [source]
pay_from_bank ( player , amount ) [source]
pay_to_bank ( player , amount ) [source]
placeBids ( player_list , property_data ) [source]
play_turn ( ) [source]
process_ai_property_purchase ( player , property_data ) [source]
process_auction_bid ( player , bid_amount ) [source]
process_auction_pass ( player ) [source]
remove_player ( player_name , voluntary = False ) [source]
sell_hotel ( property_data , player ) [source]
sell_house ( property_data , player ) [source]
try_leave_jail ( player , dice1 , dice2 ) [source]
unmortgage_property ( property_data , player ) [source]
validate_bank_transaction ( amount ) [source]