From 2ca4eef0a6b5f41314500fdcec451c4002a6ab0f Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sat, 19 Dec 2020 18:01:36 -0700 Subject: [PATCH] Move event and type docs into their own files. --- server/docs/events/CreateGame.md | 15 ++ server/docs/events/General_Response.md | 6 + server/docs/events/GetPastQuestions.md | 14 ++ server/docs/events/JoinGame.md | 16 ++ server/docs/events/JoinTeam.md | 14 ++ server/docs/events/NewHand.md | 12 ++ server/docs/events/ObjectList.md | 13 ++ server/docs/events/SelectObject.md | 14 ++ server/docs/events/SendCard.md | 17 ++ server/docs/events/UpdateAnswer.md | 18 ++ server/docs/events/UpdateHand.md | 13 ++ server/docs/events/UpdatePlayer.md | 12 ++ server/docs/events/_template.md | 13 ++ server/docs/types/Deck.md | 7 + server/docs/types/Game.md | 11 ++ server/docs/types/Player.md | 8 + server/docs/types/Team.md | 10 ++ server/events.md | 232 ------------------------- server/types.md | 29 ---- 19 files changed, 213 insertions(+), 261 deletions(-) create mode 100644 server/docs/events/CreateGame.md create mode 100644 server/docs/events/General_Response.md create mode 100644 server/docs/events/GetPastQuestions.md create mode 100644 server/docs/events/JoinGame.md create mode 100644 server/docs/events/JoinTeam.md create mode 100644 server/docs/events/NewHand.md create mode 100644 server/docs/events/ObjectList.md create mode 100644 server/docs/events/SelectObject.md create mode 100644 server/docs/events/SendCard.md create mode 100644 server/docs/events/UpdateAnswer.md create mode 100644 server/docs/events/UpdateHand.md create mode 100644 server/docs/events/UpdatePlayer.md create mode 100644 server/docs/events/_template.md create mode 100644 server/docs/types/Deck.md create mode 100644 server/docs/types/Game.md create mode 100644 server/docs/types/Player.md create mode 100644 server/docs/types/Team.md delete mode 100644 server/events.md delete mode 100644 server/types.md diff --git a/server/docs/events/CreateGame.md b/server/docs/events/CreateGame.md new file mode 100644 index 0000000..b8d56a7 --- /dev/null +++ b/server/docs/events/CreateGame.md @@ -0,0 +1,15 @@ +# `CreateGame`: + +## Description: +Triggered when a user is creating a game. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| name | String | The name of the person starting the game + +## Response Payload: (`GameCreated`) +| Property | Type | Description +| -------- | ---- | ----------- +| id | String | The user's game ID, this should be stored to permit users to re-join the game if they get disconnected. +| game_code | String | The game's code that other players can use to connect to the game. \ No newline at end of file diff --git a/server/docs/events/General_Response.md b/server/docs/events/General_Response.md new file mode 100644 index 0000000..bab05c7 --- /dev/null +++ b/server/docs/events/General_Response.md @@ -0,0 +1,6 @@ +# Properties Of All Response Payloads +| Property | Type | Description +| -------- | ---- | ----------- +| status | Integer | The response code of the server. This follows HTTP standards as described by [Mozilla's Documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) +| message? | String | More information relating to the response. This is set iff `success` is a non 2XX value. +| source? | String | The event name that caused this response to be sent. This is set iff is a non 2XX value. \ No newline at end of file diff --git a/server/docs/events/GetPastQuestions.md b/server/docs/events/GetPastQuestions.md new file mode 100644 index 0000000..8281b65 --- /dev/null +++ b/server/docs/events/GetPastQuestions.md @@ -0,0 +1,14 @@ +# `GetPastQuestions`: + +## Description: +This event is sent from the client to the server when it has the PastQuestions component visible. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| team | Integer | The team we are requesting the questions for. This can be one of `1`, or `2`, any other value will cause an error to be returned. + +## Response Payload: (`PastQuestions`) +| Property | Type | Description +| -------- | ---- | ----------- +| questions | String[] | All the previously chosen questions for the team. \ No newline at end of file diff --git a/server/docs/events/JoinGame.md b/server/docs/events/JoinGame.md new file mode 100644 index 0000000..c50af0c --- /dev/null +++ b/server/docs/events/JoinGame.md @@ -0,0 +1,16 @@ +# `JoinGame`: + +## Description: +Triggered by the client when it attempts to connect to a game. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| name | String | The user's name +| game_code | String | The game code for the game the user is trying to join. +| id? | String | The user's ID that was stored if they have already joined a game and not finished it. + +## Response Payload: (`GameJoined`) +| Property | Type | Description +| -------- | ---- | ----------- +| id | String | The user's game ID, if `id` is set in the payload, this is the same, otherwise it is a brand new ID. \ No newline at end of file diff --git a/server/docs/events/JoinTeam.md b/server/docs/events/JoinTeam.md new file mode 100644 index 0000000..3657caa --- /dev/null +++ b/server/docs/events/JoinTeam.md @@ -0,0 +1,14 @@ +# `JoinTeam`: + +## Description: +This event is triggered by the client when the user attempts to join a team from the lobby. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| team | int | The team to join. Accepted values are: `1`, and `2`, any other value will throw an error. +| role | String | The role the player is assuming. This can be `"writer"` or `"guesser"`, any other value will throw an error. + +## Response Payload: (`JoinTeam`) +| Property | Type | Description +| -------- | ---- | ----------- \ No newline at end of file diff --git a/server/docs/events/NewHand.md b/server/docs/events/NewHand.md new file mode 100644 index 0000000..6cf5b8d --- /dev/null +++ b/server/docs/events/NewHand.md @@ -0,0 +1,12 @@ +# `NewHand`: + +## Description: +This is the event client sends it requests a new 7 cards for the hand. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| team | Integer | The team that is requesting a new hand. + +## Response Payload: +This event's response comes in the form of the `UpdateHand` event with the mode set to `"replace"` \ No newline at end of file diff --git a/server/docs/events/ObjectList.md b/server/docs/events/ObjectList.md new file mode 100644 index 0000000..c23be25 --- /dev/null +++ b/server/docs/events/ObjectList.md @@ -0,0 +1,13 @@ +# `ObjectList`: + +## Description: +This event is sent by the client when they are wanting to retrieve the list of +objects that the spirits can pick from. + +## Request Payload: +No payload is read from for this event. + +## Response Payload: (`ObjectList`) +| Property | Type | Description +| -------- | ---- | ----------- +| objects | String[] | The objects that are on the chosen card. \ No newline at end of file diff --git a/server/docs/events/SelectObject.md b/server/docs/events/SelectObject.md new file mode 100644 index 0000000..e1d7f24 --- /dev/null +++ b/server/docs/events/SelectObject.md @@ -0,0 +1,14 @@ +# `SelectObject`: + +## Description: +The event sent by the clients when they are selecting an object from the card. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| object | String | The name of the object that the spirits are selecting. + +## Response Payload: (`ChosenObject`) +| Property | Type | Description +| -------- | ---- | ----------- +| object | String | The object that has been selected. \ No newline at end of file diff --git a/server/docs/events/SendCard.md b/server/docs/events/SendCard.md new file mode 100644 index 0000000..ded8055 --- /dev/null +++ b/server/docs/events/SendCard.md @@ -0,0 +1,17 @@ +# `SendCard`: + +## Description: +Sends a card to the server, the server either then either forwards the card to the spirit or the past questions pile. The action that is taken is dependant on what the `from` property is set to. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| text | String | The text of the card that is being sent. +| from | String | The source of where the card is being sent from. This can be one of `"writer"`, `"guesser"`, any other value will return an error. +| team | Integer | The team that is sending the card. This can be either `1` or `2`, any other value will return an error. + +## Response Payload: (`NewCards`) +| Property | Type | Description +| -------- | ---- | ----------- +| cards | String[] | The text of the cards that was sent. +| from | String | The source of the card(s). This will be one of `"deck"`, or `"guesser"` \ No newline at end of file diff --git a/server/docs/events/UpdateAnswer.md b/server/docs/events/UpdateAnswer.md new file mode 100644 index 0000000..9355ec8 --- /dev/null +++ b/server/docs/events/UpdateAnswer.md @@ -0,0 +1,18 @@ +# `UpdateAnswer`: + +## Description: +This event is sent to and from the server when a spirit is typing into one of the text boxes. + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| team | Integer | The team indicator number. This can be either `1`, or `2`, any other value will cause this event to return an error. +| answer | Integer | The answer that is being updated. This can be any number between `1` and `8` (inclusive), any other value will cause this event return an error. +| value | String | The new text for the input box. + +## Response Payload: (`UpdateAnswer`) +| Property | Type | Description +| -------- | ---- | ----------- +| team | Integer | The team indicator number. This can be either `1`, or `2`. +| answer | Integer | The answer that is being updated. This can be any number between `1` and `8` (inclusive). +| value | String | The new text for the input box. \ No newline at end of file diff --git a/server/docs/events/UpdateHand.md b/server/docs/events/UpdateHand.md new file mode 100644 index 0000000..be75ac7 --- /dev/null +++ b/server/docs/events/UpdateHand.md @@ -0,0 +1,13 @@ +# `UpdateHand`: + +## Description: +Tells the client to update their hand, using one of the provided modes. + +## Request Payload: +This event is never sent to the server + +## Response Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| questions | String[] | The cards that the operation for the hand will use. +| mode | String | This is one of `"append"` or `"replace"` \ No newline at end of file diff --git a/server/docs/events/UpdatePlayer.md b/server/docs/events/UpdatePlayer.md new file mode 100644 index 0000000..18e10a6 --- /dev/null +++ b/server/docs/events/UpdatePlayer.md @@ -0,0 +1,12 @@ +# `UpdatePlayer`: + +## Description: +This event is sent from the server and is a result of a player joining/changing team, this event is also fired when a new player joins the game. + +## Request Payload: +The client cannot send this event and only receives it. + +## Response Payload: +| Property | Type | Description +| -------- | ---- | ----------- +| player | Player | The player's new data. \ No newline at end of file diff --git a/server/docs/events/_template.md b/server/docs/events/_template.md new file mode 100644 index 0000000..472535d --- /dev/null +++ b/server/docs/events/_template.md @@ -0,0 +1,13 @@ +# ``: + +## Description: + + +## Request Payload: +| Property | Type | Description +| -------- | ---- | ----------- + + +## Response Payload: (``) +| Property | Type | Description +| -------- | ---- | ----------- \ No newline at end of file diff --git a/server/docs/types/Deck.md b/server/docs/types/Deck.md new file mode 100644 index 0000000..c73ee17 --- /dev/null +++ b/server/docs/types/Deck.md @@ -0,0 +1,7 @@ +## Deck +This represents a stack of cards that can be drawn from and discarded to. + +| Property | Type | Description +| -------- | ---- | ----------- +| discard | String[] | The used cards +| deck | String[] | The unused cards \ No newline at end of file diff --git a/server/docs/types/Game.md b/server/docs/types/Game.md new file mode 100644 index 0000000..38d688a --- /dev/null +++ b/server/docs/types/Game.md @@ -0,0 +1,11 @@ +## Game: +This is a representation of the game and it's corresponding data. + +| Property | Type | Description +| -------- | ---- | ----------- +| id | String | The game's ID to join with. +| teams | Team[] | The teams that are a part of this game. +| players | Player[] | All of the players that are in this game. +| questons | Deck | The deck and discard of the question cards. +| objects | Deck | The deck and discard of the object cards. +| getObjects | String[] | Gets the objects that the game has chosen. \ No newline at end of file diff --git a/server/docs/types/Player.md b/server/docs/types/Player.md new file mode 100644 index 0000000..b0698dd --- /dev/null +++ b/server/docs/types/Player.md @@ -0,0 +1,8 @@ +## Player: +A player's information for the game. + +| Property | Type | Description +| -------- | ---- | ----------- +| name | String | The player's name. +| id | String | The player's unique ID. +| socket | Socket | The socket object used to send events directly to the player. \ No newline at end of file diff --git a/server/docs/types/Team.md b/server/docs/types/Team.md new file mode 100644 index 0000000..e9948cd --- /dev/null +++ b/server/docs/types/Team.md @@ -0,0 +1,10 @@ +## Team +A representation of a team, this consists of which player is the spirit and a complete list of all the players on the team, + +| Property | Type | Description +| -------- | ---- | ----------- +| mediums | Player[] | All the Players that are on this team. +| spirit | Player | The player that is acting as the team's spirit. +| hand | String[] | The cards that are in the medium's hand. +| questions | String[] | The questions that the mediums have asked the spirit. (This is not equivalent to the Spirit's hand) +| answers | String[] | The answers that the spirit has given. \ No newline at end of file diff --git a/server/events.md b/server/events.md deleted file mode 100644 index c27c341..0000000 --- a/server/events.md +++ /dev/null @@ -1,232 +0,0 @@ -# Properties Of All Response Payloads -| Property | Type | Description -| -------- | ---- | ----------- -| status | Integer | The response code of the server. This follows HTTP standards as described by [Mozilla's Documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) -| message? | String | More information relating to the response. This is set iff `success` is a non 2XX value. -| source? | String | The event name that caused this response to be sent. This is set iff is a non 2XX value. - -

