# larikhalil/d20 architecture

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

- Interactive diagram: https://gitdiagram.com/larikhalil/d20
- Repository: https://github.com/larikhalil/d20

## Overview

Crypt of the D20 is a browser-based solitaire dungeon card game. Players choose a mode, then resolve cards in four-card rooms: combat, healing, and weapon choices change the run until the deck is exhausted or vitality reaches zero. Fleeing, undo, peek-next, scoring, and saved best scores add supporting game systems; the README also documents a tutorial, difficulty selection, responsive touch/keyboard controls, animations, and procedural audio. The source index identifies game.js as the core, but its excerpt is partial, so internal connections beyond visible behavior and README-described capabilities are limited.

Main entry points: [`game.js`](https://github.com/larikhalil/d20/blob/main/game.js) (Mode Selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_play["Run and Rules"]
  node_mode["Mode Selection<br/>[game.js]"]
  node_run["Run State<br/>[game.js]"]
  node_deck["Deck and Rooms<br/>[game.js]"]
  node_cardrules["Card Resolution<br/>[game.js]"]
  node_combat["Combat and Weapons<br/>[game.js]"]
  node_potions["Potion Healing<br/>[game.js]"]
  node_flee["Room Fleeing<br/>[game.js]"]
  node_undo["Room Undo<br/>[game.js]"]
  node_outcome["Run Outcome<br/>[game.js]"]
end

subgraph group_presentation["Interface and Effects"]
  node_menu["Screens and Menus<br/>[game.js]"]
  node_input["Game Controls<br/>[game.js]"]
  node_roomview["Room Rendering<br/>[game.js]"]
  node_cardart["Card Illustrations<br/>[game.js]"]
  node_tutorial["Tutorial Coach<br/>[game.js]"]
  node_effects["Audio and Effects<br/>[game.js]"]
end

subgraph group_persistence["Saved Progress"]
  node_scores[("Best Scores<br/>[game.js]")]
  node_storage[("Browser Storage")]
end

node_player(("Player"))
node_browser["Web Browser"]

node_player -->|"plays in"| node_browser
node_browser -->|"opens game"| node_mode
node_mode -->|"starts run"| node_run
node_player -->|"chooses actions"| node_input
node_input -->|"resolves card"| node_cardrules
node_cardrules -.->|"applies monster rules"| node_combat
node_cardrules -.->|"applies healing"| node_potions
node_run -.->|"tracks cards"| node_deck
node_player -->|"may flee"| node_flee
node_player -->|"may undo"| node_undo
node_player -->|"follows guidance"| node_tutorial
node_deck -->|"exhaustion condition"| node_outcome
node_combat -->|"vitality condition"| node_outcome
node_mode -->|"sets score tier"| node_scores
node_scores -->|"saves locally"| node_storage
node_browser -->|"shows screens"| node_menu
node_roomview -.->|"renders sprites"| node_cardart
node_roomview -.->|"plays feedback"| node_effects
node_run -.->|"updates display"| node_roomview

click node_mode "https://github.com/larikhalil/d20/blob/main/game.js"
click node_run "https://github.com/larikhalil/d20/blob/main/game.js"
click node_deck "https://github.com/larikhalil/d20/blob/main/game.js"
click node_cardrules "https://github.com/larikhalil/d20/blob/main/game.js"
click node_combat "https://github.com/larikhalil/d20/blob/main/game.js"
click node_potions "https://github.com/larikhalil/d20/blob/main/game.js"
click node_flee "https://github.com/larikhalil/d20/blob/main/game.js"
click node_undo "https://github.com/larikhalil/d20/blob/main/game.js"
click node_outcome "https://github.com/larikhalil/d20/blob/main/game.js"
click node_menu "https://github.com/larikhalil/d20/blob/main/game.js"
click node_input "https://github.com/larikhalil/d20/blob/main/game.js"
click node_roomview "https://github.com/larikhalil/d20/blob/main/game.js"
click node_cardart "https://github.com/larikhalil/d20/blob/main/game.js"
click node_tutorial "https://github.com/larikhalil/d20/blob/main/game.js"
click node_effects "https://github.com/larikhalil/d20/blob/main/game.js"
click node_scores "https://github.com/larikhalil/d20/blob/main/game.js"

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_mode,node_run,node_deck,node_cardrules,node_combat,node_potions,node_flee,node_undo,node_outcome,node_browser toneBlue
class node_menu,node_input,node_roomview,node_cardart,node_tutorial,node_effects toneAmber
class node_scores,node_storage toneMint
class node_player toneIndigo
```

## Components

### Run and Rules

- [Mode Selection](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Run State](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Deck and Rooms](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Card Resolution](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Combat and Weapons](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Potion Healing](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Room Fleeing](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Room Undo](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Run Outcome](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`

### Interface and Effects

- [Screens and Menus](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Game Controls](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Room Rendering](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Card Illustrations](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Tutorial Coach](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- [Audio and Effects](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`

### Saved Progress

- [Best Scores](https://github.com/larikhalil/d20/blob/main/game.js): `game.js`
- **Browser Storage**

### Other components

- **Player**
- **Web Browser**

## Connections

- Player → Web Browser: plays in (evidence: `README.md`)
- Web Browser → Mode Selection: opens game (evidence: `README.md`)
- Mode Selection → Run State: starts run (evidence: `game.js`)
- Player → Game Controls: chooses actions (evidence: `README.md`)
- Game Controls → Card Resolution: resolves card (evidence: `README.md`)
- Card Resolution → Combat and Weapons: applies monster rules (evidence: `game.js`)
- Card Resolution → Potion Healing: applies healing (evidence: `game.js`)
- Run State → Deck and Rooms: tracks cards (evidence: `game.js`)
- Player → Room Fleeing: may flee (evidence: `README.md`)
- Player → Room Undo: may undo (evidence: `README.md`)
- Player → Tutorial Coach: follows guidance (evidence: `README.md`)
- Deck and Rooms → Run Outcome: exhaustion condition (evidence: `README.md`)
- Combat and Weapons → Run Outcome: vitality condition (evidence: `README.md`)
- Mode Selection → Best Scores: sets score tier (evidence: `README.md`)
- Best Scores → Browser Storage: saves locally (evidence: `README.md`)
- Web Browser → Screens and Menus: shows screens (evidence: `game.js`)
- Room Rendering → Card Illustrations: renders sprites (evidence: `game.js`)
- Room Rendering → Audio and Effects: plays feedback (evidence: `game.js`)
- Run State → Room Rendering: updates display (evidence: `game.js`)
