Skip to content

Commit

Permalink
feat: Implement end game functionality
Browse files Browse the repository at this point in the history
This commit introduces the ability for the master chef to end a game.

The following changes were made:

- Added a new API endpoint to handle end game requests.
- Added a new EndGameReason enum to specify the reason for ending a game.
- Updated the game service to handle end game logic.
- Added a new menu item to the game menu and side menu to end the game.
- Updated the kitchen component to handle the end game action.
- Updated translations for new strings.
- Added Cloud Code extension to devcontainer.
- Redesigned menu system to allow for dynamic menu items.
  • Loading branch information
JessicaMulein committed Dec 28, 2024
1 parent 1711951 commit 475921b
Show file tree
Hide file tree
Showing 34 changed files with 961 additions and 379 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"MermaidChart.vscode-mermaid-chart",
"Graphite.gti-vscode",
"Orta.vscode-jest",
"Google.geminicodeassist"
"Google.geminicodeassist",
"GoogleCloudTools.cloudcode"
],
// Set *default* container specific settings.json values on container create.
"settings": {
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"mongodb.mongodb-vscode",
"ms-playwright.playwright",
"mermaidchart.vscode-mermaid-chart",
"graphite.gti-vscode"
"graphite.gti-vscode",
"googlecloudtools.cloudcode"
]
}
43 changes: 43 additions & 0 deletions chili-and-cilantro-api/src/controllers/api/game.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {

Check failure on line 1 in chili-and-cilantro-api/src/controllers/api/game.ts

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Specify a correct path to the 'eslint' package
CardType,
EndGameReason,
GamePhase,
IActionResponse,
IActionsResponse,
Expand Down Expand Up @@ -171,6 +172,19 @@ export class GameController extends BaseController {
handler: this.startGame,
useAuthentication: true,
}),
routeConfig<
IGameActionResponse | IApiErrorResponse,
false,
Array<unknown>
>({
method: 'post',
path: '/:code/end',
handler: this.endGame,
useAuthentication: true,
validation: [
body('reason').isString().isIn(Object.values(EndGameReason)),
],
}),
routeConfig<
ITurnActionsResponse | IApiErrorResponse,
false,
Expand Down Expand Up @@ -588,4 +602,33 @@ export class GameController extends BaseController {
);
});
}

private async endGame(
req: Request,
res: Response,
send: SendFunction<IGameActionResponse | IApiErrorResponse>,
next: NextFunction,
) {
try {
const user = await this.validateAndFetchRequestUser(req, res, next);
const gameCode = req.params.code;
const reason = req.validatedBody.reason as EndGameReason;
const { game, action } = await this.gameService.performEndGameAsync(
gameCode,
reason,
user._id,
);
send(
200,
{
message: translate(StringNames.Common_Success),
game: GameService.gameToGameObject(game),
action: ActionService.actionToActionObject(action),
},
res,
);
} catch (e) {
handleError(e, res, send as SendFunction<IApiErrorResponse>, next);
}
}
}
Loading

0 comments on commit 475921b

Please sign in to comment.