# andresit1524/beast_card_clash architecture

> Architecture diagram of the GitHub repository andresit1524/beast_card_clash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andresit1524/beast_card_clash
- Repository: https://github.com/andresit1524/beast_card_clash

## Overview

1. **Project shape**
   - This is a **Godot** game repository centered on scene-based gameplay, with most runtime logic in **GDScript** and a few example scripts in **C#**.
   - The repo is split cleanly into reusable engine-like addons, global singleton services, and game-specific content under `assets/`.

2. **Core runtime boundaries**
   - `addons/` contains reusable systems and editor extensions.
   - `autoload/` contains cross-scene singleton services that hold persistent state and shared managers.
   - `assets/` contains the actual game scenes, gameplay logic, resources, UI, and content.
   - `tests/` and `.docs/` provide validation/demo material and design documentation, not runtime gameplay.

3. **Global services and persistence**
   - The main architectural backbone is in `autoload/`: `scene_manager`, `music_manager`, `flags_manager`, and `player_stats`.
   - These services provide **scene transitions**, **background music control**, **game progression flags**, and **player state persistence** across different scenes.
   - This makes the game flow stateful without coupling individual scenes to each other directly.

4. **Battle system as a self-contained subsystem**
   - The battle feature lives under `assets/battle/` and is organized as a dedicated subsystem with its own scene (`battle.tscn`), manager, UI, world, states, and data resources.
   - `battle_manager.gd` is the orchestration point that bridges battle state, UI, and world presentation.

5. **Battle flow and state machine**
   - Battle logic is explicitly modeled as a state machine in `assets/battle/states/`.
   - The concrete states are `start`, `referee`, `turn`, `loop`, and `end`, all derived from `battle_state.gd`.
   - The state progression is the main control-flow path for a duel: initialize, arbitrate, resolve turns, repeat, and finish.

6. **Battle data and gameplay model**
   - `assets/battle/resources/battle_data.gd` indicates the battle system is driven by resource data rather than hardcoded scene logic.
   - This suggests the battle manager/state machine consumes structured battle configuration and outcome data, keeping logic and content separated.

7. **Battle presentation split: UI vs world**
   - Presentation is divided into `assets/battle/ui/` and `assets/battle/world/`.
   - The UI layer includes panels and interaction surfaces like hands, player panels, podium/end UI.
   - The world layer contains 3D/scene elements such as dice, rocks, players, and the battle world scene, implying a layered battle presentation where logic is separate from rendered combat objects.

8. **Card, character, and team content**
   - `assets/cards/`, `assets/elements/`, `assets/teams/`, and `assets/character_selector/` define the game’s collectible/combat identity.
   - Cards and elemental lists appear to be resource-driven, while character/team selectors handle pre-battle setup and cosmetic or faction choices.
   - This content likely feeds both the battle subsystem and the progression/menu flow.

9. **Narrative and dialogue infrastructure**
   - The embedded `addons/dialogue_manager/` is a substantial reusable subsystem that includes a compiler, runtime processors, editor UI, import/export plugins, and localization files.
   - Game dialogue content is stored under `assets/dialogues/` and likely flows through this addon at runtime.
   - This is a major architectural boundary: narrative content is authored as dialogue resources and compiled/processed by the addon instead of being embedded in gameplay scripts.

10. **Main menu, tutorial, and shell scenes**
   - `assets/ui/start_menu/`, `assets/ui/tutorial/`, and `assets/ui/credits/` represent the non-battle shell of the game.
   - Common UI elements such as `back_button` and `upper_bar` support navigation across these scenes.
   - These screens likely act as entry points into character selection, dialogue, and battle scenes via the global scene manager.

11. **Rendering, audio, and visual style**
   - The project relies on Godot assets for **music**, **fonts**, **themes**, and **shaders**.
   - Custom shaders (`blur`, `highlight`, `outline`) and UI themes indicate a strong presentation layer, while `music_manager` centralizes soundtrack behavior.
   - `addons/vector_display_2d/` is another reusable visual addon, likely used for special 2D rendering or debug/visualization tooling.

12. **Tooling, editor integration, and extensibility**
   - Several addons are editor-facing: `inspector_plugin`, `import_plugin`, `export_plugin`, and custom controls under `components/` and `views/`.
   - This means the project is not only a game but also an authoring environment for dialogue and content creation.
   - The architecture therefore includes both runtime systems and in-editor tooling as first-class parts of the repository.