---- - -# `CreateGame`: - -## Event Description: -Triggered when a user is creating a game. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| name | String | The name of the person starting the game - -## Response Payload: (`GameCreated`) -| Property | Type | Description -| -------- | ---- | ----------- -| id | String | The user's game ID, this should be stored to permit users to re-join the game if they get disconnected. -| game_code | String | The game's code that other players can use to connect to the game. - -

---- - -# `JoinGame`: - -## Description: -Triggered by the client when it attempts to connect to a game. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| name | String | The user's name -| game_code | String | The game code for the game the user is trying to join. -| id? | String | The user's ID that was stored if they have already joined a game and not finished it. - -## Response Payload: (`GameJoined`) -| Property | Type | Description -| -------- | ---- | ----------- -| id | String | The user's game ID, if `id` is set in the payload, this is the same, otherwise it is a brand new ID. - -

---- - -# `JoinTeam`: - -## Description: -This event is triggered by the client when the user attempts to join a team from the lobby. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| team | int | The team to join. Accepted values are: `1`, and `2`, any other value will throw an error. -| role | String | The role the player is assuming. This can be `"writer"` or `"guesser"`, any other value will throw an error. - -## Response Payload: (`JoinTeam`) -| Property | Type | Description -| -------- | ---- | ----------- - -

