Skip to content

Commit 91069f6

Browse files
authored
Merge pull request #17 from neu-cs4530/documentation-and-more-testing
Documentation fixes
2 parents ec5cfd3 + b3f96bb commit 91069f6

File tree

14 files changed

+75
-114
lines changed

14 files changed

+75
-114
lines changed

frontend/src/classes/interactable/PongAreaController.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default class PongAreaController extends GameAreaController<PongGameState
119119
}
120120

121121
/**
122-
* Returns the color of the current player's game piece
122+
* Returns the side of the current player's game piece
123123
* @throws an error with message PLAYER_NOT_IN_GAME_ERROR if the current player is not in the game
124124
*/
125125
get gamePiece(): PongPlayer {
@@ -221,14 +221,12 @@ export default class PongAreaController extends GameAreaController<PongGameState
221221
}
222222

223223
/**
224-
* Sends a request to the server to place the current player's game piece in the given column.
225-
* Calculates the row to place the game piece in based on the current state of the board.
224+
* Sends a request to the server to move the paddle up or down.
226225
* Does not check if the move is valid.
227226
*
228227
* @throws an error with message NO_GAME_IN_PROGRESS_ERROR if there is no game in progress
229-
* @throws an error with message COLUMN_FULL_MESSAGE if the column is full
230228
*
231-
* @param col Column to place the game piece in
229+
* @param direction Direction user moves the Paddle
232230
*/
233231
public async makeMove(direction: PongPaddleDirection): Promise<void> {
234232
const instanceID = this._instanceID;

frontend/src/classes/interactable/TargetShooterAreaController.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type TargetShooterEvents = GameEventTypes & {
3333
};
3434

3535
/**
36-
* This class is responsible for managing the state of the Pong game, and for sending commands to the server
36+
* This class is responsible for managing the state of the Target Shooter game, and for sending commands to the server
3737
*/
3838
export default class TargetShooterAreaController extends GameAreaController<
3939
TargetShooterGameState,
@@ -62,33 +62,37 @@ export default class TargetShooterAreaController extends GameAreaController<
6262
shots: 0,
6363
};
6464

65-
// returns the current position of the ball
65+
// returns the current position of the target
6666
get targetPosition(): XY {
6767
return this._targetposition;
6868
}
6969

70-
// returns the current score of the left player
70+
// returns the current score of player1
7171
get player1Score(): TargetShooterScore {
7272
return this._player1score;
7373
}
7474

75-
// returns the current score of the right player
75+
// returns the current score of player2
7676
get player2Score(): TargetShooterScore {
7777
return this._player2score;
7878
}
7979

80+
// returns the accuracy of player1
8081
get player1Accuracy(): TargetShooterAccuracy {
8182
return this._player1Acccuracy;
8283
}
8384

85+
// returns the accuracy of player2
8486
get player2Accuracy(): TargetShooterAccuracy {
8587
return this._player2Acccuracy;
8688
}
8789

90+
// returns what level of difficulty was selected
8891
get difficulty(): TargetShooterDifficulty {
8992
return this._difficulty;
9093
}
9194

95+
// returns the size of the target
9296
get targetSize(): number {
9397
return this._targetSize;
9498
}
@@ -134,7 +138,7 @@ export default class TargetShooterAreaController extends GameAreaController<
134138
}
135139

