A D&D 5E AI-powered text adventure RPG built in C# with Spectre.Console and Google Gemini AI.
Ported from GenQuest-Go (Go / BubbleTea TUI) to a chat-style console interface.
GenQuest is a single-player text adventure where an AI Dungeon Master guides you through procedurally generated quests. You create or describe a character, pick a quest theme, and the Gemini AI builds a branching adventure with combat encounters, ability checks, and narrative choices.
Key features:
- Full D&D 5E character creation (9 races, 13 classes, 8 backgrounds, ~100 subclasses)
- AI-generated quests, characters, and DM narration via Google Gemini (
gemini-2.0-flash) - Turn-based combat engine with spells, class abilities, items, and concentration
- Leveling, XP, short/long rests, spell slots, hit dice
- Save/load system with multiple save slots per character
- Data-driven design -- all D&D data loaded from JSON files at runtime, fully moddable
| Component | Technology |
|---|---|
| Runtime | .NET 10 |
| Console UI | Spectre.Console 0.54.0 |
| AI | Google Gemini API (gemini-2.0-flash) |
| Secrets | .NET User Secrets + env var fallback |
| Data format | JSON (seeded on first run, user-editable) |
GenQuest-Sharp/
├── Program.cs # Entry point
├── Models/
│ ├── Enums.cs # All enums (AbilityName, ItemType, etc.)
│ └── Types.cs # All model classes (Character, Quest, etc.)
├── Data/
│ ├── JsonConfig.cs # Shared JSON serializer options
│ ├── GameData.cs # Runtime data container
│ ├── DataLoader.cs # Loads JSON files into GameData
│ └── DataSeeder.cs # Seeds default JSON on first run
├── Services/
│ ├── AdventureEngine.cs # Combat engine, ability checks, game mechanics
│ ├── CharacterBuilder.cs # Character creation, leveling, rest mechanics
│ ├── GameDataHelpers.cs # Utility methods for querying game data
│ ├── GeminiApi.cs # Gemini AI integration (quest/character gen, DM chat)
│ └── SaveManager.cs # Save/load system (characters + game state)
└── UI/
├── GameUI.cs # Core partial class (fields, banner, RunAsync)
├── GameUI.CharacterSelect.cs # Character list & selection
├── GameUI.CharacterCreate.cs # Custom, AI-prompted, and preset creation
├── GameUI.QuestSetup.cs # Quest theme selection & AI generation
├── GameUI.Adventure.cs # Main gameplay loop, slash commands, DM chat
├── GameUI.Combat.cs # Turn-based combat UI
├── GameUI.LevelUp.cs # Level-up flow (subclass, ASI, spells)
├── GameUI.SaveLoad.cs # Load game, dead character handling, manage saves
└── GameUI.Display.cs # Display helpers, rest actions, formatting
~7,400 lines of C# across 21 files.
Models (types/enums) → Data (JSON load/seed) → Services (engine/AI/save) → UI (Spectre.Console)
- Models: Pure data types with
[JsonPropertyName]attributes. No logic. - Data:
DataSeederwrites default JSON files on first run if they don't exist.DataLoaderreads them into aGameDatacontainer. Users can edit the JSON files to mod the game. - Services: All static classes.
AdventureEnginehandles combat, checks, and game state.CharacterBuilderhandles creation and leveling.GeminiApimanages all AI calls.SaveManagerhandles persistence. - UI: A single
partial class GameUIsplit across 9 files. Uses Spectre.Console prompts, panels, tables, and markup for a chat-style interface (no alt-screen TUI).
The UI is a chat-style console interface with freeform text input and slash commands:
- Type freely to talk to the AI Dungeon Master
/1,/2,/3-- pick numbered choices from the DM/inventory(/i) -- show inventory/character(/c) -- show character sheet/quest(/q) -- show quest log/rest-- short rest (spend hit dice, recharge abilities)/longrest-- long rest (full HP, spells, hit dice)/use <item>-- use an item (e.g./use Healing Potion)/save-- manual save/quit-- save and quit?-- show help
- .NET 10 SDK
- A Google Gemini API key
The app looks for the Gemini API key in this order:
-
.NET User Secrets (recommended):
cd GenQuest-Sharp dotnet user-secrets set "GeminiApiKey" "YOUR_API_KEY_HERE"
-
Environment variable:
GEMINI_API_KEY -
.envfile in the project root:GEMINI_API_KEY=YOUR_API_KEY_HERE
dotnet build
dotnet runAll D&D 5E data is loaded from JSON files at runtime from a data/ directory (created inside the build output directory on first run). The following files are seeded with defaults:
| File | Contents |
|---|---|
races.json |
9 races with ability bonuses, traits, speed |
classes.json |
13 classes with hit dice, saves, skills, spell progression |
backgrounds.json |
8 backgrounds with skill proficiencies and equipment |
presets.json |
11 preset characters for quick start |
quest_themes.json |
10 quest theme strings |
items.json |
Items database (weapons, armor, potions, scrolls) |
starting_potions.json |
Default starting inventory |
Edit these JSON files to add custom races, classes, items, quests, etc. Your edits are preserved across runs -- the seeder only writes files that don't already exist.
- Spectre.Console markup escaping: Any
[text]in markup strings is parsed as a style tag. All dynamic content usesMarkup.Escape(), and literal brackets use[[/]]escaping. This has been audited across all 200+ markup calls. - Spell slot tables, class progressions, subclass data: These are defined in
DataSeeder.csand seeded to JSON. The leveling tables (XP thresholds, spell slots per level, cantrips known, etc.) are embedded in the class data JSON. - AdventureEngine.cs (1,490 lines) is the largest file -- contains the full combat system, ability checks, item usage, spell casting, concentration, and all D&D 5E mechanical logic.
Ported from GenQuest-Go -- a Go implementation using BubbleTea for a panel-based TUI. The C# version replaces the panel TUI with a simpler chat-style console interface using Spectre.Console, and moves all hardcoded D&D data to runtime-loaded JSON files.