---- - -# `PlayerUpdate`: - -## Description: -This event is sent from the server and is a result of a player joining/changing team. - -## Request Payload: -The client cannot send this event and only receives it. - -## Response Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| player | Player | The player's new data. - -

---- - -# `UpdateAnswer`: - -## Description: -This event is sent to and from the server when a spirit is typing into one of the text boxes. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| team | Integer | The team indicator number. This can be either `1`, or `2`, any other value will cause this event to return an error. -| answer | Integer | The answer that is being updated. This can be any number between `1` and `8` (inclusive), any other value will cause this event return an error. -| value | String | The new text for the input box. - -## Response Payload: (`UpdateAnswer`) -| Property | Type | Description -| -------- | ---- | ----------- -| team | Integer | The team indicator number. This can be either `1`, or `2`. -| answer | Integer | The answer that is being updated. This can be any number between `1` and `8` (inclusive). -| value | String | The new text for the input box. - - -

---- - -# `SendCard`: - -## Description: -Sends a card to the server, the server either then either forwards the card to the spirit or the past questions pile. The action that is taken is dependant on what the `from` property is set to. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| text | String | The text of the card that is being sent. -| from | String | The source of where the card is being sent from. This can be one of `"writer"`, `"guesser"`, any other value will return an error. -| team | Integer | The team that is sending the card. This can be either `1` or `2`, any other value will return an error. - -## Response Payload: (`NewCards`) -| Property | Type | Description -| -------- | ---- | ----------- -| cards | String[] | The text of the cards that was sent. -| from | String | The source of the card(s). This will be one of `"deck"`, or `"guesser"` - -

---- - -# `UpdateHand`: - -## Description: -Tells the client to update their hand, using one of the provided modes. - -## Request Payload: -This event is never sent to the server - -## Response Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| questions | String[] | The cards that the operation for the hand will use. -| mode | String | This is one of `"append"` or `"replace"` - -

---- - -# `GetPastQuestions`: - -## Description: -This event is sent from the client to the server when it has the PastQuestions component visible. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| team | Integer | The team we are requesting the questions for. This can be one of `1`, or `2`, any other value will cause an error to be returned. - -## Response Payload: (`PastQuestions`) -| Property | Type | Description -| -------- | ---- | ----------- -| questions | String[] | All the previously chosen questions for the team. - -

---- - -# `SelectObject`: - -## Description: -The event sent by the clients when they are selecting an object from the card. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| object | String | The name of the object that the spirits are selecting. - -## Response Payload: (`ChosenObject`) -| Property | Type | Description -| -------- | ---- | ----------- -| object | String | The object that has been selected. - -

---- - -# `NewPlayer`: - -## Description: -This is sent by the server when a new player joins the game. - -## Request Payload: -This event cannot be requested by the clients. - -## Response Payload: (``) -| Property | Type | Description -| -------- | ---- | ----------- -| name | String | The player's name. - -

---- - -# `NewHand`: - -## Description: -This is the event client sends it requests a new 7 cards for the hand. - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- -| team | Integer | The team that is requesting a new hand. - -## Response Payload: (`NewHand`) -| Property | Type | Description -| -------- | ---- | ----------- -| by | String | The name of the player that triggered the `NewHand` event. -| cards | String[] | An array containing all of the new cards for the team. - -

---- - -# ``: - -## Description: - - -## Request Payload: -| Property | Type | Description -| -------- | ---- | ----------- - - -## Response Payload: (``) -| Property | Type | Description -| -------- | ---- | ----------- - - -

---- \ No newline at end of file diff --git a/server/types.md b/server/types.md deleted file mode 100644 index 604a25f..0000000 --- a/server/types.md +++ /dev/null @@ -1,29 +0,0 @@ -## Player: -| Property | Type | Description -| -------- | ---- | ----------- -| name | String | The player's name. -| id | String | The player's unique ID. - -## Deck -| Property | Type | Description -| -------- | ---- | ----------- -| discard | String[] | The used cards -| deck | String[] | The unused cards - -## Game: -| Property | Type | Description -| -------- | ---- | ----------- -| id | String | The game's ID to join with. -| teams | Team[] | The teams that are a part of this game. -| players | Player[] | All of the players that are in this game. -| questons | Deck | The deck and discard of the question cards. -| objects | Deck | The deck and discard of the object cards. - -## Team -| Property | Type | Description -| -------- | ---- | ----------- -| players | Player[] | All the Players that are on this team. -| spirit | Player | The player that is acting as the team's spirit. -| hand | String[] | The cards that are in this team's hand. -| questions | String[] | The questions that the mediums have asked the spirit. -| answers | String[] | The answers that the spirit has given. \ No newline at end of file