Skip to content

Latest commit

 

History

History
98 lines (79 loc) · 2.6 KB

File metadata and controls

98 lines (79 loc) · 2.6 KB

Phase 6: Integration & Testing

Overview

Phase 6 completes the Timeloop game server by wiring all components together and providing sample test data.

Implementation

Main Application (main.rs)

  • Async Runtime: Tokio-based async main function
  • Logging: Tracing subscriber with INFO level logging
  • AppState: Shared application state with:
    • Arc<RwLock<Option>> for concurrent access
    • GameDefinitionsLoader for game data
    • SaveManager for character persistence
  • Router: Axum router with:
    • CORS middleware (allow all origins for development)
    • Tracing middleware for request logging
    • All API routes from Phase 5
  • Server: Listening on 127.0.0.1:3000

Sample Test Data

Located in game_data/core/:

attributes.json

  • Physical (base: 10, training_difficulty: 100)
  • Mental (base: 10, training_difficulty: 100)
  • Social (base: 10, training_difficulty: 120)

affinities.json

  • Hand-to-Hand Combat (+5 Physical)
  • Psionic (+5 Mental)
  • Business (+5 Social)

effects.json

  • Training Boost (+2 Physical, +2 Mental, 100 ticks)
  • Physical Weakness (-3 Physical, 50 ticks)
  • Social Charm (+4 Social, 200 ticks)

Verification

# Build and verify
cargo build
cargo clippy -- -D warnings -A dead_code

# Run server
cargo run

# Server starts on http://127.0.0.1:3000
# Health check: http://127.0.0.1:3000/health
# API endpoints: http://127.0.0.1:3000/api/*

API Endpoints

Game Management

  • POST /api/game/new - Create new game
  • GET /api/game/current - Get current game state
  • POST /api/game/tick - Advance game by N ticks
  • POST /api/game/save - Save current game
  • GET /api/game/saves - List all saved games

Character Actions

  • POST /api/game/train - Start/stop attribute training
  • POST /api/game/acquire_affinity - Acquire new affinity

Game Definitions

  • GET /api/definitions/attributes - List all attributes
  • GET /api/definitions/affinities - List all affinities
  • GET /api/definitions/effects - List all effects

System

  • GET /health - Health check

Architecture Integration

HTTP Request
    ↓
[Axum Router + Middleware]
    ↓
[API Handlers] → AppState
    ↓
[Game Engine] → GameState
    ↓
[Data Models] → Instances/Definitions
    ↓
[Storage Layer] → JSON Files

Quality Gates

✅ cargo build - Passes with warnings (dead code) ✅ cargo clippy -- -D warnings -A dead_code - Passes ✅ Server starts successfully ✅ Logging initialized and operational

Status

Phase 6: Complete

All components from Phases 1-5 are now integrated into a working REST API server with sample test data.