Skip to content

Conversation

Copy link

Copilot AI commented Sep 21, 2025

Implements a comprehensive REST API server that exposes Roam game world and player data to external client applications, fulfilling the requirement to allow external applications to access world data for mapping, world viewing, and other companion applications.

Changes Made

  • REST API Server: Created a threaded HTTP server using Python's built-in http.server module that runs alongside the game without affecting performance
  • World Data Endpoints:
    • GET /world - General world information including current room and tick count
    • GET /world/rooms - List of all loaded rooms with entity counts
    • GET /world/room/{x}/{y} - Detailed room data including entities and living entities
  • Player Data Endpoints:
    • GET /player - Player status, energy, location, and movement state
    • GET /player/inventory - Complete inventory contents with item quantities
    • GET /player/stats - Player statistics and movement attributes
  • Integration: Seamlessly integrated with the main game loop, automatically starting when the world screen initializes and stopping on game exit
  • Error Handling: Comprehensive error responses with appropriate HTTP status codes
  • CORS Support: Enables cross-origin requests for web applications
  • Documentation: Complete API documentation with examples and use cases

Technical Implementation

  • Server runs on localhost:8080 by default in a separate daemon thread
  • All responses are JSON formatted with proper content-type headers
  • Real-time data access to live game state
  • Graceful error handling for missing rooms, invalid coordinates, and server errors
  • Added accessor methods to WorldScreen class for API data access

Testing

  • ✅ Comprehensive unit tests for all API endpoints and data extraction methods
  • ✅ Mock-based testing ensures API logic works correctly
  • ✅ Error handling validation for edge cases
  • ✅ Integration tests verify server lifecycle management

Use Cases Enabled

This API enables development of:

  • World viewer applications showing real-time game state
  • Interactive mapping tools displaying room layouts and entities
  • Statistics dashboards for monitoring game progress
  • Development and debugging tools
  • Mobile or web companion applications

The implementation provides a robust foundation for external applications to extend Roam's functionality while maintaining clean separation between the game engine and external integrations.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@dmccoystephenson
Copy link
Member

@copilot Try again

@dmccoystephenson
Copy link
Member

@copilot Continue work on this

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Author

Copilot AI commented Sep 22, 2025

@copilot Continue work on this

I've implemented a comprehensive REST API for the Roam game that exposes world and player data to external client applications. The implementation includes:

Key Features:

  • World data endpoints (current room, all rooms, specific room details)
  • Player data endpoints (general info, inventory, stats)
  • Real-time data access during gameplay
  • CORS support for web applications
  • Comprehensive error handling

Endpoints Available:

  • GET /world - General world information
  • GET /world/rooms - List of loaded rooms
  • GET /world/room/{x}/{y} - Specific room data
  • GET /player - Player information
  • GET /player/inventory - Player inventory
  • GET /player/stats - Player statistics

The API server automatically starts when entering the game world and runs on localhost:8080. I've included tests, documentation, and integrated it cleanly with the existing codebase.

Commit: f519f9f

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] @Preponderous-Software/roam-prototype/issues/231 Implement REST API endpoints for external world data access Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants