Skip to content

Commit

Permalink
Feat(networking): [TTTK-44] Added JSON Schema for Client to Host
Browse files Browse the repository at this point in the history
  • Loading branch information
Petzys committed Feb 23, 2024
1 parent 5573bd0 commit 35abaeb
Showing 1 changed file with 131 additions and 22 deletions.
153 changes: 131 additions & 22 deletions json_schema/client_to_server.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,145 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "lobby/join",
"title": "Client joins the lobby",
"description": "Game Client joins the lobby, and sends the player's profile",
"$id": "client_to_server_TicTacToe",
"title": "Clients perform actions in the TicTacToe program",
"description": "The schema for the messages sent from the client to the server in the TicTacToe program",
"type": "object",
"properties": {
"message_type": {
"description": "The message type",
"type": "string",
"const": "lobby/join"
"enum": ["lobby/join", "lobby/kick", "lobby/ready", "game/make_move", "chat/message"]
}
},
"required": [ "message_type"],
"allOf": [
{
"if": {
"properties": {
"message_type": { "const": "lobby/join" }
}
},
"then": {
"properties": {
"profile": {
"description": "The profile object of the player",
"type": "object",
"properties": {
"id": {
"description": "The id of the player",
"type": "number"
},
"name": {
"description": "The name of the player",
"type": "string"
},
"color": {
"description": "The color of the player",
"type": "number",
"minimum": 0,
"maximum": 16777215
}
},
"required": [ "id", "name", "color"]
}
},
"required": [ "profile"]
}
},
{
"if": {
"properties": {
"message_type": { "const": "lobby/kick" }
}
},
"then": {
"properties": {
"admin_player_id": {
"description": "The id of the player with admin rights",
"type": "number"
},
"kick_player_id": {
"description": "The id of the player to kick",
"type": "number"
}
},
"required": [ "admin_player_id", "kick_player_id"]
}
},
"profile": {
"description": "The profile object of the player",
"type": "object",
"properties": {
"id": {
"description": "The id of the player",
"type": "number"
{
"if": {
"properties": {
"message_type": { "const": "lobby/ready" }
}
},
"then": {
"properties": {
"player_id": {
"description": "The id of the player who changed the ready status",
"type": "number"
},
"ready": {
"description": "The ready status of the player",
"type": "boolean"
}
},
"name": {
"description": "The name of the player",
"type": "string"
"required": [ "player_id", "ready"]
}
},
{
"if": {
"properties": {
"message_type": { "const": "game/make_move" }
}
},
"then": {
"properties": {
"player_id": {
"description": "The id of the player who made the move",
"type": "number"
},
"move": {
"description": "The move to make",
"type": "object",
"properties": {
"x": {
"description": "The x coordinate of the move",
"type": "number",
"minimum": 0,
"maximum": 2
},
"y": {
"description": "The y coordinate of the move",
"type": "number",
"minimum": 0,
"maximum": 2
}
},
"required": [ "x", "y"]
}
},
"color": {
"description": "The color of the player",
"type": "number",
"minimum": 0,
"maximum": 16777215
"required": [ "player_id", "move"]
}
},
{
"if": {
"properties": {
"message_type": { "const": "chat/message" }
}
},
"required": [ "id", "name", "color"]
"then": {
"properties": {
"player_id": {
"description": "The id of the player who sent the message",
"type": "number"
},
"message": {
"description": "The message to send",
"type": "string"
}
},
"required": [ "player_id", "message"]
}
}
},
"required": [ "message_type", "profile"]
]
}

0 comments on commit 35abaeb

Please sign in to comment.