Development Guide

This guide provides information for developers who want to contribute to or modify openRoads.

Development Environment Setup

  1. Install Go 1.23 or later

  2. Clone the repository:

    git clone https://gitlab.phospher.com/darkhorse7881/openroads.git
  3. Navigate to the project directory:

    cd openroads
  4. Install dependencies:

    go mod download

Project Structure

openroads/
β”œβ”€β”€ config/             # Configuration handling
β”œβ”€β”€ dev_tools/          # Development utilities
β”œβ”€β”€ lib/                # Core game libraries
β”œβ”€β”€ routines/           # Background processes
β”œβ”€β”€ world/              # Game world data
β”œβ”€β”€ server.go           # Server implementation
└── xroads.go           # Main entry point

Key Components

Main Entry Point (xroads.go)

The xroads.go file contains the main function and initializes the game:

  • Sets up command-line flags

  • Initializes world files

  • Starts background routines

  • Launches the game server

Server (server.go)

The server component handles:

  • Client connections

  • Session management

  • Command routing

Libraries (lib/)

  • player.go: Player data and actions

  • ui.go: User interface and terminal handling

  • world.go: World data management

Routines (routines/)

  • cleanup.go: World cleanup operations

  • engine.go: Game engine and background processes

Adding New Features

Adding a New Command

  1. Locate the command handler in lib/ui.go

  2. Add a new case to the switch statement:

Adding a New Room Type

  1. Modify the Room struct in lib/world.go if needed

  2. Add the new room to world/formatted_rooms.json

  3. Implement any special behavior in the appropriate handler

Adding a New Game Mechanic

  1. Identify which component should handle the mechanic

  2. Implement the core logic in the appropriate file

  3. Add any necessary UI elements or commands

  4. Update documentation to reflect the new feature

Building and Testing

Building the Project

Running Tests

Creating a Release

Use the provided script to create a new release:

This will:

  1. Create a Git tag

  2. Push the tag to GitLab

  3. Trigger the CI/CD pipeline to build binaries

  4. Create a release on GitLab with the binaries attached

Last updated

Was this helpful?