# davidslv/rogue architecture

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

- Interactive diagram: https://gitdiagram.com/davidslv/rogue
- Repository: https://github.com/davidslv/rogue

## Overview

Rogue is a terminal dungeon-crawling game: the player starts or restores a run, issues commands, explores generated dungeon levels, fights monsters, uses and collects items, and ultimately dies or escapes; scores record the outcome. The runtime is organized around the main game loop, with separate modules for world generation, movement, combat, item effects, and persistence. The README documents major gameplay and save/score capabilities, but most implementation excerpts are absent, so uncertain internal links are omitted rather than inferred.

Main entry points: [`things.c`](https://github.com/davidslv/rogue/blob/master/things.c) (Item Handling), [`main.c`](https://github.com/davidslv/rogue/blob/master/main.c) (Game Entry), [`command.c`](https://github.com/davidslv/rogue/blob/master/command.c) (Command Loop), [`new_level.c`](https://github.com/davidslv/rogue/blob/master/new_level.c) (Level Setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_main["Game Entry<br/>[main.c]"]
  node_commands["Command Loop<br/>[command.c]"]
  node_shared_state["Game State<br/>[extern.c]"]
end

subgraph group_world["Dungeon World"]
  node_level_setup["Level Setup<br/>[new_level.c]"]
  node_rooms["Room Generation<br/>[rooms.c]"]
  node_passages["Passage Generation<br/>[passages.c]"]
end

subgraph group_play["Gameplay"]
  node_movement["Movement<br/>[move.c]"]
  node_monster_ai["Monster Pursuit<br/>[chase.c]"]
  node_combat["Combat<br/>[fight.c]"]
  node_monster_catalog["Monster Catalog<br/>[monsters.c]"]
  node_item_system["Item Handling<br/>[things.c]"]
  node_potions["Potions<br/>[potions.c]"]
  node_scrolls["Scrolls<br/>[scrolls.c]"]
  node_wands["Wands and Staves<br/>[sticks.c]"]
  node_weapons["Weapons<br/>[weapons.c]"]
  node_armor["Armor<br/>[armor.c]"]
end

subgraph group_records["Persistence and Records"]
  node_save_state["Save and Restore<br/>[save.c]"]
  node_state_codec["State Serialization<br/>[state.c]"]
  node_scoreboard[("Scoreboard<br/>[rip.c]")]
end

subgraph group_platform["Terminal Platform"]
  node_terminal["Terminal Portability<br/>[mdport.c]"]
end

node_player(("Player"))
node_curses["Curses Terminal"]

node_player -->|"starts game"| node_main
node_main -->|"initializes port"| node_terminal
node_main -->|"opens scores"| node_scoreboard
node_main -->|"sets up game"| node_level_setup
node_main -->|"runs commands"| node_commands
node_player -->|"issues commands"| node_commands
node_commands -.->|"moves hero"| node_movement
node_commands -.->|"attacks monsters"| node_combat
node_commands -.->|"uses items"| node_item_system
node_level_setup -.->|"generates rooms"| node_rooms
node_level_setup -.->|"generates passages"| node_passages
node_monster_ai -.->|"engages hero"| node_combat
node_item_system -.->|"handles potions"| node_potions
node_item_system -.->|"handles scrolls"| node_scrolls
node_item_system -.->|"handles wands"| node_wands
node_item_system -.->|"handles weapons"| node_weapons
node_item_system -.->|"handles armor"| node_armor
node_player -->|"restores save"| node_save_state
node_save_state -.->|"serializes state"| node_state_codec
node_player -->|"views scores"| node_scoreboard
node_terminal -->|"uses terminal UI"| node_curses

click node_main "https://github.com/davidslv/rogue/blob/master/main.c"
click node_commands "https://github.com/davidslv/rogue/blob/master/command.c"
click node_shared_state "https://github.com/davidslv/rogue/blob/master/extern.c"
click node_level_setup "https://github.com/davidslv/rogue/blob/master/new_level.c"
click node_rooms "https://github.com/davidslv/rogue/blob/master/rooms.c"
click node_passages "https://github.com/davidslv/rogue/blob/master/passages.c"
click node_movement "https://github.com/davidslv/rogue/blob/master/move.c"
click node_monster_ai "https://github.com/davidslv/rogue/blob/master/chase.c"
click node_combat "https://github.com/davidslv/rogue/blob/master/fight.c"
click node_monster_catalog "https://github.com/davidslv/rogue/blob/master/monsters.c"
click node_item_system "https://github.com/davidslv/rogue/blob/master/things.c"
click node_potions "https://github.com/davidslv/rogue/blob/master/potions.c"
click node_scrolls "https://github.com/davidslv/rogue/blob/master/scrolls.c"
click node_wands "https://github.com/davidslv/rogue/blob/master/sticks.c"
click node_weapons "https://github.com/davidslv/rogue/blob/master/weapons.c"
click node_armor "https://github.com/davidslv/rogue/blob/master/armor.c"
click node_save_state "https://github.com/davidslv/rogue/blob/master/save.c"
click node_state_codec "https://github.com/davidslv/rogue/blob/master/state.c"
click node_scoreboard "https://github.com/davidslv/rogue/blob/master/rip.c"
click node_terminal "https://github.com/davidslv/rogue/blob/master/mdport.c"

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_main,node_commands,node_shared_state toneBlue
class node_level_setup,node_rooms,node_passages toneAmber
class node_movement,node_monster_ai,node_combat,node_monster_catalog,node_item_system,node_potions,node_scrolls,node_wands,node_weapons,node_armor toneMint
class node_save_state,node_state_codec,node_scoreboard toneRose
class node_terminal,node_player,node_curses toneIndigo
```

## Components

### Game Runtime

- [Game Entry](https://github.com/davidslv/rogue/blob/master/main.c): `main.c`
- [Command Loop](https://github.com/davidslv/rogue/blob/master/command.c): `command.c`
- [Game State](https://github.com/davidslv/rogue/blob/master/extern.c): `extern.c`

### Dungeon World

- [Level Setup](https://github.com/davidslv/rogue/blob/master/new_level.c): `new_level.c`
- [Room Generation](https://github.com/davidslv/rogue/blob/master/rooms.c): `rooms.c`
- [Passage Generation](https://github.com/davidslv/rogue/blob/master/passages.c): `passages.c`

### Gameplay

- [Movement](https://github.com/davidslv/rogue/blob/master/move.c): `move.c`
- [Monster Pursuit](https://github.com/davidslv/rogue/blob/master/chase.c): `chase.c`
- [Combat](https://github.com/davidslv/rogue/blob/master/fight.c): `fight.c`
- [Monster Catalog](https://github.com/davidslv/rogue/blob/master/monsters.c): `monsters.c`
- [Item Handling](https://github.com/davidslv/rogue/blob/master/things.c): `things.c`
- [Potions](https://github.com/davidslv/rogue/blob/master/potions.c): `potions.c`
- [Scrolls](https://github.com/davidslv/rogue/blob/master/scrolls.c): `scrolls.c`
- [Wands and Staves](https://github.com/davidslv/rogue/blob/master/sticks.c): `sticks.c`
- [Weapons](https://github.com/davidslv/rogue/blob/master/weapons.c): `weapons.c`
- [Armor](https://github.com/davidslv/rogue/blob/master/armor.c): `armor.c`

### Persistence and Records

- [Save and Restore](https://github.com/davidslv/rogue/blob/master/save.c): `save.c`
- [State Serialization](https://github.com/davidslv/rogue/blob/master/state.c): `state.c`
- [Scoreboard](https://github.com/davidslv/rogue/blob/master/rip.c): `rip.c`

### Terminal Platform

- [Terminal Portability](https://github.com/davidslv/rogue/blob/master/mdport.c): `mdport.c`

### Other components

- **Player**
- **Curses Terminal**

## Connections

- Player → Game Entry: starts game (evidence: `README.md`)
- Game Entry → Terminal Portability: initializes port (evidence: `main.c`)
- Game Entry → Scoreboard: opens scores (evidence: `main.c`)
- Game Entry → Level Setup: sets up game (evidence: `main.c`)
- Game Entry → Command Loop: runs commands (evidence: `main.c`)
- Player → Command Loop: issues commands (evidence: `README.md`)
- Command Loop → Movement: moves hero
- Command Loop → Combat: attacks monsters
- Command Loop → Item Handling: uses items
- Level Setup → Room Generation: generates rooms
- Level Setup → Passage Generation: generates passages
- Monster Pursuit → Combat: engages hero
- Item Handling → Potions: handles potions
- Item Handling → Scrolls: handles scrolls
- Item Handling → Wands and Staves: handles wands
- Item Handling → Weapons: handles weapons
- Item Handling → Armor: handles armor
- Player → Save and Restore: restores save (evidence: `README.md`)
- Save and Restore → State Serialization: serializes state
- Player → Scoreboard: views scores (evidence: `README.md`)
- Terminal Portability → Curses Terminal: uses terminal UI (evidence: `README.md`)
