# zlaper/onedayrpg architecture

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

- Interactive diagram: https://gitdiagram.com/zlaper/onedayrpg
- Repository: https://github.com/zlaper/onedayrpg

## Overview

##### Main Components (Top Level)

a. Core Game Systems (Blue Rectangle)
- MainControl (Central Controller)
- SaveDataManager (Data Persistence)
- SoundControl (Audio Management)

b. Game Logic Layer (Green Rectangle)
- Battle System
- Hero Management
- Entity Generation
- Progress System

c. UI Layer (Orange Rectangle)
- Screen Management
- Hero Selection UI
- Battle UI
- Result Screen

##### Detailed Component Breakdown

a. Battle System (Purple Sub-section)
- BattleFlow
- BattlePhases
- Start Phase
- Hero Phase
- Enemy Phase
- End Check Phase
- BattleField
- Heroes (3 slots)
- Enemy (1 slot)

b. Entity System (Green Sub-section)
- Entity Framework
- Base Entity
- Hero Entity
- Enemy Entity
- Entity Generator

c. Data Management (Yellow Sub-section)
- SaveDataManager
- Hero Collection
- Battle Progress
- Player Stats

- Screen States
- Hero Selection
- Battle
- Results

- Hero Selection → Battle Initiation → Turn System → Battle Resolution → Results

##### Key Integration Points
- How SaveDataManager connects to all persistent data points
- Event system flow between UI and game logic
- Demonstrate animation system integration with battle actions

##### Technical Details
- Unity Scene structure
- DOTween integration points
- Sound system connections
- UI element hierarchy

- ◆ Core Systems
- ● UI Elements
- ■ Data Structures
- → Direct Communication
- ⇢ Event Flow
- ↔ Two-way Data Flow

##### The save system's integration points

Keep the abstraction level high enough to show system relationships but detailed enough to illustrate the game's core mechanics and data flow. Use the namespace structure (zg.gramrpg) as shown in the file tree to organize the components logically.

Remember to highlight critical paths like:
- Hero selection → Battle initialization
- Battle action → Animation → State update → UI refresh
- Victory/Defeat → Experience gain → Level up system
- Data persistence flow

This will provide a clear understanding of both the architecture and the game flow while maintaining technical accuracy.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef core fill:#b3d1ff,stroke:#333
    classDef logic fill:#b3ffb3,stroke:#333
    classDef ui fill:#ffd9b3,stroke:#333
    classDef battle fill:#e6b3ff,stroke:#333
    classDef data fill:#fff2b3,stroke:#333
    classDef entity fill:#b3ffb3,stroke:#333

    %% Core Systems
    subgraph CoreSystems
        MC["Main Controller"]:::core
        SDM["Save Data Manager"]:::core
        SC["Sound Control"]:::core
    end

    %% Game Logic Layer
    subgraph GameLogic
        BS["Battle System"]:::logic
        HM["Hero Management"]:::logic
        EG["Entity Generator"]:::logic
        PS["Progress System"]:::logic
    end

    %% UI Layer
    subgraph UILayer
        SM["Screen Management"]:::ui
        HS["Hero Selection UI"]:::ui
        BUI["Battle UI"]:::ui
        RS["Result Screen"]:::ui
    end

    %% Battle System Details
    subgraph BattleSystem
        BF["Battle Field"]:::battle
        BP["Battle Phases"]:::battle
        BSP["Start Phase"]:::battle
        BHP["Hero Phase"]:::battle
        BEP["Enemy Phase"]:::battle
        BCP["End Check Phase"]:::battle
    end

    %% Entity System
    subgraph EntitySystem
        EF["Entity Framework"]:::entity
        BE["Base Entity"]:::entity
        HE["Hero Entity"]:::entity
        EE["Enemy Entity"]:::entity
    end

    %% Data Management
    subgraph DataManagement
        HC["Hero Collection"]:::data
        BP2["Battle Progress"]:::data
        PS2["Player Stats"]:::data
    end

    %% Relationships
    MC --> BS
    MC --> SDM
    MC --> SC
    BS --> BF
    BS --> BP
    BP --> BSP
    BSP --> BHP
    BHP --> BEP
    BEP --> BCP
    HM --> EF
    EG --> BE
    BE --> HE
    BE --> EE
    SDM --> HC
    SDM --> BP2
    SDM --> PS2
    SM --> HS
    SM --> BUI
    SM --> RS

    %% Click Events
    click MC "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/game/MainControl.cs"
    click SDM "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/serialize/SaveDataManager.cs"
    click SC "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/game/controls/SoundControl.cs"
    click BS "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/rpg/battle/BattleFlow.cs"
    click BP "https://github.com/zlaper/OneDayRPG/tree/main/Assets/OneDayRPG/Scripts/zg/gramrpg/rpg/battle/battlePhases/"
    click EF "https://github.com/zlaper/OneDayRPG/tree/main/Assets/OneDayRPG/Scripts/zg/gramrpg/rpg/entities/"
    click EG "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/rpg/generators/EntityGenerator.cs"
    click SM "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/game/controls/ScreenControl.cs"
    click HS "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/ui/HeroScreen.cs"
    click BUI "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/ui/BattleScreen.cs"
    click RS "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/ui/BattleResultScreen.cs"
    click HM "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/rpg/heroes/HeroList.cs"
    click BF "https://github.com/zlaper/OneDayRPG/blob/main/Assets/OneDayRPG/Scripts/zg/gramrpg/rpg/battle/BattleField.cs"
```
