Skip to content

tyler-builds/fable-forge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

25 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—ก๏ธ Fable Forge

An AI-powered text-based RPG that brings classic tabletop gaming to life with dynamic storytelling, intelligent dungeon mastering, and immersive adventures.

TypeScript React Convex OpenAI


โœจ Features

๐ŸŽญ Character Creation

  • Choose from three distinct classes: Warrior, Mage, or Rogue
  • Point-buy stat allocation system for customized builds
  • Unique character portraits for each class
  • Dynamic stat calculation (HP, MP, modifiers)

๐Ÿค– AI Dungeon Master

  • Powered by OpenAI GPT-5 for intelligent, context-aware storytelling
  • Dynamic world generation tailored to your character class
  • Realistic NPC interactions and branching narratives
  • Proactive world events that keep adventures engaging

๐ŸŽฒ D&D-Style Mechanics

  • D20 skill checks with stat modifiers
  • Attribute-based difficulty classes (DC)
  • Eight core stats: STR, DEX, CON, INT, WIS, CHA, HP, MP
  • Real-time stat tracking and adjustments

๐Ÿ“ฆ Inventory & Economy

  • Item collection with descriptions and reasons
  • Gold system for trading and purchases
  • AI-detected transactions (buying, selling, looting)
  • Persistent inventory across sessions

๐ŸŒ Dynamic Worlds

  • AI-generated scene backgrounds based on location
  • Background caching and reuse system
  • Adaptive scene descriptions
  • Glossary building for lore and world-building

๐Ÿ“ˆ Progression System

  • Experience points (XP) and level-up mechanics
  • Class-specific stat growth
  • Character development tracking
  • Level-based difficulty scaling

๐Ÿ’พ Save Management

  • Multiple adventure save slots
  • Automatic progress saving
  • Continue from where you left off
  • Adventure dashboard with all your quests

๐Ÿ” Secure Authentication

  • User accounts with Better Auth
  • Protected adventure data
  • Personal adventure library
  • Secure session management

๐Ÿ› ๏ธ Tech Stack

Technology Purpose
React 19 Frontend UI framework
TypeScript Type-safe development
Vite Build tool and dev server
Convex Real-time backend and database
OpenAI API GPT-5 Mini for AI storytelling
Better Auth Authentication system
Tailwind CSS Utility-first styling
Lucide React Icon library

๐Ÿš€ Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/fable-forge.git
    cd fable-forge
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # OpenAI API Configuration
    OPENAI_API_KEY=your_openai_api_key_here
    
    # Convex (configured via `npx convex dev`)
    VITE_CONVEX_URL=your_convex_deployment_url
  4. Initialize Convex

    npx convex dev

    This will:

    • Set up your Convex backend
    • Open the Convex dashboard
    • Generate your deployment URL
  5. Run migrations (if you have existing data)

    In the Convex dashboard, run these mutations:

    // Add gold to existing adventures
    await mutation(api.adventures.migrateGoldField, {})
    
    // Add leveling fields to existing adventures
    await mutation(api.adventures.migrateLevelingFields, {})
  6. Start the development server

    npm run dev

    The app will open at http://localhost:5173


๐ŸŽฎ How to Play

1. Create Your Account

Sign up with email to save your adventures and progress.

2. Build Your Character

  • Select a class: Warrior (tanky), Mage (magical), or Rogue (agile)
  • Allocate 27 points across your six core stats
  • View your calculated HP and MP
  • Choose a character portrait

3. Enter the World

The AI Dungeon Master generates:

  • A unique world setting
  • Your starting location
  • An engaging adventure title
  • Visual scene backgrounds

4. Take Actions

Type natural language commands:

  • "I search the room for treasure"
  • "I try to persuade the guard"
  • "I cast a fireball at the goblin"
  • "I buy a health potion from the merchant"

5. Roll for Success

The game automatically determines when skill checks are needed:

  • D20 roll + stat modifier vs. DC
  • Results affect the narrative outcome
  • Visible roll breakdown in the log

6. Manage Resources

  • Track your HP and MP
  • Monitor your gold for purchases
  • View your inventory items
  • Reference the glossary for lore

7. Level Up

  • Earn XP through challenges
  • Level up to increase stats
  • Unlock new abilities and power

8. Save & Return

  • Adventures auto-save after each turn
  • Return to the dashboard anytime
  • Continue or start new adventures
  • Delete old campaigns

๐ŸŽฏ Game Mechanics

Stats System

Stat Abbreviation Primary Use
Strength STR Melee attacks, lifting, breaking
Dexterity DEX Agility, stealth, ranged attacks
Constitution CON Health, stamina, resistance
Intelligence INT Magic power, knowledge, investigation
Wisdom WIS Perception, insight, willpower
Charisma CHA Persuasion, deception, leadership

Derived Stats

  • HP = Base (class) + CON modifier ร— 2
  • MP = Base (class) + INT modifier ร— 2
  • Modifier = floor((stat - 10) / 2)

Dice Rolling

  • D20 + stat modifier vs. DC
  • DC ranges: 6-10 (easy), 10-15 (medium), 16-20 (hard), 21+ (very hard)
  • Critical success on natural 20
  • Automatic failure on natural 1

Gold System

  • Start with 100 gold
  • Earn through quests and looting
  • Spend on items, services, bribes
  • AI detects purchase intent automatically

Leveling

  • Earn XP through successful actions and combat
  • Level up unlocks stat increases
  • Class-specific growth patterns
  • Progressive difficulty scaling

๐Ÿ“ Project Structure

fable-forge/
โ”œโ”€โ”€ convex/                    # Backend (Convex)
โ”‚   โ”œโ”€โ”€ schema.ts             # Database schema
โ”‚   โ”œโ”€โ”€ adventures.ts         # Adventure queries/mutations
โ”‚   โ”œโ”€โ”€ startAdventure.ts     # AI turn processing
โ”‚   โ”œโ”€โ”€ dmSchema.ts           # AI response schema
โ”‚   โ”œโ”€โ”€ levelingSystem.ts     # XP and leveling logic
โ”‚   โ”œโ”€โ”€ backgrounds.ts        # Scene background generation
โ”‚   โ””โ”€โ”€ auth.ts               # Authentication config
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/           # React components
โ”‚   โ”‚   โ”œโ”€โ”€ CharacterCreation.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ CharacterStats.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ AdventureLog.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ ActionInput.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ InventoryPanel.tsx
โ”‚   โ”‚   โ””โ”€โ”€ GlossaryPanel.tsx
โ”‚   โ”œโ”€โ”€ hooks/                # Custom React hooks
โ”‚   โ”œโ”€โ”€ lib/                  # Utilities and helpers
โ”‚   โ””โ”€โ”€ App.tsx               # Main application
โ”œโ”€โ”€ .env.local                # Environment variables
โ””โ”€โ”€ package.json              # Dependencies

๐Ÿ”ง Configuration

OpenAI Models Used

Model Purpose Reasoning Effort
gpt-5-mini Main storytelling, adventure generation Minimal
gpt-5-nano Quick roll checks and decisions Minimal

Convex Tables

  • adventures - Character and world state
  • adventureActions - Turn-by-turn game log
  • adventureInventory - Items and quantities
  • adventureGlossary - Lore and terminology
  • sceneBackgrounds - Generated scene images
  • characterPortraits - Class portrait images

๐Ÿค Contributing

This is a personal showcase project, but contributions are welcome!

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is open source and available under the MIT License.


๐Ÿ™ Acknowledgments

  • OpenAI for powerful language models
  • Convex for seamless real-time backend
  • Better Auth for secure authentication
  • D&D 5e for game mechanics inspiration

๐Ÿ“ง Contact

For questions or feedback, open an issue on GitHub.

Enjoy your adventure in Fable Forge! โš”๏ธโœจ

About

An AI-powered text RPG where you build a character, manage stats, collect gold, and adventure through dynamic stories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors