Skip to content

Latest commit

 

History

History
239 lines (126 loc) · 7.19 KB

protos.md

File metadata and controls

239 lines (126 loc) · 7.19 KB

Protocol Documentation

Table of Contents

Top

proto/game.proto

Game related messages.

This file contains the messages that are used to communicate between the game server and the players.

Lighthouse

Represents a lighthouse in the game.

Field Type Label Description
Position Position Position of the lighthouse
Owner int32 Owner of the lighthouse
Energy int32 Energy of the lighthouse
Connections Position repeated Connections of the lighthouse
HaveKey bool Have key to the lighthouse

MapRow

Represents the game map as a list of rows.

Field Type Label Description
Row int32 repeated Row of the map

NewAction

Represents the action that a player took in a turn.

Field Type Label Description
Action Action Action: 0 = pass, 1 = move, 2 = attack, 3 = connect
Destination Position Destination position for the action
Energy int32 Energy used for the action

NewPlayer

Represents a response for a new player that joined the game.

Field Type Label Description
name string Name of the player
serverAddress string Address of the server

NewPlayerInitialState

Represents the initial state of the game for a given player.

Field Type Label Description
PlayerID int32 Player ID
PlayerCount int32 Number of players in the game
Position Position Initial position of the player
Map MapRow repeated Complete map of the game
Lighthouses Lighthouse repeated Lighthouses in the game

NewTurn

Represents a new turn in the game for a given player.

Field Type Label Description
Position Position Current position of the player
Score int32 Current score of the player
Energy int32 Current energy of the player
View MapRow repeated Current view of the player surroundings
Lighthouses Lighthouse repeated Current state of the lighthouses

PlayerID

Represents a player ID.

Field Type Label Description
PlayerID int32 Player ID

PlayerReady

Represents the player ready state.

Field Type Label Description
Ready bool Ready state: 0 = not ready, 1 = ready

Position

Represents a position in the game map.

Field Type Label Description
X int32 X coordinate
Y int32 Y coordinate

Action

Represents the actions that a player can take in a turn.

Name Number Description
PASS 0 Do nothing
MOVE 1 Move to a new position
ATTACK 2 Attack a lighthouse
CONNECT 3 Connect to a lighthouse

GameService

Represents the game services.

Method Name Request Type Response Type Description
Join .NewPlayer .PlayerID
InitialState .NewPlayerInitialState .PlayerReady
Turn .NewTurn .NewAction

Scalar Value Types

.proto Type Notes C++ Java Python Go C# PHP Ruby
double double double float float64 double float Float
float float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)