Files
Code_of_Conquest/docs/ROADMAP.md
2025-11-24 23:10:55 -06:00

30 KiB
Raw Blame History

Code of Conquest - Implementation Roadmap

Project: Code of Conquest (AI Dungeon Master) Last Updated: November 15, 2025 Status: Active Development


Development Philosophy

Workflow: Brainstorm → Design → Code → Revise

Principles:

  • Build incrementally (MVP first, then expand)
  • Test each phase before moving forward
  • Security and cost control from day one
  • Manual testing preferred for most features
  • Focus on core gameplay before polish

Phase 0: Foundation (Week 1-2) COMPLETE

Goal: Set up development environment and project structure

Tasks

Task Priority Status Notes
Initialize git repository High Set up dev/beta/master branches
Create project structure High /app, /config, /tests, /static, /templates
Set up virtual environment High python3 -m venv venv
Create requirements.txt High Pin version ranges for all dependencies
Configure .env and .env.example High API keys, secrets, config
Set up Docker Compose (local) High Redis container
Configure Appwrite project High Create project, get credentials
Set up Appwrite collections High users, characters, game_sessions, marketplace_listings, transactions
Configure logging (structlog) Medium Centralized logging setup
Create config loader Medium YAML config + typed dataclass
Write API response wrapper Medium Standardized JSON response format
Set up Flask app factory High app/__init__.py

Deliverable: Fully configured development environment, ready for coding


Phase 1: Core Data Models (Week 3) COMPLETE

Goal: Implement all core dataclasses and serialization

Tasks

Task Priority Status Notes
Implement Stats dataclass High Include computed properties (HP, MP)
Implement Item dataclass High All item types
Implement Effect dataclass High BUFF, DEBUFF, DOT, HOT, STUN, SHIELD
Implement SkillNode dataclass High With prerequisite checking
Implement SkillTree dataclass High With can_unlock() method
Implement PlayerClass dataclass High Base stats + skill trees
Implement Character dataclass High to_json(), from_json(), get_effective_stats()
Implement Combatant dataclass High For combat encounters
Implement CombatEncounter dataclass High Combat state management
Implement SessionConfig dataclass High Session settings
Implement GameSession dataclass High Full session state
Implement MarketplaceListing dataclass Medium Auction + fixed price
Write unit tests for dataclasses High 68 tests passing, >80% coverage

Deliverable: Complete data model layer with tests - All 68 tests passing!

Phase 1 Implementation Summary

What Was Built:

  • 10 data model files in /app/models/:
    • enums.py - 9 enum types for type safety
    • stats.py - Stats with computed properties (HP, MP, defense, resistance)
    • effects.py - 6 effect types (BUFF, DEBUFF, DOT, HOT, STUN, SHIELD) with stacking
    • abilities.py - Ability system with YAML loader (data-driven design)
    • items.py - Items (weapons, armor, consumables, quest items)
    • skills.py - SkillNode, SkillTree, PlayerClass
    • character.py - Character with get_effective_stats() (single source of truth)
    • combat.py - Combatant, CombatEncounter with turn-based flow
    • session.py - GameSession, SessionConfig, GameState, ConversationEntry
    • marketplace.py - MarketplaceListing, Bid, Transaction, ShopItem

Test Coverage:

  • 68 tests across 4 test files, all passing
  • test_stats.py - 12 tests for Stats dataclass
  • test_effects.py - 17 tests for all effect types
  • test_character.py - 20 tests including get_effective_stats()
  • test_combat_simulation.py - 19 tests including full combat flow

Key Design Decisions Made:

Decision Rationale
Abilities from YAML Data-driven design for easy balancing without code changes
Effect stacking capped at max_stacks Prevents infinite stacking abuse (default 5, configurable)
Duration refreshes on re-application Simpler than cumulative duration, more predictable
Shield damage absorption Fully implemented with partial/complete absorption logic
Critical hits only No damage variance = deterministic damage except crits (JRPG-style)
Stat minimum clamped at 1 Debuffs can't reduce stats below 1 (prevents zero/negative stats)
Single source of truth Character.get_effective_stats() combines all modifiers (base + equip + skills + effects)