13. **Documentation and verification**
   - `.docs/` contains design notes such as battle state-machine and architecture documents, which are useful for understanding intended control flow.
   - `tests/3d_tests.tscn` and `tests/card_battle_demo.py` provide smoke-test/demo style validation around rendering or combat behavior.
   - These are supporting artifacts for development, not separate production subsystems.

Main entry points: [`assets/battle/battle_manager.gd`](https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/battle_manager.gd) (Battle Manager), [`autoload/scene_manager.gd`](https://github.com/andresit1524/beast_card_clash/blob/main/autoload/scene_manager.gd) (Scene Manager), [`assets/battle/battle.tscn`](https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/battle.tscn) (Battle Scene), [`assets/character_selector`](https://github.com/andresit1524/beast_card_clash/tree/main/assets/character_selector) (Character Select)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_addons["Addons"]
  node_dialogue_manager["Dialogue Manager<br/>addon"]
  node_state_machine["State Machine<br/>addon"]
  node_vector_display_2d["Vector Display<br/>addon"]
end

subgraph group_autoload["Autoload"]
  node_scene_manager(("Scene Manager<br/>autoload service<br/>[scene_manager.gd]"))
  node_music_manager(("Music Manager<br/>autoload service<br/>[music_manager.gd]"))
  node_flags_manager(("Flags Manager<br/>autoload service<br/>[flags_manager.gd]"))
  node_player_stats(("Player Stats<br/>autoload service<br/>[player_stats.gd]"))
end

subgraph group_assets["Game Assets"]
  node_battle_manager["Battle Manager<br/>orchestrator<br/>[battle_manager.gd]"]
  node_battle_states["Battle States<br/>state set"]
  node_battle_ui["Battle UI<br/>presentation"]
  node_battle_world["Battle World<br/>scene layer"]
  node_battle_data["Battle Data<br/>resource schema<br/>[battle_data.gd]"]
  node_battle_scene["Battle Scene<br/>[battle.tscn]"]
  node_cards["Cards<br/>content"]
  node_elements["Elements<br/>content"]
  node_teams["Teams<br/>content"]
  node_character_selector["Character Select<br/>menu flow"]
  node_start_menu["Start Menu<br/>menu scene"]
  node_tutorial_ui["Tutorial<br/>ui scene"]
  node_credits_ui["Credits<br/>ui scene"]
  node_dialogues["Dialogue Content<br/>story assets"]
end

subgraph group_support["Support"]
  node_docs["Design Docs<br/>documentation<br/>[.docs]"]
  node_tests["Tests & Demo<br/>validation"]
end

node_scene_manager -->|"opens"| node_start_menu
node_scene_manager -->|"loads"| node_battle_scene
node_scene_manager -->|"loads"| node_tutorial_ui
node_scene_manager -->|"loads"| node_credits_ui
node_music_manager -->|"menu music"| node_start_menu
node_music_manager -->|"battle music"| node_battle_scene
node_flags_manager -->|"progression"| node_character_selector
node_player_stats -->|"load state"| node_character_selector
node_start_menu -->|"navigate"| node_scene_manager
node_character_selector -->|"start battle"| node_battle_scene
node_battle_scene -->|"hosts"| node_battle_manager
node_battle_manager -->|"drives"| node_battle_states
node_battle_manager -->|"updates"| node_battle_ui
node_battle_manager -->|"controls"| node_battle_world
node_battle_manager -->|"consumes"| node_battle_data
node_battle_states -->|"reads"| node_battle_data
node_battle_ui -->|"shows cards"| node_cards
node_battle_ui -->|"reflects"| node_player_stats
node_battle_world -->|"uses visuals"| node_vector_display_2d
node_dialogue_manager -->|"runs"| node_dialogues
node_dialogue_manager -->|"narrates"| node_tutorial_ui
node_dialogue_manager -->|"presents text"| node_credits_ui
node_docs -->|"describes"| node_battle_states
node_tests -->|"exercises"| node_battle_manager
node_cards -->|"feeds"| node_battle_data
node_elements -->|"supports"| node_cards
node_teams -->|"drives choice"| node_character_selector

click node_dialogue_manager "https://github.com/andresit1524/beast_card_clash/tree/main/addons/dialogue_manager"
click node_state_machine "https://github.com/andresit1524/beast_card_clash/tree/main/addons/state_machine"
click node_vector_display_2d "https://github.com/andresit1524/beast_card_clash/tree/main/addons/vector_display_2d"
click node_scene_manager "https://github.com/andresit1524/beast_card_clash/blob/main/autoload/scene_manager.gd"
click node_music_manager "https://github.com/andresit1524/beast_card_clash/blob/main/autoload/music_manager.gd"
click node_flags_manager "https://github.com/andresit1524/beast_card_clash/blob/main/autoload/flags_manager.gd"
click node_player_stats "https://github.com/andresit1524/beast_card_clash/blob/main/autoload/player_stats.gd"
click node_battle_manager "https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/battle_manager.gd"
click node_battle_states "https://github.com/andresit1524/beast_card_clash/tree/main/assets/battle/states"
click node_battle_ui "https://github.com/andresit1524/beast_card_clash/tree/main/assets/battle/ui"
click node_battle_world "https://github.com/andresit1524/beast_card_clash/tree/main/assets/battle/world"
click node_battle_data "https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/resources/battle_data.gd"
click node_battle_scene "https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/battle.tscn"
click node_cards "https://github.com/andresit1524/beast_card_clash/tree/main/assets/cards"
click node_elements "https://github.com/andresit1524/beast_card_clash/tree/main/assets/elements"
click node_teams "https://github.com/andresit1524/beast_card_clash/tree/main/assets/teams"
click node_character_selector "https://github.com/andresit1524/beast_card_clash/tree/main/assets/character_selector"
click node_start_menu "https://github.com/andresit1524/beast_card_clash/tree/main/assets/ui/start_menu"
click node_tutorial_ui "https://github.com/andresit1524/beast_card_clash/tree/main/assets/ui/tutorial"
click node_credits_ui "https://github.com/andresit1524/beast_card_clash/tree/main/assets/ui/credits"
click node_dialogues "https://github.com/andresit1524/beast_card_clash/tree/main/assets/dialogues"
click node_docs "https://github.com/andresit1524/beast_card_clash/blob/main/.docs"
click node_tests "https://github.com/andresit1524/beast_card_clash/tree/main/tests"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dialogue_manager,node_state_machine,node_vector_display_2d toneBlue
class node_scene_manager,node_music_manager,node_flags_manager,node_player_stats toneAmber
class node_battle_manager,node_battle_states,node_battle_ui,node_battle_world,node_battle_data,node_battle_scene,node_cards,node_elements,node_teams,node_character_selector,node_start_menu,node_tutorial_ui,node_credits_ui,node_dialogues toneMint
class node_docs,node_tests toneRose
```

## Components

### Addons

Reusable engine-like subsystems and editor tooling

- [Dialogue Manager](https://github.com/andresit1524/beast_card_clash/tree/main/addons/dialogue_manager): addon · Compiler, runtime, editor plugins, and localization for authored dialogue · `addons/dialogue_manager`
- [State Machine](https://github.com/andresit1524/beast_card_clash/tree/main/addons/state_machine): addon · Generic base state and state machine framework · `addons/state_machine`
- [Vector Display](https://github.com/andresit1524/beast_card_clash/tree/main/addons/vector_display_2d): addon · Reusable 2D display and visualization tooling · `addons/vector_display_2d`

### Autoload

Cross-scene singleton services and persistent state

- [Scene Manager](https://github.com/andresit1524/beast_card_clash/blob/main/autoload/scene_manager.gd): autoload service · Scene transition and navigation controller · `autoload/scene_manager.gd`
- [Music Manager](https://github.com/andresit1524/beast_card_clash/blob/main/autoload/music_manager.gd): autoload service · Persistent soundtrack and playlist control · `autoload/music_manager.gd`
- [Flags Manager](https://github.com/andresit1524/beast_card_clash/blob/main/autoload/flags_manager.gd): autoload service · Progression flags and game-state persistence · `autoload/flags_manager.gd`
- [Player Stats](https://github.com/andresit1524/beast_card_clash/blob/main/autoload/player_stats.gd): autoload service · Persistent player state and statistics · `autoload/player_stats.gd`

### Game Assets

Scenes, gameplay content, UI, audio, and visual resources

- [Battle Manager](https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/battle_manager.gd): orchestrator · Coordinates battle flow across state, UI, and world · `assets/battle/battle_manager.gd`
- [Battle States](https://github.com/andresit1524/beast_card_clash/tree/main/assets/battle/states): state set · Battle state machine stages: start, referee, turn, loop, end · `assets/battle/states`
- [Battle UI](https://github.com/andresit1524/beast_card_clash/tree/main/assets/battle/ui): presentation · Battle-facing panels and interaction surfaces · `assets/battle/ui`
- [Battle World](https://github.com/andresit1524/beast_card_clash/tree/main/assets/battle/world): scene layer · World scene and combat objects rendered during battle · `assets/battle/world`
- [Battle Data](https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/resources/battle_data.gd): resource schema · Resource-driven battle configuration and outcome data · `assets/battle/resources/battle_data.gd`
- [Battle Scene](https://github.com/andresit1524/beast_card_clash/blob/main/assets/battle/battle.tscn): scene · Top-level battle scene entry point · `assets/battle/battle.tscn`
- [Cards](https://github.com/andresit1524/beast_card_clash/tree/main/assets/cards): content · Card definitions, scenes, and card lists · `assets/cards`
- [Elements](https://github.com/andresit1524/beast_card_clash/tree/main/assets/elements): content · Element list resources and associated sprites · `assets/elements`
- [Teams](https://github.com/andresit1524/beast_card_clash/tree/main/assets/teams): content · Team list resources and faction identity data · `assets/teams`
- [Character Select](https://github.com/andresit1524/beast_card_clash/tree/main/assets/character_selector): menu flow · Pre-battle team and skin selection scenes · `assets/character_selector`
- [Start Menu](https://github.com/andresit1524/beast_card_clash/tree/main/assets/ui/start_menu): menu scene · Entry shell scene for the game · `assets/ui/start_menu`
- [Tutorial](https://github.com/andresit1524/beast_card_clash/tree/main/assets/ui/tutorial): ui scene · Tutorial and onboarding scene flow · `assets/ui/tutorial`
- [Credits](https://github.com/andresit1524/beast_card_clash/tree/main/assets/ui/credits): ui scene · Credits screen scene · `assets/ui/credits`
- [Dialogue Content](https://github.com/andresit1524/beast_card_clash/tree/main/assets/dialogues): story assets · Game dialogue resources consumed by the dialogue addon · `assets/dialogues`

### Support

Documentation and validation artifacts

- [Design Docs](https://github.com/andresit1524/beast_card_clash/blob/main/.docs): documentation · Battle architecture and state-machine notes · `.docs`
- [Tests & Demo](https://github.com/andresit1524/beast_card_clash/tree/main/tests): validation · Smoke tests and demo validation artifacts · `tests`

## Connections

- Scene Manager → Start Menu: opens · Navigates into shell scenes and gameplay entry points
- Scene Manager → Battle Scene: loads · Transitions into battle scenes
- Scene Manager → Tutorial: loads · Transitions into tutorial flow
- Scene Manager → Credits: loads · Transitions into credits screen
- Music Manager → Start Menu: menu music · Drives menu soundtrack behavior
- Music Manager → Battle Scene: battle music · Switches audio context for combat
- Flags Manager → Character Select: progression · Controls unlocks and flow gating
- Player Stats → Character Select: load state · Provides persistent player state to setup screens
- Start Menu → Scene Manager: navigate · Starts scene transitions from the shell
- Character Select → Battle Scene: start battle · Sends chosen setup into combat flow
- Battle Scene → Battle Manager: hosts · Scene entry point for battle orchestration
- Battle Manager → Battle States: drives · Advances the battle state machine
- Battle Manager → Battle UI: updates · Synchronizes UI with battle state
- Battle Manager → Battle World: controls · Coordinates world presentation and combat objects
- Battle Manager → Battle Data: consumes · Uses resource-driven battle configuration
- Battle States → Battle Data: reads · States use structured battle data during progression
- Battle UI → Cards: shows cards · Battle UI presents card-based gameplay content
- Battle UI → Player Stats: reflects · Displays persistent player-related state when needed
- Battle World → Vector Display: uses visuals · May rely on shared visualization helpers
- Dialogue Manager → Dialogue Content: runs · Compiles and renders authored dialogue content
- Dialogue Manager → Tutorial: narrates · Supports onboarding and story presentation
- Dialogue Manager → Credits: presents text · Can power narrative UI screens if needed
- Design Docs → Battle States: describes · Documents intended battle control flow
- Tests & Demo → Battle Manager: exercises · Validates core battle behavior through demos
- Cards → Battle Data: feeds · Card content contributes to battle configuration
- Elements → Cards: supports · Element definitions underpin card identity
- Teams → Character Select: drives choice · Team resources populate selection screens
