# justhoadoan/oop_cardgame architecture

> Architecture diagram of the GitHub repository justhoadoan/oop_cardgame, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/justhoadoan/oop_cardgame
- Repository: https://github.com/justhoadoan/oop_cardgame

## Overview

##### Main Components and Modules
- Core Game Logic:
– Card and Deck Management: Representing classes like Card, CardSkin, and Deck.
– Game Definitions: Modules under the “src/games” package (e.g., PokerGame, BlackjackGame) and the GameType enum.
– Game Modes: “src/gamemode” includes GraphicMode and NonGraphicMode to define how the game is run.
– Game Actions: The “src/gameaction” package which defines actions (e.g., PokerAction, BlackjackAction) that are executed during gameplay.
- AI and Strategy:
– AI Strategies: The “src/ai” package contains various strategies such as MonteCarloAIStrategy, RuleBasedAIStrategy, as well as supportive classes like GameState and PokerState.
– Evaluation Tools: Including utilities like PokerHandEvaluator.
- GUI and Input:
– Graphical Interface: Classes like MainFrame and PokerView in “src/gui” represent the view layer.
– Input Processing: The “src/input” package includes classes (ActionProcessor, BlackjackActionProcessor, PokerActionProcessor, etc.) that handle user actions and translate them into game actions.
- Playable Entities:
– Represents different types of players including AI and human players, captured in “src/playable” (AI, Playable, Player, PlayerManager).
- Network / Server Functionality:
– Server and Client: The “src/server” package (Client, Server, NetworkManager) that supports networking, suggesting a multiplayer or remote play-capable architecture.
- Resources:
– Card Assets: The “resources/cards” folder with subdirectories for various card skins (animated, realistic, traditional).

##### Relationships and Interactions
– The game starts from the GUI (or optionally a non-graphic mode) which initiates a game session.
– The GUI layer sends user actions through the input processors to the central game engine.
– The Game Engine uses underlying card, deck, and game logic to manage gameplay.
– Depending on the game type (Poker or Blackjack), different game modules and corresponding game actions are invoked.
– AI strategies (from the AI module) are plugged into the game loop via the playable components if a computer-controlled player is involved.
– For networked modes, the server/client modules manage communications and synchronize game states between players.
– The resources (card images) are used by the GUI to visually represent the state of the game.

##### Architectural Patterns and Design Principles
– Object-Oriented Design: Emphasize encapsulation and separation of concerns across packages (game logic, UI, AI, networking).
– Strategy Pattern: Evidenced by the “AIStrategy” interface and its concrete implementations (Monte Carlo, rule-based).
– Possibly an MVC (Model-View-Controller) or similar pattern: The model (game state, playable objects), view (GUI components), and controller (input processors, network manager) are clearly separated.
– Modular Design: Different modules (e.g., core logic, AI, IO, server) are clearly distinct but interact via well-defined interfaces.

##### Including Relevant Technologies and Libraries
– Since this is a Java project, indicate that Java is the underlying technology.

