feat: Implement Phase 5 Quest System (100% complete)

Add YAML-driven quest system with context-aware offering:

Core Implementation:
- Quest data models (Quest, QuestObjective, QuestReward, QuestTriggers)
- QuestService for YAML loading and caching
- QuestEligibilityService with level, location, and probability filtering
- LoreService stub (MockLoreService) ready for Phase 6 Weaviate integration

Quest Content:
- 5 example quests across difficulty tiers (2 easy, 2 medium, 1 hard)
- Quest-centric design: quests define their NPC givers
- Location-based probability weights for natural quest offering

AI Integration:
- Quest offering section in npc_dialogue.j2 template
- Response parser extracts [QUEST_OFFER:quest_id] markers
- AI naturally weaves quest offers into NPC conversations

API Endpoints:
- POST /api/v1/quests/accept - Accept quest offer
- POST /api/v1/quests/decline - Decline quest offer
- POST /api/v1/quests/progress - Update objective progress
- POST /api/v1/quests/complete - Complete quest, claim rewards
- POST /api/v1/quests/abandon - Abandon active quest
- GET /api/v1/characters/{id}/quests - List character quests
- GET /api/v1/quests/{quest_id} - Get quest details

Frontend:
- Quest tracker sidebar with HTMX integration
- Quest offer modal for accept/decline flow
- Quest detail modal for viewing progress
- Combat service integration for kill objective tracking

Testing:
- Unit tests for Quest models and serialization
- Integration tests for full quest lifecycle
- Comprehensive test coverage for eligibility service

Documentation:
- Reorganized docs into /docs/phases/ structure
- Added Phase 5-12 planning documents
- Updated ROADMAP.md with new structure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 15:42:55 -06:00
parent e7e329e6ed
commit df26abd207
42 changed files with 8421 additions and 2227 deletions

View File

@@ -0,0 +1,109 @@
# Cellar Rats - Entry level quest for new players
quest_id: quest_cellar_rats
name: "Rat Problem in the Cellar"
description: |
Giant rats have infested the Rusty Anchor's cellar, threatening
the tavern's food supplies and scaring away customers. Grom the
bartender needs someone to clear them out.
difficulty: easy
# NPC Quest Givers (quest-centric design)
quest_giver_npc_ids:
- npc_grom_ironbeard
quest_giver_name: "Grom Ironbeard"
# Location context
location_id: crossville_tavern
region_id: crossville
# Offering conditions
offering_triggers:
location_types: ["tavern"]
specific_locations: ["crossville_tavern"]
min_character_level: 1
max_character_level: 5
required_quests_completed: []
probability_weights:
tavern: 0.35
town: 0.15
# NPC-specific offer dialogue
npc_offer_dialogues:
npc_grom_ironbeard:
dialogue: |
*leans in conspiratorially* Got a problem, friend. Giant rats
in me cellar. Been scaring off the paying customers and getting
into the ale stores. 50 gold for whoever clears 'em out.
conditions:
min_relationship: 30
required_flags: []
forbidden_flags: ["refused_rat_quest"]
# What NPCs know about this quest
npc_quest_knowledge:
npc_grom_ironbeard:
- "The rats started appearing about a week ago"
- "They seem bigger than normal rats - something's not right"
- "Old smuggling tunnels under the cellar might be where they're coming from"
- "Lost three kegs of dwarven stout to the vermin already"
# Embedded lore for AI context
lore_context:
backstory: |
The cellar of the Rusty Anchor connects to old smuggling tunnels
from Captain Morgath's days, sealed decades ago. Recent earthquakes
may have reopened them, allowing creatures to emerge.
world_connections:
- "The earthquakes that opened the tunnels also disturbed the Old Mines"
- "Giant rats are unnatural - possibly corrupted by dark magic from below"
regional_hints:
- "Smuggling was common 50 years ago in Crossville"
- "Captain Morgath was a notorious smuggler who disappeared mysteriously"
# Narrative hooks for natural dialogue
dialogue_templates:
narrative_hooks:
- "mentions unusual scratching sounds from below"
- "complains about spoiled food supplies"
- "nervously glances toward the cellar door"
- "asks if you've ever dealt with vermin before"
ambient_hints:
- "You notice scratch marks near the cellar door"
- "A faint squeaking echoes from somewhere below"
- "The air carries a musty, unpleasant odor"
# Objectives
objectives:
- objective_id: kill_rats
description: "Clear out the giant rats"
objective_type: kill
required_progress: 10
target_enemy_type: giant_rat
- objective_id: find_source
description: "Discover where the rats are coming from"
objective_type: discover
required_progress: 1
target_location_id: smuggler_tunnel_entrance
# Rewards
rewards:
gold: 50
experience: 100
items: []
relationship_bonuses:
npc_grom_ironbeard: 10
unlocks_quests: ["quest_tunnel_mystery"]
reveals_locations: ["crossville_tunnels"]
# Completion dialogue
completion_dialogue:
npc_grom_ironbeard: |
*actually smiles* Well done, friend! Rats are gone, cellar's safe.
Here's your coin, well earned. Drink's on the house tonight.
*pauses* You say you found old tunnels down there? Interesting...
tags:
- starter
- combat
- exploration