Combat System Features:

  • Deterministic damage calculation with stat scaling
  • 6 effect types with tick() processing
  • Shield absorption before HP damage
  • Effect stacking with configurable caps
  • Turn-based initiative system
  • Mana costs and ability cooldowns
  • Full combat simulation tested

Data Serialization:

  • All models have to_dict() / from_dict() methods
  • Enums serialize to .value strings
  • JSON-compatible for Appwrite storage
  • Round-trip serialization tested

Documentation Updated:

  • DATA_MODELS.md - Added Ability, AbilityLoader, Enums, expanded Effect/Character
  • GAME_SYSTEMS.md - Added Ability System section, clarified effect stacking, shields, crits
  • ARCHITECTURE.md - Updated models directory structure

Phase 2: Authentication & User Management (Week 4) COMPLETE

Goal: Implement user authentication via Appwrite

Tasks

Task Priority Status Notes
Set up Appwrite service wrapper High app/services/appwrite_service.py
Implement login endpoint High POST /api/v1/auth/login
Implement register endpoint High POST /api/v1/auth/register
Implement logout endpoint High POST /api/v1/auth/logout
Implement email verification High GET /api/v1/auth/verify-email
Implement password reset High POST /api/v1/auth/forgot-password, POST /api/v1/auth/reset-password
Create JWT token middleware High Verify tokens on protected routes
Implement user tier/subscription check High Free/Basic/Premium/Elite
Create auth decorators High @require_auth, @require_tier(), @require_email_verified
Write auth tests Medium Manual API testing with docs/API_TESTING.md
Create login page template Medium templates/auth/login.html with HTMX
Create register page template Medium templates/auth/register.html with password strength
Create password reset templates Medium templates/auth/forgot_password.html, reset_password.html
Create base template Medium templates/base.html with RPG/fantasy theme
Create main stylesheet Medium static/css/main.css with approved dark slate theme

Deliverable: Complete authentication system with email verification, password reset, and RPG-themed UI


Phase 3: Character System (Week 5-6) COMPLETE

Goal: Character creation, management, and skill system

Tasks

Task Priority Status Notes
Define all 8 player classes High Using reference data from data files
Design skill trees (2 per class) High Loaded from YAML data files
Implement character CRUD API High 7 endpoints: create, get, list, delete, unlock skill, respec
Implement classes/origins API High 3 endpoints: list classes, get class, list origins
Implement skill unlock endpoint High POST /api/v1/characters/<id>/skills/unlock
Implement skill respec endpoint Medium POST /api/v1/characters/<id>/skills/respec
Implement effective stats calculation High In Character dataclass from Phase 1
Write character system tests Medium 18 integration tests in test_api_characters_integration.py
Create API testing doc Medium docs/API_TESTING.md with character endpoints
Create character creation UI High 4-step flow: origin → class → customize → confirm
Create character list UI High Show all user's characters with tier limits
Create character detail UI High Stats, inventory, equipment display

Deliverable: Full character creation and management system (API + UI complete)

Progress: 12/12 tasks complete (100%)

Note: Skill tree visualization UI moved to Phase 5 (Combat System) where it will be implemented alongside combat abilities.


Phase 4: AI Integration + Story Progression System (Week 7-9) 🎯 NEXT PHASE

Goal: Integrate AI narrative generation and implement turn-based story progression with quest system

Total Tasks: 45 tasks across 3 weeks (~126 hours) Implementation Details: See api/docs/PHASE4_IMPLEMENTATION.md for granular task breakdowns, code examples, and verification steps.

Overview

Phase 4 delivers the core single-player gameplay experience where players interact with the AI Dungeon Master through button-based actions. This phase includes AI infrastructure, story progression, and the quest system.

Week 7: AI Engine Foundation (15 tasks)

Task Groups:

  • Group 1: Redis & RQ Infrastructure (4 tasks)
  • Group 2: AI API Clients (4 tasks)
  • Group 3: Prompt Templates & Narrative Generation (4 tasks)
  • Group 4: Usage Tracking & Cost Controls (3 tasks)