– Begin by drawing the highest-level view with four main blocks: Game Engine, AI Component, User Interface, and Networking.
– Inside the Game Engine block, add sub-components like Card/Deck, Game Modes, and Game Actions.
– Inside the AI block, show the strategy interface and concrete strategies.
– Represent the server components separately but show how they interface with the game engine and UI for multiplayer support.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Game Engine Section
    subgraph "Game Engine"
        direction TB
        %% Card & Deck Management Subgroup
        subgraph "Card & Deck Management"
            card["Card"]:::gameEngine
            cardSkin["CardSkin"]:::gameEngine
            deck["Deck"]:::gameEngine
        end
        %% Game Definitions Subgroup
        subgraph "Game Definitions"
            pokerGame["PokerGame"]:::gameEngine
            blackjackGame["BlackjackGame"]:::gameEngine
            gameType["GameType"]:::gameEngine
        end
        %% Game Modes Subgroup
        subgraph "Game Modes"
            graphicMode["GraphicMode"]:::gameEngine
            nonGraphicMode["NonGraphicMode"]:::gameEngine
        end
        %% Game Actions Subgroup
        subgraph "Game Actions"
            pokerAction["PokerAction"]:::gameEngine
            blackjackAction["BlackjackAction"]:::gameEngine
            gameAction["GameAction"]:::gameEngine
        end
    end

    %% AI Component Section
    subgraph "AI Component"
        direction TB
        aiStrategy["AIStrategy"]:::ai
        monteCarlo["MonteCarloAIStrategy"]:::ai
        ruleBased["RuleBasedAIStrategy"]:::ai
        aiFactory["AIStrategyFactory"]:::ai
        gameState["GameState"]:::ai
        pokerState["PokerState"]:::ai
        handEvaluator["PokerHandEvaluator"]:::ai
    end

    %% User Interface Section
    subgraph "User Interface"
        direction TB
        mainFrame["MainFrame"]:::ui
        pokerView["PokerView"]:::ui
        view["View"]:::ui
        actionProcessor["ActionProcessor"]:::ui
        blackjackActionProcessor["BlackjackActionProcessor"]:::ui
        pokerActionProcessor["PokerActionProcessor"]:::ui
        actionProcessorRegistry["ActionProcessorRegistry"]:::ui
        inputHandler["InputHandler"]:::ui
    end

    %% Playable Entities Section
    subgraph "Playable Entities"
        direction TB
        aiPlayer["AI"]:::playable
        playable["Playable"]:::playable
        player["Player"]:::playable
        playerManager["PlayerManager"]:::playable
    end

    %% Networking Section
    subgraph "Networking"
        direction TB
        server["Server"]:::network
        client["Client"]:::network
        networkManager["NetworkManager"]:::network
    end

    %% Resources Section
    subgraph "Resources"
        direction TB
        animated["Animated Cards"]:::resources
        realistic["Realistic Cards"]:::resources
        traditional["Traditional Cards"]:::resources
    end

    %% Interactions and Data Flows
    %% UI flows to Game Engine
    mainFrame -->|"userInput"| inputHandler
    inputHandler -->|"routesTo"| pokerAction
    inputHandler -->|"routesTo"| blackjackAction
    actionProcessorRegistry --> actionProcessor
    actionProcessor -->|"dispatches"| gameAction

    %% Game Actions trigger Game Definitions
    pokerAction -->|"triggers"| pokerGame
    blackjackAction -->|"triggers"| blackjackGame

    %% Game Definitions depend on Card & Deck Management
    pokerGame -->|"uses"| card
    pokerGame -->|"uses"| deck
    pokerGame -->|"uses"| cardSkin
    blackjackGame -->|"uses"| deck

    %% Game Definitions reference Game Type
    pokerGame -->|"defines"| gameType
    blackjackGame -->|"defines"| gameType

    %% AI interactions
    aiStrategy -->|"implements"| monteCarlo
    aiStrategy -->|"implements"| ruleBased
    aiFactory --> aiStrategy
    gameState -->|"refines"| pokerState
    aiStrategy ---|"influences"| aiPlayer
    aiPlayer ---|"participates in"| pokerGame
    aiPlayer ---|"participates in"| blackjackGame

    %% UI and Resources
    animated ---|"assets"| mainFrame
    realistic ---|"assets"| pokerView
    traditional ---|"assets"| view

    %% UI Input Processors
    actionProcessor -->|"calls"| pokerActionProcessor
    actionProcessor -->|"calls"| blackjackActionProcessor

    %% Networking interactions
    mainFrame ---|"syncs with"| client
    inputHandler ---|"communicates via"| networkManager
    networkManager --- server
    networkManager --- client

    %% Playable Entities involvement
    pokerGame ---|"includes"| playable
    blackjackGame ---|"includes"| playable
    playable --- playerManager
    playable --- player

    %% Styling Classes
    classDef gameEngine fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef ai fill:#FAD6A5,stroke:#000,stroke-width:2px;
    classDef ui fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef playable fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef network fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef resources fill:#FFFFE0,stroke:#000,stroke-width:2px;

    %% Click Events
    click card "https://github.com/justhoadoan/oop_cardgame/blob/main/src/card/Card.java"
    click cardSkin "https://github.com/justhoadoan/oop_cardgame/blob/main/src/card/CardSkin.java"
    click deck "https://github.com/justhoadoan/oop_cardgame/blob/main/src/deck/Deck.java"
    click pokerGame "https://github.com/justhoadoan/oop_cardgame/blob/main/src/games/PokerGame.java"
    click blackjackGame "https://github.com/justhoadoan/oop_cardgame/blob/main/src/games/BlackjackGame.java"
    click gameType "https://github.com/justhoadoan/oop_cardgame/blob/main/src/games/GameType.java"
    click graphicMode "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gamemode/GraphicMode.java"
    click nonGraphicMode "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gamemode/NonGraphicMode.java"
    click pokerAction "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gameaction/PokerAction.java"
    click blackjackAction "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gameaction/BlackjackAction.java"
    click gameAction "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gameaction/GameAction.java"
    click aiStrategy "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/AIStrategy.java"
    click monteCarlo "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/MonteCarloAIStrategy.java"
    click ruleBased "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/RuleBasedAIStrategy.java"
    click aiFactory "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/AIStrategyFactory.java"
    click gameState "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/GameState.java"
    click pokerState "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/PokerState.java"
    click handEvaluator "https://github.com/justhoadoan/oop_cardgame/blob/main/src/ai/PokerHandEvaluator.java"
    click mainFrame "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gui/MainFrame.java"
    click pokerView "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gui/PokerView.java"
    click view "https://github.com/justhoadoan/oop_cardgame/blob/main/src/gui/View.java"
    click actionProcessor "https://github.com/justhoadoan/oop_cardgame/blob/main/src/input/ActionProcessor.java"
    click blackjackActionProcessor "https://github.com/justhoadoan/oop_cardgame/blob/main/src/input/BlackjackActionProcessor.java"
    click pokerActionProcessor "https://github.com/justhoadoan/oop_cardgame/blob/main/src/input/PokerActionProcessor.java"
    click actionProcessorRegistry "https://github.com/justhoadoan/oop_cardgame/blob/main/src/input/ActionProcessorRegistry.java"
    click inputHandler "https://github.com/justhoadoan/oop_cardgame/blob/main/src/input/InputHandler.java"
    click aiPlayer "https://github.com/justhoadoan/oop_cardgame/blob/main/src/playable/AI.java"
    click playable "https://github.com/justhoadoan/oop_cardgame/blob/main/src/playable/Playable.java"
    click player "https://github.com/justhoadoan/oop_cardgame/blob/main/src/playable/Player.java"
    click playerManager "https://github.com/justhoadoan/oop_cardgame/blob/main/src/playable/PlayerManager.java"
    click server "https://github.com/justhoadoan/oop_cardgame/blob/main/src/server/Server.java"
    click client "https://github.com/justhoadoan/oop_cardgame/blob/main/src/server/Client.java"
    click networkManager "https://github.com/justhoadoan/oop_cardgame/blob/main/src/server/NetworkManager.java"
    click animated "https://github.com/justhoadoan/oop_cardgame/tree/main/resources/cards/animated"
    click realistic "https://github.com/justhoadoan/oop_cardgame/tree/main/resources/cards/realistic"
    click traditional "https://github.com/justhoadoan/oop_cardgame/tree/main/resources/cards/traditional"
```
