Skip to content

Latest commit

 

History

History
199 lines (168 loc) · 2.49 KB

protocols.md

File metadata and controls

199 lines (168 loc) · 2.49 KB

Protocols

Pregame (login and create)

Give game list (server)

{
    "Action":"gameList",
    "Games":[
        "Game":{
            "id":[gameId],
            "nbPlayers":[0|1|2|3|4],
        },
        "Game":{
            ...
        }
    ]
}

Create a game (client)

{
    "Action":"createGame"
}

Response from server :

{
    "MapList": ["level1", "level2", ...]
}

Ask to join a game (client)

{
  "Action":"joinGame",
  "GameId":[id]
}

Responses to join a game (server)

{
  "Action":"joinedGame",
  "GameId":[id],
  "Players":[id, id, ...],
  "PlayerId": id,
  "Map": "name"
}
{
  "Action":"cantJoinGame",
  "GameId":[id],
  "MoreInfo":["gameFull"|"communicationError"|"gameDoesNotExist"|...]
}

Ask to change player's role (client)

{
    "Action":"roleChange",
    "RoleId":[id]
}

Responses from server (broadcast)

{
  "Action":"roleChange",
  "PlayerId":[id],
  "RoleId":[id]
}

OSEF

{
  "Action":"cantChangeRole",
  "MoreInfo":[...]
}

Ask Change Map (leader)

{
    "Action":"changeMap",
    "Map": "name"
}

Responses from server

{
    "Action":"changedMap",
    "Map": "name"
}

Ask Start game (client)(leader)

{
    "Action":"startGame"
}

Responses from server

{
  "Action":"loadLevel",
  "Blocks":[[1,0,4,3,1,1,1,..],[...]],
  "Objects":[{xPos:[val],yPos:[val],value:[val]},...],
  "Players":[{xPos:0,yPos:0},{xPos:0,yPos:0},{xPos:0,yPos:0},{xPos:0,yPos:0}]
}
{
  "Action":"cantStartGame",
  "MoreInfo":["Not enough players"|"Dup role"|...]
}

Ingame

Ask for a movement (client)

{
    "Action":"move",
    "Direction":"up|down|left|right"
}

Send a player movement (server)

{
    "Action":"move",
    "PosX":[val],
    "PosY":[val],
    "Player":[id]
}

Action (player) (if appropriate)

{
    "Action":"action"
}

Response from server if action allowed (new map status)

{
    "Action":"action",
    "Changes":[{xPos:[val],yPos:[val],value:[val]},{xPos:[val],yPos:[val],value:[val]}]
}

Players wons (server)

{
    "Action":"win"
}

Goto next level (client)(leader)

{
    "Action":"nextLevel"
}

Response from server : load level (see "Ask Start game" response)

Quit game

{
    "Action":"leaveGame"
}

Response from server (broadcast)

{
    "Action":"leaveGame",
    "Player":[id]
}

Restart level

TODO