Task ID Task Status Notes
7.1 Set up Redis service wrapper Connection pooling, TTL support
7.2 Configure RQ job queues ai_tasks, combat_tasks, marketplace_tasks
7.3 Create base AI task job structure Status tracking, retry logic
7.4 Checkpoint: Verify Redis/RQ Integration test
7.5 Implement Replicate API client Llama-3 8B for free tier
7.6 Implement Anthropic API client Haiku/Sonnet/Opus support
7.7 Implement model selector Tier-based routing
7.8 Checkpoint: Verify all models Test each AI model
7.9 Create Jinja2 prompt templates 4 core templates
7.10 Implement narrative generator High-level generation API
7.11 Build AI task jobs Async processing with Appwrite
7.12 Checkpoint: E2E AI flow Full job lifecycle test
7.13 Implement AI usage tracking Log tokens, costs to Appwrite
7.14 Implement daily limit checks Per-tier rate limiting
7.15 Set up cost monitoring & alerts Daily cost reports, email alerts

Deliverable: Working AI narrative generation with tier-based models and cost controls

Week 8: Story Progression System (16 tasks)

Task Groups:

  • Group 5: Action Prompts & Data Layer (4 tasks)
  • Group 6: Session Management (5 tasks)
  • Group 7: Story API Endpoints (4 tasks)
  • Group 8: Story UI & Integration (3 tasks)
Task ID Task Status Notes
8.16 Create ActionPrompt dataclass Tier/context filtering
8.17 Create 10 action prompts in YAML Free(4), Premium(+3), Elite(+3)
8.18 Implement ActionPromptLoader YAML loading and filtering
8.19 Checkpoint: Verify action filtering Test tier/context logic
8.20 Extend GameSession for solo play Add state tracking fields
8.21 Implement SessionService Create/load/update sessions
8.22 Add conversation history management History CRUD methods
8.23 Add game state tracking Location, quests, events
8.24 Checkpoint: Verify persistence Test Appwrite storage
8.25 Implement create session endpoint POST /api/v1/sessions
8.26 Implement take action endpoint POST /sessions/{id}/action (async)
8.27 Implement get session state endpoint GET /api/v1/sessions/{id}
8.28 Implement get history endpoint GET /sessions/{id}/history
8.29 Create story gameplay template HTMX-powered UI
8.30 Build action button UI Tier filtering, custom input
8.31 Checkpoint: Full integration test Complete story turn flow

Deliverable: Complete turn-based story progression with button-based actions

Week 9: Quest System (14 tasks)

Task Groups:

  • Group 9: Quest Data Models (3 tasks)
  • Group 10: Quest Content & Loading (4 tasks)
  • Group 11: Quest Offering & Management (4 tasks)
  • Group 12: Quest UI & Final Testing (3 tasks)
Task ID Task Status Notes
9.32 Create Quest dataclasses Quest, Objective, Reward, Triggers
9.33 Create QuestTriggers with offering logic Location/level-based eligibility
9.34 Checkpoint: Verify serialization Test round-trip to JSON
9.35 Create quest YAML schema Document in QUEST_SYSTEM.md
9.36 Write 10 example quests 4 easy, 3 medium, 2 hard, 1 epic
9.37 Implement QuestService YAML loading, filtering
9.38 Checkpoint: Verify quest loading Test all 10 quests load
9.39 Implement context-aware offering Probability + AI selection
9.40 Integrate offering into story turns Check after each action
9.41 Implement quest accept endpoint POST /api/v1/quests/accept
9.42 Implement quest complete endpoint Rewards, level up check
9.43 Create quest tracker sidebar UI Active quests display
9.44 Create quest offering modal UI Accept/decline interface
9.45 Final Checkpoint: Full integration Complete quest lifecycle

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

Phase 4 Success Criteria

  • AI clients for Anthropic and Replicate functional
  • Tier-based model selection working (Free→Replicate, Premium→Sonnet, etc.)
  • Cost tracking and daily limits enforced
  • 10 action prompts defined and loadable from YAML
  • Solo session creation and management working
  • Story turn flow functional (action → AI response → state update)
  • Conversation history persisted and displayed
  • Tier restrictions enforced (Free: 4 buttons, Premium: 7 + free-form, Elite: 10 + free-form)
  • 10 example quests defined in YAML
  • Quest offering logic working (context-aware + location-based)
  • Quest tracking and completion functional
  • Max 2 active quests enforced

