Skip to content

do4k/GenQuest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenQuest

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.

Overview

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

Tech Stack

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)

Project Structure

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.

Architecture

Models (types/enums) → Data (JSON load/seed) → Services (engine/AI/save) → UI (Spectre.Console)
  • Models: Pure data types with [JsonPropertyName] attributes. No logic.
  • Data: DataSeeder writes default JSON files on first run if they don't exist. DataLoader reads them into a GameData container. Users can edit the JSON files to mod the game.
  • Services: All static classes. AdventureEngine handles combat, checks, and game state. CharacterBuilder handles creation and leveling. GeminiApi manages all AI calls. SaveManager handles persistence.
  • UI: A single partial class GameUI split across 9 files. Uses Spectre.Console prompts, panels, tables, and markup for a chat-style interface (no alt-screen TUI).

Gameplay

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

Setup

Prerequisites

API Key Configuration

The app looks for the Gemini API key in this order:

  1. .NET User Secrets (recommended):

    cd GenQuest-Sharp
    dotnet user-secrets set "GeminiApiKey" "YOUR_API_KEY_HERE"
  2. Environment variable: GEMINI_API_KEY

  3. .env file in the project root:

    GEMINI_API_KEY=YOUR_API_KEY_HERE
    

Build & Run

dotnet build
dotnet run

Data-Driven Design

All 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.

Known Issues / Notes

  • Spectre.Console markup escaping: Any [text] in markup strings is parsed as a style tag. All dynamic content uses Markup.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.cs and 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.

Origin

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages