# ahineya0/elephantocracy architecture

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

- Interactive diagram: https://gitdiagram.com/ahineya0/elephantocracy
- Repository: https://github.com/ahineya0/elephantocracy

## Overview

This is a Windows Forms tile-based action game. The player starts a level, controls an elephant with the keyboard, and fights spawned enemies; the game loop processes movement, shots, collisions, damage, and cleanup, while the presenter refreshes the view. The presenter also supports saving and loading games. The map, entity, and persistence paths are visible in sampled sources; UI wiring beyond the documented presenter/view relationship and unsampled rendering details are left limited.

Main entry points: [`Models/Game.cs`](https://github.com/ahineya0/elephantocracy/blob/master/Models/Game.cs) (Game loop), [`Presenter/GamePresenter.cs`](https://github.com/ahineya0/elephantocracy/blob/master/Presenter/GamePresenter.cs) (Game presenter), [`Models/Serializator.cs`](https://github.com/ahineya0/elephantocracy/blob/master/Models/Serializator.cs) (Save and load), [`Models/GameSaveData.cs`](https://github.com/ahineya0/elephantocracy/blob/master/Models/GameSaveData.cs) (Save model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_input["Keyboard input<br/>[InputController.cs]"]
  node_presenter["Game presenter<br/>[GamePresenter.cs]"]
  node_viewcontract["View contract<br/>[IGameView.cs]"]
  node_forms["Game and menu UI<br/>[StartMenuForm.cs]"]
  node_render["Render data<br/>[RenderInfo.cs]"]
end

subgraph group_gameplay["Game simulation"]
  node_bubble["Projectile<br/>[Bubble.cs]"]
  node_effect["Effects<br/>[Effect.cs]"]
  node_freezing["Freezing effect<br/>[FreezingEffect.cs]"]
  node_game["Game loop<br/>[Game.cs]"]
  node_fire["Shot result<br/>[FireResult.cs]"]
  node_direction["Direction<br/>[Direction.cs]"]
  node_contracts["Gameplay contracts"]
end

subgraph group_world["World and actors"]
  node_player["Player<br/>[Elephant.cs]"]
  node_enemy["Enemy AI<br/>[Enemy.cs]"]
  node_ai["Random AI"]
  node_map["Map<br/>[Map.cs]"]
  node_block["Map blocks<br/>[Block.cs]"]
  node_spawn["Spawn service"]
end

subgraph group_persistence["Persistence"]
  node_serializer["Save and load<br/>[Serializator.cs]"]
  node_savefiles[("Save files")]
  node_savedata["Save model<br/>[GameSaveData.cs]"]
  node_entitydata["Entity save data<br/>[ElephantData.cs]"]
  node_enemydata["Enemy save data<br/>[EnemyData.cs]"]
end

node_actor(("Player"))

node_actor -.->|"starts game"| node_forms
node_forms -.->|"starts session"| node_presenter
node_presenter -->|"updates view"| node_viewcontract
node_presenter -->|"updates"| node_game
node_presenter -->|"forwards keys"| node_input
node_presenter -->|"saves and loads"| node_serializer
node_presenter -->|"gets spawn points"| node_spawn
node_presenter -->|"builds render sectors"| node_map
node_presenter -->|"returns render data"| node_render
node_input -->|"provides movement"| node_direction
node_game -->|"checks and changes"| node_map
node_map -->|"stores"| node_block
node_game -->|"reads controls"| node_input
node_game -->|"moves and attacks"| node_player
node_game -->|"moves and attacks"| node_enemy
node_enemy -->|"uses brain"| node_ai
node_game -->|"creates and updates"| node_bubble
node_game -->|"uses shot result"| node_fire
node_game -->|"dispatches actions"| node_contracts
node_game -->|"uses directions"| node_direction
node_effect -->|"specializes"| node_freezing
node_serializer -->|"serializes"| node_savedata
node_serializer -->|"captures player"| node_entitydata
node_serializer -->|"captures enemies"| node_enemydata
node_serializer -->|"reads and writes"| node_savefiles
node_savedata -->|"stores map"| node_map
node_savedata -->|"stores player data"| node_entitydata
node_savedata -->|"stores enemy data"| node_enemydata

click node_player "https://github.com/ahineya0/elephantocracy/blob/master/Models/Elephant.cs"
click node_enemy "https://github.com/ahineya0/elephantocracy/blob/master/Models/Enemy.cs"
click node_ai "https://github.com/ahineya0/elephantocracy/blob/master/Models/RandomAIController.cs"
click node_bubble "https://github.com/ahineya0/elephantocracy/blob/master/Models/Bubble.cs"
click node_effect "https://github.com/ahineya0/elephantocracy/blob/master/Models/Effect.cs"
click node_freezing "https://github.com/ahineya0/elephantocracy/blob/master/Models/Effects/FreezingEffect.cs"
click node_game "https://github.com/ahineya0/elephantocracy/blob/master/Models/Game.cs"
click node_map "https://github.com/ahineya0/elephantocracy/blob/master/Models/Map.cs"
click node_block "https://github.com/ahineya0/elephantocracy/blob/master/Models/Block.cs"
click node_spawn "https://github.com/ahineya0/elephantocracy/blob/master/Services/SpawnOnMapService.cs"
click node_input "https://github.com/ahineya0/elephantocracy/blob/master/Models/InputController.cs"
click node_presenter "https://github.com/ahineya0/elephantocracy/blob/master/Presenter/GamePresenter.cs"
click node_viewcontract "https://github.com/ahineya0/elephantocracy/blob/master/Interfaces/IGameView.cs"
click node_forms "https://github.com/ahineya0/elephantocracy/blob/master/View/StartMenuForm.cs"
click node_render "https://github.com/ahineya0/elephantocracy/blob/master/Presenter/RenderModels/RenderInfo.cs"
click node_serializer "https://github.com/ahineya0/elephantocracy/blob/master/Models/Serializator.cs"
click node_savedata "https://github.com/ahineya0/elephantocracy/blob/master/Models/GameSaveData.cs"
click node_entitydata "https://github.com/ahineya0/elephantocracy/blob/master/Models/ElephantData.cs"
click node_enemydata "https://github.com/ahineya0/elephantocracy/blob/master/Models/EnemyData.cs"
click node_fire "https://github.com/ahineya0/elephantocracy/blob/master/Structures/FireResult.cs"
click node_direction "https://github.com/ahineya0/elephantocracy/blob/master/Enums/Direction.cs"
click node_contracts "https://github.com/ahineya0/elephantocracy/tree/master/Interfaces"

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_input,node_presenter,node_viewcontract,node_forms,node_render toneBlue
class node_bubble,node_effect,node_freezing,node_game,node_fire,node_direction,node_contracts toneAmber
class node_player,node_enemy,node_ai,node_map,node_block,node_spawn toneMint
class node_serializer,node_savefiles,node_savedata,node_entitydata,node_enemydata toneRose
class node_actor toneIndigo
```

## Components

### Presentation

- [Keyboard input](https://github.com/ahineya0/elephantocracy/blob/master/Models/InputController.cs): `Models/InputController.cs`
- [Game presenter](https://github.com/ahineya0/elephantocracy/blob/master/Presenter/GamePresenter.cs): `Presenter/GamePresenter.cs`
- [View contract](https://github.com/ahineya0/elephantocracy/blob/master/Interfaces/IGameView.cs): `Interfaces/IGameView.cs`
- [Game and menu UI](https://github.com/ahineya0/elephantocracy/blob/master/View/StartMenuForm.cs): `View/StartMenuForm.cs`
- [Render data](https://github.com/ahineya0/elephantocracy/blob/master/Presenter/RenderModels/RenderInfo.cs): `Presenter/RenderModels/RenderInfo.cs`

### Game simulation

- [Projectile](https://github.com/ahineya0/elephantocracy/blob/master/Models/Bubble.cs): `Models/Bubble.cs`
- [Effects](https://github.com/ahineya0/elephantocracy/blob/master/Models/Effect.cs): `Models/Effect.cs`
- [Freezing effect](https://github.com/ahineya0/elephantocracy/blob/master/Models/Effects/FreezingEffect.cs): `Models/Effects/FreezingEffect.cs`
- [Game loop](https://github.com/ahineya0/elephantocracy/blob/master/Models/Game.cs): `Models/Game.cs`
- [Shot result](https://github.com/ahineya0/elephantocracy/blob/master/Structures/FireResult.cs): `Structures/FireResult.cs`
- [Direction](https://github.com/ahineya0/elephantocracy/blob/master/Enums/Direction.cs): `Enums/Direction.cs`
- [Gameplay contracts](https://github.com/ahineya0/elephantocracy/tree/master/Interfaces): `Interfaces`

### World and actors

- [Player](https://github.com/ahineya0/elephantocracy/blob/master/Models/Elephant.cs): `Models/Elephant.cs`
- [Enemy AI](https://github.com/ahineya0/elephantocracy/blob/master/Models/Enemy.cs): `Models/Enemy.cs`
- [Random AI](https://github.com/ahineya0/elephantocracy/blob/master/Models/RandomAIController.cs): `Models/RandomAIController.cs`
- [Map](https://github.com/ahineya0/elephantocracy/blob/master/Models/Map.cs): `Models/Map.cs`
- [Map blocks](https://github.com/ahineya0/elephantocracy/blob/master/Models/Block.cs): `Models/Block.cs`
- [Spawn service](https://github.com/ahineya0/elephantocracy/blob/master/Services/SpawnOnMapService.cs): `Services/SpawnOnMapService.cs`

### Persistence

- [Save and load](https://github.com/ahineya0/elephantocracy/blob/master/Models/Serializator.cs): `Models/Serializator.cs`
- **Save files**
- [Save model](https://github.com/ahineya0/elephantocracy/blob/master/Models/GameSaveData.cs): `Models/GameSaveData.cs`
- [Entity save data](https://github.com/ahineya0/elephantocracy/blob/master/Models/ElephantData.cs): `Models/ElephantData.cs`
- [Enemy save data](https://github.com/ahineya0/elephantocracy/blob/master/Models/EnemyData.cs): `Models/EnemyData.cs`

### Other components

- **Player**

## Connections

- Player → Game and menu UI: starts game
- Game and menu UI → Game presenter: starts session
- Game presenter → View contract: updates view (evidence: `Presenter/GamePresenter.cs`)
- Game presenter → Game loop: updates (evidence: `Presenter/GamePresenter.cs`)
- Game presenter → Keyboard input: forwards keys (evidence: `Presenter/GamePresenter.cs`)
- Game presenter → Save and load: saves and loads (evidence: `Presenter/GamePresenter.cs`)
- Game presenter → Spawn service: gets spawn points (evidence: `Presenter/GamePresenter.cs`)
- Game presenter → Map: builds render sectors (evidence: `Presenter/GamePresenter.cs`)
- Game presenter → Render data: returns render data (evidence: `Presenter/GamePresenter.cs`)
- Keyboard input → Direction: provides movement (evidence: `Models/InputController.cs`)
- Game loop → Map: checks and changes (evidence: `Models/Game.cs`)
- Map → Map blocks: stores (evidence: `Models/Map.cs`)
- Game loop → Keyboard input: reads controls (evidence: `Models/Game.cs`)
- Game loop → Player: moves and attacks (evidence: `Models/Game.cs`)
- Game loop → Enemy AI: moves and attacks (evidence: `Models/Game.cs`)
- Enemy AI → Random AI: uses brain (evidence: `Models/Enemy.cs`)
- Game loop → Projectile: creates and updates (evidence: `Models/Game.cs`)
- Game loop → Shot result: uses shot result (evidence: `Models/Game.cs`)
- Game loop → Gameplay contracts: dispatches actions (evidence: `Models/Game.cs`)
- Game loop → Direction: uses directions (evidence: `Models/Game.cs`)
- Effects → Freezing effect: specializes (evidence: `Models/Effects/FreezingEffect.cs`)
- Save and load → Save model: serializes (evidence: `Models/Serializator.cs`)
- Save and load → Entity save data: captures player (evidence: `Models/Serializator.cs`)
- Save and load → Enemy save data: captures enemies (evidence: `Models/Serializator.cs`)
- Save and load → Save files: reads and writes (evidence: `Models/Serializator.cs`)
- Save model → Map: stores map (evidence: `Models/GameSaveData.cs`)
- Save model → Entity save data: stores player data (evidence: `Models/GameSaveData.cs`)
- Save model → Enemy save data: stores enemy data (evidence: `Models/GameSaveData.cs`)
