Future Terminal

Mechanics

Buildings

Buildings are critical to help you progress through the technology tree. If you lose all your buildings, it's game over.

Units

Units are an important part of extending your influence. Units are used for economy and military purposes.

Resources

Harvest Ore with workers and return it to your Hub.

Process Ore into Metal.

Use Metal to build basic units like workers and soldiers to expand your economy and military.

Gather more advanced resources and use them to build custom modular units to adapt to any situation.

Earth-based players must first demonstrate competency before working with more complex resources.

Population limit

Your population limit is determined by the number of hubs and other personnel buildings you have.

Vision

Your units and buildings provide vision around them in a moderate area. There may be some delay due to satellite uplink.


Websocket -- mode one

For precise control over units and buildings, you should establish a websocket connection.

  1. Send connect to the server
  2. Server responds with `PlayerConnected`
  3. Send `PlayerId` with your playerId, password, and colour
  4. Send `GetSync` with your playerId
  5. Send `SpawnBuilding` with building info
  6. Send `SpawnUnit` with unit info
  7. Send `Action` with its info
  8. Send `GetOres` with your playerId

Handle the following events for a complete experience

Let's launch and then link to Redoc here.

HTTP -- mode two

For one-off or rare commands like key building construction, a simple HTTP request may be sufficient.

Let's launch and then link to Redoc here.

CLI -- mode three

For interactive debugging or analysis, a CLI may be useful.

Let's launch and then link to Redoc here.

Code editor -- mode four

Here's how you can code

All of the below is probably too complicated for now.

The code editor is a simple JavaScript editor with a few features to help you.

Your code should take the following shape:


// To make your code run, return an object with `start`, `step`, and `stop` that the Future Terminal client can call
function myCode() {
  var api;
  var tick = function () {
    // Your code goes here!
  };
  var codeVersion = new Date().toLocaleString();
  return {
    start: function () {
      var now = new Date().toLocaleString();
      console.log("User code ".concat(codeVersion, " is starting at ").concat(now));
      if (!api) {
        api = window.api;
      }
    },
    step: function () {
      return tick();
    },
    stop: function () {
      var now = new Date().toLocaleString();
      console.log( "User code ".concat(codeVersion, " is stopping at ").concat(now));
    }
  };
}
      

API

Here's what you're coding with

When you're using the client editor, the main object to code against is found at window.api.

Some functions run locally and have no costs. Other functions are sent to the server and so have a cost or delay associated with them. Any function that is a server command might silently fail: your code will continue to run, but the command will not be accepted by the server.

Make sure your code handles this gracefully.

Local commands

These functions run locally and have no costs. But their data might be a little bit out of date.

Function Description
getOres() Get all ores
getUnits() Get all your units
getBuildingsByType(buildingType) Get your buildings by type
getUnitsByType(unitType) Get your units by type
getEnemyUnits() Get enemy units
getEnemyBuildings() Get enemy buildings
distanceBetweenEntities(a, b) Get the distance between two entities
distanceBetween(x1, y1, x2, y2) Get the distance between two entities within a range
getNearest(entities, x1, y1) Get the nearest entity to a point
getNearestWithinRange(entities, x1, y1, range) Get the nearest entity to a point within a range

Server commands

These functions are sent to the server as requests and have a cost or delay associated with them. They might silently fail.

Function Description
move(a, x, y) Try to move a unit to a point
mine(a, ore) Try to mine an ore
load(a, hub) Try to load ore into a building
spawnBuilding(buildingType, x, y) Try to spawn a building
spawnWorker(x, y) Try to spawn a worker
spawnSoldier(x, y) Try to spawn a soldier

Local commands - detail

getOres()

Returns a list of Ore objects.

getUnits()

Returns a list of Unit objects that are yours.

getBuildingsByType(buildingType)

Returns a list of Building objects filtered by buildingType that are yours.

buildingType is the value of a BuildingType.

getUnitsByType(unitType)

Returns a list of Unit objects filtered by unitType.

unitType is the value of a UnitType

getEnemyUnits()

Returns a list of Unit objects that are enemies.

getEnemyBuildings()

Returns a list of Building objects that are enemies.

distanceBetweenEntities(a, b)

Returns the distance between two entities as a number.

a is the first entity, b is the second entity

distanceBetween(x1, y1, x2, y2)

Returns the distance between two points as a number.

getNearest(entities, x1, y1)

Returns the nearest entity to a point.

entities is a list of entities

getNearestWithinRange(entities, x1, y1, range)

Returns the nearest entity to a point within a range.

entities is a list of entities. x1, y1, and range are numbers

Server commands - detail

move(a, x, y)

Moves a unit to a point.

mine(a, ore)

Mines an ore.

a is the entity mining. ore is the ore to be mined.

load(a, hub)

Loads ore into a building.

a is the entity loading. ore is the hub to be loaded.

spawnBuilding(buildingType, x, y)

Create a building.

spawnWorker(x, y)

Create a worker.

spawnSoldier(x, y)

Create a soldier.


BuildingType

Name Value Description
Hub 1 The Hub building
House 2 The House building

UnitType

Name Value Description
Worker 1 The Worker unit
Soldier 2 The Soldier unit

Mechs

Each faction ultimately strives to field its customisable mech units, which are the mainstay of any ground-based main battle force.

Simple (Primary) mechs are comprised of a Base, Body, and Primary Armament.

Complex (Secondary) mechs are comprised of a Base, Body, Right arm (primary), Left arm (secondary).

Advanced (Tertiary) modular mechs are comprised of a Base, Body, and composable Segments. Segments may be connectors with various Endpoints. Endpoints can have Armaments attached.

Body

Body types are the core of a mech. They determine the mech's size and shape.

Base

Base types are the foundation of a mech. They determine the mech's movement and power.

Armament

Armament types are the weapons of a mech. They determine the mech's offensive capabilities.

Segment

Segment types are the modular components of a mech. They determine the mech's flexibility and adaptability.

Building a mech

In code:


const simpleMech = buildMech({
  base: "BaseType",
  body: "BodyType",
  armament: "ArmamentType",
});

Base type should be one of the following:

Body type should be one of the following:

Weapons come in three major categories:

Future weapon classes may include e.g., Indirect Fire (Artillery), Support (e.g,. Repair), and Melee (???).

Armament (weapon) type should be one of the following:


Factions

Each faction has unique buildings, units, and tactics

Information about known factions has been removed.


How code runs

Here's how your commands compete

All commands received by the server are queued and run in order, after a little bit of grouping. The server will run as many commands as it can. If you send too many commands, only the first few will run. The rest will be ignored.

In more technical terms, the server runs commands in batches. Each batch is a set of commands that were received within a certain time period. The size of each batch varies according to server performance.