Estimated Timeline: ~126 hours (~16 days of focused work)


Phase 5: Combat System + Skill Tree UI (Week 10-11)

Goal: Turn-based combat with AI narration + skill tree visualization

Note: Combat reuses the turn-based infrastructure built in Phase 4 (story progression). The main additions are damage calculation, effect processing, combat-specific UI, and the skill tree visualization deferred from Phase 3.

Tasks

Task Priority Status Notes
Implement damage calculator High Physical, magical, critical
Implement effect processor High Tick effects, apply damage
Implement combat engine High Turn order, action processing
Implement initiative system High d20 + speed rolls
Implement combat API endpoints High Attack, cast, item, defend
Implement combat state management High Start, process, end combat
Implement AI combat narration High Generate descriptions for actions
Create loot generator Medium Random loot by tier
Implement XP/leveling Medium Award XP, level up characters
Create combat UI High templates/game/combat.html
Create combat action UI High Buttons for attack/spell/item
Create skill tree UI High templates/character/skills.html - Dual tree display (from Phase 3)
Implement skill node visualization High Show 5 tiers × 2 nodes per tree, locked/available/unlocked states
Implement skill unlock UI High Click to unlock with HTMX, prerequisite validation
Implement respec UI Medium Respec button with confirmation modal (costs gold)
Write combat tests High Test damage, effects, flow
Write skill tree UI tests Medium Test unlock flow, respec, validation

Deliverable: Fully functional combat system + interactive skill tree UI

Total Tasks: 17 tasks (12 combat + 5 skill tree UI)


Phase 6: Multiplayer Sessions (Week 12-13)

Goal: Invite-based, time-limited co-op sessions for Premium/Elite players

Note: Multiplayer is a paid-tier feature focused on short co-op adventures. Unlike solo story progression, multiplayer sessions are time-limited (2 hours), invite-based, and combat-focused.

Key Features:

  • Premium/Elite tier only
  • Shareable invite links
  • 2-4 player parties
  • 2-hour session duration
  • AI-generated custom campaigns
  • Realtime synchronization
  • Character snapshots (doesn't affect solo campaigns)

See: MULTIPLAYER.md for complete specification

Week 12: Core Multiplayer Infrastructure (Days 1-7)

Task Priority Status Notes
Create MultiplayerSession dataclass High Extends GameSession with time limits, invite codes
Create PartyMember dataclass High Player info, character snapshot
Create MultiplayerCampaign models High Campaign, CampaignEncounter, CampaignRewards
Implement invite code generation High 8-char alphanumeric, unique, 24hr expiration
Implement session creation API High POST /api/v1/sessions/multiplayer/create (Premium/Elite only)
Implement join via invite API High GET/POST /api/v1/sessions/multiplayer/join/{invite_code}
Implement lobby system High Ready status, player list, host controls
Implement 2-hour timer logic High Session expiration, warnings (10min, 5min, 1min), auto-end
Set up Appwrite Realtime High WebSocket subscriptions for live session updates
Write unit tests Medium Invite generation, join validation, timer logic

Week 13: Campaign Generation & Combat (Days 8-14)

Task Priority Status Notes
Implement AI campaign generator High Generate 3-5 encounters based on party composition
Create campaign templates Medium Pre-built campaign structures for AI to fill
Implement turn management High Initiative, turn order, action validation for multiplayer
Implement multiplayer combat flow High Reuse Phase 5 combat system, add multi-player support
Implement disconnect handling High Auto-defend mode, host promotion on disconnect
Implement reward distribution High Calculate and grant rewards at session end
Create lobby UI High templates/multiplayer/lobby.html - Player list, ready status, invite link
Create active session UI High templates/multiplayer/session.html - Timer, party status, combat, narrative
Create session complete UI High templates/multiplayer/complete.html - Rewards, stats, MVP badges
Write integration tests High Full session flow: create → join → play → complete
Test realtime synchronization High Multiple browsers simulating party gameplay
Test session expiration Medium Force expiration, verify cleanup and reward distribution

Deliverable: Working invite-based multiplayer system with time-limited co-op campaigns

Total Tasks: 22 tasks across 2 weeks


Phase 7: NPC Shop (Week 12)

Goal: Basic economy and item purchasing

Tasks

Task Priority Status Notes
Define shop inventory High Items, prices, categories
Implement shop browse API High GET /api/v1/shop/items
Implement shop purchase API High POST /api/v1/shop/purchase
Implement transaction logging Medium Record all purchases
Create shop UI High templates/shop/index.html
Test shop purchases Medium Verify gold deduction, item add

Deliverable: Working NPC shop system


Phase 8: Marketplace (Week 13-14)

Goal: Player-to-player trading (Premium+ only)

Tasks

Task Priority Status Notes
Implement marketplace browse API High Filtering, sorting, pagination
Implement listing creation API High Auction + fixed price
Implement bidding API High Validate bid amounts
Implement buyout API High Instant purchase
Implement listing cancellation Medium Return item to seller
Implement auction processing task High Periodic job to end auctions
Implement bid notifications Medium Realtime outbid alerts
Implement my listings/bids API Medium User's active listings/bids
Create marketplace browse UI High templates/marketplace/browse.html
Create listing detail UI High Show item, bids, auction timer
Create listing creation UI High Form for creating listings
Test auction flow High Full auction cycle
Test tier restrictions High Verify Premium+ only

Deliverable: Working marketplace system


Phase 9: Frontend Polish (Week 15-16)

Goal: Improve UI/UX, add HTMX interactivity

Tasks

Task Priority Status Notes
Design CSS theme High Dark fantasy aesthetic
Implement responsive design High Mobile-friendly
Add HTMX for dynamic updates High No full page reloads
Create reusable components Medium Character cards, inventory, etc.
Add loading states Medium Spinners for AI calls
Add error messaging High User-friendly error displays
Implement dice roll animations Low static/js/dice-roller.js
Add combat animations Low Visual feedback for actions
Create base template High templates/base.html
Test UI across browsers Medium Chrome, Firefox, Safari

Deliverable: Polished, interactive UI


Phase 10: PWA & Deployment (Week 17-18)

Goal: Deploy to production as PWA

Tasks

Task Priority Status Notes
Create PWA manifest High static/manifest.json
Create service worker High sw.js for offline support
Create PWA icons High Various sizes
Set up production environment High Server, domain, SSL
Configure Nginx High Reverse proxy
Configure Gunicorn High 4+ workers
Set up RQ workers (production) High Separate instances
Set up Redis (production) High Standalone or cluster
Configure monitoring High Sentry, uptime monitoring
Set up backup system High Daily Appwrite backups
Create deployment scripts High scripts/deploy.sh
Write deployment documentation Medium Update DEPLOYMENT.md
Perform security audit High Check all endpoints
Load testing Medium Test concurrent users
Deploy to production High Go live!

Deliverable: Live production deployment


Phase 11: Beta Testing & Iteration (Week 19-20)

Goal: Gather feedback and fix issues

Tasks

Task Priority Status Notes
Recruit beta testers High 10-20 users
Create feedback form High Bug reports, suggestions
Monitor error logs High Daily Sentry review
Monitor AI costs High Track spending
Fix critical bugs High Priority: game-breaking issues
Balance combat Medium Adjust damage, HP, difficulty
Balance economy Medium Gold rates, item prices
Optimize performance Medium Reduce latency
Improve AI prompts Medium Better narrative quality
Update documentation Medium Based on learnings

Deliverable: Stable, tested system ready for launch


Phase 12: Launch Preparation (Week 21-22)

Goal: Marketing, final polish, and launch

Tasks

Task Priority Status Notes
Create landing page High Marketing site
Write user documentation High How to play guide
Set up payment system High Stripe integration for subscriptions
Implement subscription tiers High Free/Basic/Premium/Elite
Create privacy policy High Legal requirement
Create terms of service High Legal requirement
Set up analytics Medium Track user behavior
Create social media accounts Medium Twitter, Discord, etc.
Write launch announcement Medium Blog post, social media
Set up support system Medium Email, Discord, or ticketing
Final security review High Penetration testing
Final performance review High Load testing
Launch! High Public release

Deliverable: Public launch of Code of Conquest


Future Phases (Post-Launch)

Phase 13: Content Expansion

  • Additional player classes (Monk, Druid, Warlock, Artificer)
  • New locations and quests
  • More items and equipment
  • Seasonal events

Phase 14: Advanced Features

  • Guild system
  • PvP arena
  • Crafting system
  • Achievement system
  • World events

Phase 15: Mobile Apps

  • Native iOS app
  • Native Android app
  • Mobile-specific UI optimizations

Risk Management

Risk Impact Probability Mitigation
AI costs exceed budget High Medium Daily monitoring, strict tier limits, cost alerts
Appwrite service issues High Low Backup plan to self-host, regular backups
Low user adoption Medium Medium Beta testing, marketing, community building
Performance issues Medium Medium Load testing, horizontal scaling, caching
Security vulnerabilities High Low Regular audits, security-first development
Feature creep Medium High Stick to roadmap, resist scope expansion

Success Metrics

MVP Success (End of Phase 10)

  • 50+ beta users
  • < 3s average API response time
  • < $500/month AI costs
  • 99% uptime
  • < 5% error rate

Launch Success (End of Phase 12)

  • 500+ registered users
  • 100+ paying subscribers
  • Positive user reviews
  • Profitable (revenue > costs)
  • Active community (Discord, etc.)

Long-term Success (6 months post-launch)

  • 5,000+ registered users
  • 1,000+ paying subscribers
  • Monthly content updates
  • Growing user base
  • Sustainable business model

Notes

Current Status: Phase 3 COMPLETE (100%) | Phase 4 🎯 READY TO START Last Completed: Phase 3 - Character System (creation, management, APIs, UI) - November 16, 2025 Next Milestone: Phase 4 - AI Integration + Story Progression + Quest System (Weeks 7-9, 21 days) Estimated MVP Completion: End of Phase 10 (~20 weeks / 5 months) Estimated Launch: End of Phase 12 (~24 weeks / 6 months)

Important Notes:

  • Phase 3 is 100% complete. Skill tree UI deferred to Phase 5 (Combat System).
  • Phase 4 is the next active development phase (AI engine + story progression + quests).
  • Phase 4 expanded from 1 week to 3 weeks to include complete story gameplay loop.
  • Overall timeline extended by 2 weeks from original estimate.

Update Frequency: Review and update roadmap weekly during development


Changelog

Date Change By
2025-11-14 Initial roadmap created Claude
2025-11-14 Phase 2 (Authentication & User Management) completed User/Claude
2025-11-15 Phase 3 Character API layer completed (10 endpoints) Claude
2025-11-15 Documentation updated: API_REFERENCE.md, API_TESTING.md Claude
2025-11-16 Phase 3 Integration tests completed (18 comprehensive tests) Claude
2025-11-16 API_TESTING.md updated with correct endpoint paths and formats Claude
2025-11-16 Database migrated from Documents API to TablesDB API User/Claude
2025-11-16 Authentication flow fixed (session secrets, cookies, user model) User/Claude
2025-11-16 Phase 3 Character Creation UI completed (4-step HTMX flow) User/Claude
2025-11-16 Phase 3 Character Management UI completed (list, detail pages) User/Claude
2025-11-16 Phase 3 COMPLETE - Character system fully functional User/Claude
2025-11-16 Created STORY_PROGRESSION.md - Turn-based story gameplay system Claude
2025-11-16 Created QUEST_SYSTEM.md - YAML-driven quest system with context-aware offering Claude
2025-11-16 Expanded Phase 4 from 1 week to 3 weeks (AI + Story + Quests) Claude
2025-11-16 Adjusted Phases 5-6 timeline (+2 weeks overall to MVP) Claude
2025-11-16 Created MULTIPLAYER.md - Invite-based, time-limited co-op system specification Claude
2025-11-16 Revised Phase 6: Multiplayer now paid-tier only, 2-hour sessions, AI campaigns Claude
2025-11-16 Phase 3 marked as 100% complete - Skill tree UI moved to Phase 5 User/Claude
2025-11-16 Phase 5 updated to include skill tree UI (5 additional tasks) User/Claude
2025-11-16 Phase 4 set as next active development phase (READY TO START) User/Claude