Skip to content

hexammon/HexammonServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hexo-Nards Game Server

Game Server implementation consists of 2 parts:

  • Web-socket server for game events and players interaction: useful in all event-driven cases.
  • REST API for receiving data (like statistic) and authorization: useful in data-driven cases and request-response logic.

Web-socket server

All messages based on player actions or game related events. Messages are JSON. Common format for client messages is:

{
    "authKey": "<authKey>", 
    "eventType": "<eventName>",
    "eventData": {
        // fields with event data
    }
}

Common format for server messages is:

{
    "initiator": "<player>", 
    "eventType": "<eventName>",
    "eventData": {
        // fields with event data
    }
}

/auth

Channel for authentication related actions.

Client events

{
    "initiator": "<player>", 
    "eventType": "<eventName>",
    "eventData": {
        // fields with event data
    }
}

All wss-routes prefixed with /wss/v1. Server provide next routes:

/rooms

This channel provide events about new games.

Client messages:

CreateNewRoom
{
    "eventType": "CreateNewRoom",
    "eventData": {
        "numberOfPlayers": 2,
        "boardType": "<hex|square>",
        "boardSize": 8, // e.g. 8x8
    }
}
RoomsListRequest
{
    "eventType": "RoomsListRequest",
    "eventData": {
        "numberOfPlayers": 2, // optional, can be undefined for include without limit by players 
        "boardType": "<hex|square>", // optional, can be undefined for include without limit by board
        "boardSize": 8, // e.g. 8x8, optional, can be undefined for include without limit by players 
    }
}
JoinToRoom

Server messages:

RoomsListResponse
{
    "eventType": "RoomsListRequest",
    "eventData": {
        "rooms": [
            {
                "numberOfPlayers": 2,
                "boardType": "<hex|square>",
                "boardSize": 8, // e.g. 8x8
                "players": [
                    {
                        "id": "<playerId>",
                        "login": "<playerLogin>",
                        "color": "#FFFFFF"
                    }
                ]
            }
        ]
    }
}
PlayerJoinedToRoom
{
    "eventType": "PlayerJoinedToRoom",
    "eventData": {
        "roomId": "<roomId>",
        "player": {
            "id": "<playerId>",
            "login": "<playerLogin",
            "color": "#FFFFFF" // RGB color of player
        }
    }
}
RoomFilled (game is begin)
{
    "eventType": "RoomFilled",
    "eventData": {
        "gameId": "<gameId>" // id of new game, connect to its channel (see below)
    }
}
NewRoomCreated
{
    "eventType": "NewRoomCreated",
    "eventData": {
        "roomId": "<roomId>",
        "numberOfPlayers": 2,
        "boardType": "<hex|square>",
        "boardSize": 8, // e.g. 8x8
    }
}

/game/<gameId>

This channel provide all events in game, like player actions.

Client messages:

AssaultCastle
{
    "eventType": "AssaultCastle",
    "eventData": {
        // TBD
    }
}
BuildCastle
{
    "eventType": "BuildCastle",
    "eventData": {
        "tileCoordinate": "<tileCoordinate>" // coordinate of tile in "1-1" format, where first number is row, and second is column, started from 1.   
    }
}
MergeArmy
{
    "eventType": "MergeArmy",
    "eventData": {
        // TBD
    }
}
MoveArmy
{
    "eventType": "MoveArmy",
    "eventData": {
        "sourceTileCoordinate": "<tileCoordinate>",
        "targetTileCoordinate": "<tileCoordinate>",
        "units": 10 // number of units for movement
    }
}
ReplenishGarrison
{
    "eventType": "ReplenishGarrison",
    "eventData": {
        "tileCoordinate": "<tileCoordinate>"
    }
}
TakeOffEnemyGarrison
{
    "eventType": "TakeOffEnemyGarrison",
    "eventData": {
        "tileCoordinate": "<tileCoordinate>"
    }
}

Server messages:

Server re-send all client messages to every player in game as is. Client must update board state with action from other players.

SwitchActivePlayer

Send when previous player make all moves, and active player switched.

{
    "eventType": "SwitchActivePlayer",
    "eventData": {
        "activePlayerId": "<playerId>"
    }
}

REST API (auth service and statistic data)

All REST routes prefixed with /api/v1. REST API provide next routes:

...TBD...

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages