# simocastro18/knightmare architecture

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

- Interactive diagram: https://gitdiagram.com/simocastro18/knightmare
- Repository: https://github.com/simocastro18/knightmare

## Overview

Knightmare is an Unreal Engine turn-based 1v1 tactics game against AI. The player deploys a Brawler and Sniper on a procedurally generated, elevation-based grid, then selects units to move or attack while the game mode advances turns and evaluates tower control for victory. AI units choose strategic targets and move using selectable A* or Greedy pathfinding. The map, input, unit combat, tower objectives, and UI are evidenced by the README, tree, and sampled C++; unsampled Blueprint wiring is represented only where documented, so uncertain links are omitted.

Main entry points: [`Source/StrategicoaTurni2025/Private/StrategyGameMode.cpp`](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyGameMode.cpp) (Game Mode), [`Source/StrategicoaTurni2025/Private/StrategyPlayerController.cpp`](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyPlayerController.cpp) (Player Controller), [`Source/StrategicoaTurni2025/Private/GameField.cpp`](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/GameField.cpp) (Grid Manager), [`Source/StrategicoaTurni2025/Private/StrategyUnit.cpp`](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyUnit.cpp) (Units)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_map["Map and Grid"]
  node_field["Grid Manager<br/>[GameField.cpp]"]
  node_tile["Grid Tiles<br/>[Tile.cpp]"]
end

subgraph group_match["Match Flow"]
  node_game["Game Mode"]
end

subgraph group_actors["Units and Combat"]
  node_unit["Units<br/>[StrategyUnit.cpp]"]
  node_tower["Tower Objectives<br/>[StrategyTower.cpp]"]
end

subgraph group_presentation["Player Presentation"]
  node_input["Click Input<br/>[IA_Click.uasset]"]
  node_controller["Player Controller"]
  node_hud["Game HUD"]
  node_combatlog["Combat Log"]
  node_outcome["Match Result"]
  node_setup["Deployment UI"]
end

node_player(("Player"))
node_engine(("Unreal Engine"))

node_player -->|"clicks"| node_input
node_input -->|"triggers"| node_controller
node_engine -->|"dispatches input"| node_controller
node_controller -->|"queries paths and ranges"| node_field
node_controller -->|"handles selection"| node_tile
node_controller -->|"places, moves, attacks"| node_unit
node_controller -->|"advances deployment"| node_game
node_field -->|"generates grid"| node_tile
node_field -->|"spawns objectives"| node_tower
node_field -->|"spawns AI units"| node_unit
node_game -->|"uses map manager"| node_field
node_game -->|"dispatches AI turns"| node_unit
node_game -->|"evaluates control"| node_tower
node_unit -->|"requests pathfinding"| node_field
node_unit -->|"attacks and damages"| node_unit
node_game -.->|"broadcasts turn updates"| node_hud
node_game -.->|"broadcasts log messages"| node_combatlog
node_game -.->|"shows game over"| node_outcome
node_player -->|"chooses deployment"| node_setup
node_setup -.->|"selects unit class"| node_controller

click node_input "https://github.com/simocastro18/knightmare/blob/main/Content/Input/IA_Click.uasset"
click node_controller "https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyPlayerController.cpp"
click node_field "https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/GameField.cpp"
click node_tile "https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/Tile.cpp"
click node_game "https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyGameMode.cpp"
click node_unit "https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyUnit.cpp"
click node_tower "https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyTower.cpp"
click node_hud "https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_CurrentTurn.uasset"
click node_combatlog "https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_CombatLog.uasset"
click node_outcome "https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_GameOverWinner.uasset"
click node_setup "https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_Deployment.uasset"

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_field,node_tile toneBlue
class node_game toneAmber
class node_unit,node_tower toneMint
class node_input,node_controller,node_hud,node_combatlog,node_outcome,node_setup toneRose
class node_player,node_engine toneIndigo
```

## Components

### Map and Grid

- [Grid Manager](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/GameField.cpp): `Source/StrategicoaTurni2025/Private/GameField.cpp`
- [Grid Tiles](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/Tile.cpp): `Source/StrategicoaTurni2025/Private/Tile.cpp`

### Match Flow

- [Game Mode](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyGameMode.cpp): `Source/StrategicoaTurni2025/Private/StrategyGameMode.cpp`

### Units and Combat

- [Units](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyUnit.cpp): `Source/StrategicoaTurni2025/Private/StrategyUnit.cpp`
- [Tower Objectives](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyTower.cpp): `Source/StrategicoaTurni2025/Private/StrategyTower.cpp`

### Player Presentation

- [Click Input](https://github.com/simocastro18/knightmare/blob/main/Content/Input/IA_Click.uasset): `Content/Input/IA_Click.uasset`
- [Player Controller](https://github.com/simocastro18/knightmare/blob/main/Source/StrategicoaTurni2025/Private/StrategyPlayerController.cpp): `Source/StrategicoaTurni2025/Private/StrategyPlayerController.cpp`
- [Game HUD](https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_CurrentTurn.uasset): `Content/Blueprints/WBP_CurrentTurn.uasset`
- [Combat Log](https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_CombatLog.uasset): `Content/Blueprints/WBP_CombatLog.uasset`
- [Match Result](https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_GameOverWinner.uasset): `Content/Blueprints/WBP_GameOverWinner.uasset`
- [Deployment UI](https://github.com/simocastro18/knightmare/blob/main/Content/Blueprints/WBP_Deployment.uasset): `Content/Blueprints/WBP_Deployment.uasset`

### Other components

- **Player**
- **Unreal Engine**

## Connections

- Player → Click Input: clicks
- Click Input → Player Controller: triggers
- Unreal Engine → Player Controller: dispatches input
- Player Controller → Grid Manager: queries paths and ranges
- Player Controller → Grid Tiles: handles selection
- Player Controller → Units: places, moves, attacks
- Player Controller → Game Mode: advances deployment
- Grid Manager → Grid Tiles: generates grid
- Grid Manager → Tower Objectives: spawns objectives
- Grid Manager → Units: spawns AI units
- Game Mode → Grid Manager: uses map manager
- Game Mode → Units: dispatches AI turns
- Game Mode → Tower Objectives: evaluates control
- Units → Grid Manager: requests pathfinding
- Units → Units: attacks and damages
- Game Mode → Game HUD: broadcasts turn updates
- Game Mode → Combat Log: broadcasts log messages
- Game Mode → Match Result: shows game over
- Player → Deployment UI: chooses deployment
- Deployment UI → Player Controller: selects unit class