136140
/**
137-
* Returns the color of the current player's game piece
141+
* Returns the player of the current player's game piece
138142
* @throws an error with message PLAYER_NOT_IN_GAME_ERROR if the current player is not in the game
139143
*/
140144
get gamePiece(): TargetShooterPlayer {
@@ -179,11 +183,13 @@ export default class TargetShooterAreaController extends GameAreaController<
179183
* Calls super._updateFrom, which updates the occupants of this game area and other
180184
* common properties (including this._model)
181185
*
182-
* If the opposite paddle has changed, emits an oppositePaddleUpdated event with the new paddle location
183-
* If the our paddle has changed, emits an ourPaddleUpdated event with the new paddle location
184-
* If the ball position has changed, emits a ballPositionUpdated event with the new ball position
185-
* If the left score has changed, emits a leftScoreUpdated event with the new left score
186-
* If the right score has changed, emits a rightScoreUpdated event with the new right score
186+
* If the target position has changed, emits an targetPositionUpdated event with the new target location
187+
* If the player1 score has changed, emits an player1Score event with the new player 1 score
188+
* If the player2 score has changed, emits an player2Score event with the new player 2 score
189+
* If the difficulty has changed, emits a difficultyUpdated event with the new difficulty
190+
* If the target size has changed, emits a targetSizeUpdated event with the new target size
191+
* If the player1 accuracy has changed, emits a player1AccuracyUpdated event with the new player1 accuracy
192+
* If the player2 accuracy has changed, emits a player1AccuracyUpdated event with the new player2 accuracy
187193
*
188194
*/
189195
protected _updateFrom(newModel: GameArea<TargetShooterGameState>): void {
@@ -251,9 +257,8 @@ export default class TargetShooterAreaController extends GameAreaController<
251257
* Does not check if the move is valid.
252258
*
253259
* @throws an error with message NO_GAME_IN_PROGRESS_ERROR if there is no game in progress
254-
* @throws an error with message COLUMN_FULL_MESSAGE if the column is full
255260
*
256-
* @param col Column to place the game piece in
261+
* @param position XY where the player's position is
257262
*/
258263
public async makeMove(position: XY): Promise<void> {
259264
const instanceID = this._instanceID;

frontend/src/components/Town/interactables/Inventory.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ const itemImages = {
1414
};
1515

1616
/**
17-
* A generic component that renders a game area.
1817
*
1918
* It uses Chakra-UI components (does not use other GUI widgets)
2019
*
21-
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get the current state of the game. (@see useInteractableAreaController)
22-
*
23-
* It renders the following:
24-
* - A leaderboard of the game results
25-
* - A list of occupants' usernames (in a list with the aria-label 'list of occupants in the game')
26-
* - The game area component (either ConnectFourArea or TicTacToeArea). If the game area is NOT a ConnectFourArea or TicTacToeArea, then the message INVALID_GAME_AREA_TYPE_MESSAGE appears within the component
27-
* - A chat channel for the game area (@see ChatChannel.tsx), with the property interactableID set to the interactableID of the game area
20+
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get
21+
* the current state of the players inventory. (@see useInteractableAreaController)
2822
*
23+
* TESTED MANUALLY
2924
*/
3025
export function Inventory({ interactableID }: { interactableID: InteractableID }): JSX.Element {
3126
const ticketBoothAreaController = useInteractableAreaController(

frontend/src/components/Town/interactables/Pong/PongArea.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import PongAreaController from '../../../../classes/interactable/PongAreaControl
88
import PongDisplay from './PongDisplay';
99

1010
/**
11-
* The ConnectFourArea component renders the Connect Four game area.
11+
* The PongArea component renders the Pong game area.
1212
* It renders the current state of the area, optionally allowing the player to join the game.
1313
*
1414
* It uses Chakra-UI components (does not use other GUI widgets)
1515
*
16-
* It uses the ConnectFourAreaController to get the current state of the game.
16+
* It uses the PongAreaController to get the current state of the game.
1717
* It listens for the 'gameUpdated' and 'gameEnd' events on the controller, and re-renders accordingly.
1818
* It subscribes to these events when the component mounts, and unsubscribes when the component unmounts. It also unsubscribes when the gameAreaController changes.
1919
*
@@ -36,7 +36,6 @@ import PongDisplay from './PongDisplay';
3636
* - Before calling startGame method, the button is disabled and has the property isLoading set to true, and is re-enabled when the method call completes
3737
* - If the method call fails, a toast is displayed with the error message as the description of the toast (and status 'error')
3838
* - Once the game starts, the button dissapears
39-
* - The ConnectFourBoard component, which is passed the current gameAreaController as a prop (@see ConnectFourBoard.tsx)
4039
*
4140
* - When the game ends, a toast is displayed with the result of the game:
4241
* - Tie: description 'Game ended in a tie'

frontend/src/components/Town/interactables/Pong/PongDisplay.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,13 @@ const Ball = ({ position }: { position: XY }) => {
2828
/**
2929
* A component that renders the ConnectFour state
3030
*
31-
* Renders the ConnectFour state as a "StyledConnectFourstate", which consists of "StyledConnectFourSquare"s
32-
* (one for each cell in the state, starting from the top left and going left to right, top to bottom).
31+
* Renders the Pong state
3332
*
34-
* Each StyledConnectFourSquare has an aria-label property that describes the cell's position in the state,
35-
* formatted as `Cell ${rowIndex},${colIndex} (Red|Yellow|Empty)`.
33+
* The state is re-rendered whenever the state changes
3634
*
37-
* The background color of each StyledConnectFourSquare is determined by the value of the cell in the state, either
38-
* 'red', 'yellow', or '' (an empty for an empty square).
35+
* TESTED MANUALLY
3936
*
40-
* The state is re-rendered whenever the state changes, and each cell is re-rendered whenever the value
41-
* of that cell changes.
42-
*
43-
* If the current player is in the game, then each StyledConnectFourSquare is clickable, and clicking
44-
* on it will make a move in that column. If there is an error making the move, then a toast will be
45-
* displayed with the error message as the description of the toast. If it is not the current player's
46-
* turn, then the StyledConnectFourSquare will be disabled.
47-
*
48-
* @param gameAreaController the controller for the ConnectFour game
37+
* @param gameAreaController the controller for the Pong game
4938
*/
5039
export default function PongDisplay({ gameAreaController }: PongGameProps): JSX.Element {
5140
const [ballPosition, setBallPosition] = useState(gameAreaController.ballPosition);

frontend/src/components/Town/interactables/TargetShooter/TargetShooterArea.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ import TargetAreaController from '../../../../classes/interactable/TargetShooter
2222
import TargetShooterDisplay from './TargetShooterDisplay';
2323

2424
/**
25-
* The ConnectFourArea component renders the Connect Four game area.
25+
* The TargetShooterArea component renders the Target Shooter game area.
2626
* It renders the current state of the area, optionally allowing the player to join the game.
2727
*
2828
* It uses Chakra-UI components (does not use other GUI widgets)
2929
*
30-
* It uses the ConnectFourAreaController to get the current state of the game.
30+
* It uses the TargetShooterAreaController to get the current state of the game.
3131
* It listens for the 'gameUpdated' and 'gameEnd' events on the controller, and re-renders accordingly.
3232
* It subscribes to these events when the component mounts, and unsubscribes when the component unmounts. It also unsubscribes when the gameAreaController changes.
3333
*
3434
* It renders the following:
35-
* - A list of players' usernames (in a list with the aria-label 'list of players in the game', one item for leftPlayer and one for rightPlayer)
35+
* - A list of players' usernames (in a list with the aria-label 'list of players in the game', one item for player1 and one for player2)
3636
* - If there is no player in the game, the username is '(No player yet!)'
37-
* - List the players as (exactly) `leftPlayer: ${username}` and `rightPlayer: ${username}`
37+
* - List the players as (exactly) `player1: ${username}` and `player2: ${username}`
3838
* - A message indicating the current game status:
3939
* - If the game is in progress, the message is 'Game in progress, {moveCount} moves in, currently {whoseTurn}'s turn'. If it is currently our player's turn, the message is 'Game in progress, {moveCount} moves in, currently your turn'
4040
* - If the game is in status WAITING_FOR_PLAYERS, the message is 'Waiting for players to join'
@@ -50,7 +50,6 @@ import TargetShooterDisplay from './TargetShooterDisplay';
5050
* - Before calling startGame method, the button is disabled and has the property isLoading set to true, and is re-enabled when the method call completes
5151
* - If the method call fails, a toast is displayed with the error message as the description of the toast (and status 'error')
5252
* - Once the game starts, the button dissapears
53-
* - The ConnectFourBoard component, which is passed the current gameAreaController as a prop (@see ConnectFourBoard.tsx)
5453
*
5554
* - When the game ends, a toast is displayed with the result of the game:
5655
* - Tie: description 'Game ended in a tie'

frontend/src/components/Town/interactables/TargetShooter/TargetShooterDisplay.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,17 @@ const Target = ({ position, size }: { position: XY; size: number }) => {
1919
};
2020

2121
/**
22-
* A component that renders the ConnectFour state
22+
* A component that renders the TargetShooter state
2323
*
24-
* Renders the ConnectFour state as a "StyledConnectFourstate", which consists of "StyledConnectFourSquare"s
25-
* (one for each cell in the state, starting from the top left and going left to right, top to bottom).
24+
* The state is re-rendered whenever the state changes, and each target is re-rendered whenever the target position changes
25+
* The state is re-rendered whenever the difficulty is changed
2626
*
27-
* Each StyledConnectFourSquare has an aria-label property that describes the cell's position in the state,
28-
* formatted as `Cell ${rowIndex},${colIndex} (Red|Yellow|Empty)`.
2927
*
30-
* The background color of each StyledConnectFourSquare is determined by the value of the cell in the state, either
31-
* 'red', 'yellow', or '' (an empty for an empty square).
28+
* If the current player is in the game, then each Target is clickable, and clicking
29+
* on it will make a move in the game and spawn a new target. If there is an error making the move, then a toast will be
30+
* displayed with the error message as the description of the toast.
3231
*
33-
* The state is re-rendered whenever the state changes, and each cell is re-rendered whenever the value
34-
* of that cell changes.
35-
*
36-
* If the current player is in the game, then each StyledConnectFourSquare is clickable, and clicking
37-
* on it will make a move in that column. If there is an error making the move, then a toast will be
38-
* displayed with the error message as the description of the toast. If it is not the current player's
39-
* turn, then the StyledConnectFourSquare will be disabled.
32+
* TESTED MANUALLY
4033
*
4134
* @param gameAreaController the controller for the ConnectFour game
4235
*/

frontend/src/components/Town/interactables/TicketBooth/TicketBoothStore.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,13 @@ const flashing = keyframes`
4242
`;
4343

4444
/**
45-
* A generic component that renders a game area.
4645
*
4746
* It uses Chakra-UI components (does not use other GUI widgets)
4847
*
49-
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get the current state of the game. (@see useInteractableAreaController)
50-
*
51-
* It renders the following:
52-
* - A leaderboard of the game results
53-
* - A list of occupants' usernames (in a list with the aria-label 'list of occupants in the game')
54-
* - The game area component (either ConnectFourArea or TicTacToeArea). If the game area is NOT a ConnectFourArea or TicTacToeArea, then the message INVALID_GAME_AREA_TYPE_MESSAGE appears within the component
55-
* - A chat channel for the game area (@see ChatChannel.tsx), with the property interactableID set to the interactableID of the game area
48+
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get
49+
* the current state of the store. (@see useInteractableAreaController)
5650
*
51+
* TESTED MANUALLY
5752
*/
5853
export function TicketBoothStore({
5954
interactableID,

frontend/src/components/Town/interactables/TicketBoothsArea.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,13 @@ import { Inventory } from './Inventory';
2020
import { TokenLeaderboard } from './TokenLeaderboard';
2121

2222
/**
23-
* A generic component that renders a game area.
2423
*
2524
* It uses Chakra-UI components (does not use other GUI widgets)
2625
*
27-
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get the current state of the game. (@see useInteractableAreaController)
28-
*
29-
* It renders the following:
30-
* - A leaderboard of the game results
31-
* - A list of occupants' usernames (in a list with the aria-label 'list of occupants in the game')
32-
* - The game area component (either ConnectFourArea or TicTacToeArea). If the game area is NOT a ConnectFourArea or TicTacToeArea, then the message INVALID_GAME_AREA_TYPE_MESSAGE appears within the component
33-
* - A chat channel for the game area (@see ChatChannel.tsx), with the property interactableID set to the interactableID of the game area
26+
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get
27+
* the current state of the ticketbooth. (@see useInteractableAreaController)
3428
*
29+
* TESTED MANUALLY
3530
*/
3631
function TicketBoothsArea({ interactableID }: { interactableID: InteractableID }): JSX.Element {
3732
return (

frontend/src/components/Town/interactables/TokenLeaderboard.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@ import { usePlayers } from '../../../classes/TownController';
44
import PlayerController from '../../../classes/PlayerController';
55

66
/**
7-
* A generic component that renders a game area.
7+
* A generic component that renders a token leaderboard.
88
*
99
* It uses Chakra-UI components (does not use other GUI widgets)
1010
*
11-
* It uses the TicketBoothAreaController corresponding to the provided interactableID to get the current state of the game. (@see useInteractableAreaController)
11+
* It uses the UsePlayers hook to get the current players of the game. (@see usePlayers)
1212
*
13-
* It renders the following:
14-
* - A leaderboard of the game results
15-
* - A list of occupants' usernames (in a list with the aria-label 'list of occupants in the game')
16-
* - The game area component (either ConnectFourArea or TicTacToeArea). If the game area is NOT a ConnectFourArea or TicTacToeArea, then the message INVALID_GAME_AREA_TYPE_MESSAGE appears within the component
17-
* - A chat channel for the game area (@see ChatChannel.tsx), with the property interactableID set to the interactableID of the game area
1813
*
1914
*/
2015
export function TokenLeaderboard(): JSX.Element {

0 commit comments

Comments
 (0)