View File

@@ -0,0 +1,109 @@
# Missing Tools - Simple fetch quest for new players
quest_id: quest_missing_tools
name: "The Blacksmith's Missing Tools"
description: |
Hilda the blacksmith's best hammers and tongs have gone missing.
She suspects they were stolen by mischievous goblins who've been
spotted near the forest edge.
difficulty: easy
# NPC Quest Givers
quest_giver_npc_ids:
- npc_blacksmith_hilda
quest_giver_name: "Hilda Stoneforge"
# Location context
location_id: crossville_forge
region_id: crossville
# Offering conditions
offering_triggers:
location_types: ["town", "shop"]
specific_locations: ["crossville_forge", "crossville_village"]
min_character_level: 1
max_character_level: 4
required_quests_completed: []
probability_weights:
town: 0.25
shop: 0.30
# NPC-specific offer dialogue
npc_offer_dialogues:
npc_blacksmith_hilda:
dialogue: |
*sighs heavily* Some thieving little beasts made off with me
best tools last night. Saw goblin tracks leading toward the
forest. Can't do proper work without 'em. Help me out?
conditions:
min_relationship: 20
required_flags: []
forbidden_flags: []
# What NPCs know about this quest
npc_quest_knowledge:
npc_blacksmith_hilda:
- "The tools were passed down from her father"
- "Goblins have been more active lately near the forest"
- "She heard strange noises two nights ago but thought it was just animals"
- "The tools are distinctive - marked with the Stoneforge family crest"
# Embedded lore
lore_context:
backstory: |
The Stoneforge family has been the village's blacksmiths for
four generations. Hilda's tools are not just valuable - they're
family heirlooms with sentimental worth.
world_connections:
- "Goblins typically avoid settlements unless driven by something"
- "Recent disturbances in the region have made all creatures more bold"
regional_hints:
- "Goblin warrens exist in the rocky hills east of the forest"
- "The Stoneforge family once forged weapons for the village militia"
# Narrative hooks
dialogue_templates:
narrative_hooks:
- "mentions being unable to fill orders without proper tools"
- "looks frustrated at a half-finished project"
- "grumbles about creatures getting bolder"
- "offers a discount on future work as additional thanks"
ambient_hints:
- "You notice the forge is quieter than usual"
- "Several half-finished weapons sit abandoned on workbenches"
# Objectives
objectives:
- objective_id: track_goblins
description: "Follow the goblin tracks into the forest"
objective_type: travel
required_progress: 1
target_location_id: forest_goblin_camp
- objective_id: recover_tools
description: "Recover Hilda's stolen tools"
objective_type: collect
required_progress: 1
target_item_id: stoneforge_tools
# Rewards
rewards:
gold: 35
experience: 75
items: []
relationship_bonuses:
npc_blacksmith_hilda: 15
unlocks_quests: []
reveals_locations: ["forest_goblin_camp"]
# Completion dialogue
completion_dialogue:
npc_blacksmith_hilda: |
*eyes light up* My tools! You found them! By the ancestors,
I thought they were gone forever. Here's your coin, and know
that you've got a friend at the Stoneforge. Come by anytime
you need gear - I'll give you the family discount.
tags:
- starter
- fetch
- exploration