Files
space_game_server/commands.md
T

4.8 KiB

This is a list of all the commands that are available from the client to the server along with the expected response.

Message types

Client

Hello

Sent during initiali connection phase.

Query

Query information from the server about a specific topic

Command

Request an action to be performed on the server

Server

Hello

Responses and further queries during the connection phase. Example is asking what faction they want to be.

Update

Response to a query or a command. Examples would be responding to a query of how much money the player has. A response updating the target positon of a ship and it's location.

This is also used to provide updates about the game state. There are periodic updates that define where everything should be. This is the type used there.

Event

This is an event that the client did not create or ask for. For example, a battle starting, a building finishing, a planet found.

Error

A response sent when the requested action can not be completed. This is likely to be a frequent response to things like not having enough resources.

Full message definitions

For all communication with the server the player you need the player id

Hello

For the hello message neither key is optional for connecting. They are both required. If a new player is created then it does not matter what the faction key is (as long as it is a valid faction) however when connecting an existing player the faction key must match the key stored on the server or a connection error will happen.

Domain Payload keys Expected response
Player connect: player_id An update with payload success OR an update with a payload of faction
faction: faction An update to the player (when creating a player) that has the faction

Queries

For queries the keys just need to exist. There are not any values for the payload keys. You can also apply as many keys in a single request as you would like. All parts of the message should be in snake_case. All of the values for the keys may be whatever you wish, they are discarded by the server though.

Domain Payload keys Expected response
Game time The current game time.
size The current size of the game universe.
Player resources The resources the player has
planets The planets the player can see (All planets owned, and discovered)
buildings The buildings the player has
ships The ships the player has
construction The builds in progress the player has

Commands

This lists the domain and the payload keys required as well as the expected value.

Domain Payload keys Expected response
Game resign An update with payload success.
Player build: type [tech, building, ship], name: item name An update with payload success.
move: type [ship], name: item_id An update with the new target of the item.
equip: item_id, target: item_id An update with the stats of the targeted item.