Cards Module
This module defines the structure and behavior of the Pot Luck and Opportunity Knocks cards used in the game. It includes classes for individual cards and the decks that manage them, including drawing, discarding, and reshuffling.
- class src.Cards.CardType(*values)[source]
Bases:
Enum
- OPPORTUNITY_KNOCKS = 'opportunity knocks'
- POT_LUCK = 'pot luck'
High-Level Design
Use Case Diagram
Shows the basic interaction with the card system from a game perspective.
Card System Use Cases
Detailed Design
Class Diagram
Shows the classes involved in the card system and their relationships.
Cards Class Structure
State Diagram (CardDeck)
Illustrates the different states a CardDeck can be in regarding its draw and discard piles.
CardDeck State Diagram
Sequence Diagrams
Deck Initialization
Shows the process of creating and shuffling a new deck.
Sequence Diagram: Deck Initialization
Drawing a Card
Illustrates the logic when a card is drawn, including handling an empty draw pile.
Sequence Diagram: Card Drawing Sequence
Returning a “Get Out of Jail Free” Card
Shows the special handling for returning this specific type of card.
Sequence Diagram: Returning Jail Free Card
Key Classes Overview
CardType: An Enum defining the two types of decks: POT_LUCK and OPPORTUNITY_KNOCKS.
Card: Represents a single card with its display text, associated action (which likely corresponds to a function or identifier in the game logic), and card_type. It also determines if the card requires_input or is is_special based on keywords in its text.
CardDeck: Manages a collection of Card objects for a specific card_type. It handles initialization (reading from external data and shuffling), drawing cards (including reshuffling the discard pile when the draw pile is empty), returning used cards to the discard pile, and specifically handling the return of “Get Out of Jail Free” cards.