API Documentation

This document describes the internal API of openRoads for developers who want to extend or modify the game.

World Management API

Loading the World

func LoadWorld() map[string]*Room

Loads the game world from the JSON file and returns a map of room IDs to Room objects.

Saving the World

func SaveWorld(worldData map[string]*Room) error

Saves the current state of the game world to the JSON file.

Room Structure

type Room struct {
    Short   string                   // Short description
    Long    string                   // Long description
    Exits   map[string]string        // Map of directions to room IDs
    Items   []map[string]interface{} // Items in the room
    Players []string                 // Players in the room
}

Player Management API

Getting a Player

Retrieves a player object based on the session.

Getting a User by Client Name

Looks up a user by their client name and returns the user object if found.

User Structure

Player Structure

Session Management API

Session Structure

Configuration API

Loading Configuration

Loads the configuration from the specified file.

Getting Configuration

Returns the currently loaded configuration.

Configuration Structure

Background Routines API

Starting the Engine

Initializes and runs all necessary background processes for the game.

Scheduling Cleanup

Schedules periodic cleanup operations.

Nightly Cleanup

Performs the actual cleanup operations.

Last updated

Was this helpful?