diff --git a/apps/kazu/src/modules/game/commands/start.commands.ts b/apps/kazu/src/modules/game/commands/start.commands.ts index 0b9d5a8..05589ea 100644 --- a/apps/kazu/src/modules/game/commands/start.commands.ts +++ b/apps/kazu/src/modules/game/commands/start.commands.ts @@ -4,6 +4,7 @@ import { ForbiddenExceptionFilter, GuildModeratorGuard } from '@yugen/shared'; import { Client, CommandInteraction } from 'discord.js'; import { Context, + NumberOption, Options, SlashCommandContext, StringOption, @@ -28,6 +29,22 @@ class GameStartOptions { choices: GameStartOptionsChoices, }) type: GameType; + + @NumberOption({ + name: 'starting-number', + description: 'The number to start the game at', + required: false, + }) + startingNumber: number; +} + +class GameResetOptions { + @NumberOption({ + name: 'starting-number', + description: 'The number to start the game at', + required: false, + }) + startingNumber: number; } @UseGuards(GuildModeratorGuard) @@ -47,25 +64,38 @@ export class GameStartCommands { }) public async start( @Context() [interaction]: SlashCommandContext, - @Options() { type }: GameStartOptions, + @Options() { type, startingNumber }: GameStartOptions, ) { - return this._startGame(interaction, type ?? GameType.NORMAL); + return this._startGame( + interaction, + type ?? GameType.NORMAL, + startingNumber ?? 1, + ); } @Subcommand({ name: 'reset', description: 'Reset the current game and any points earned.', }) - public async reset(@Context() [interaction]: SlashCommandContext) { + public async reset( + @Context() [interaction]: SlashCommandContext, + @Options() { startingNumber }: GameResetOptions, + ) { const currentGame = await this._game.getCurrentGame( interaction.guildId, ); - return this._startGame(interaction, currentGame.type, true); + return this._startGame( + interaction, + currentGame.type, + startingNumber ?? 1, + true, + ); } private async _startGame( interaction: CommandInteraction, type: GameType = GameType.NORMAL, + startingNumber: number = 0, recreate: boolean = false, ) { const settings = await this._settings.getSettings(interaction.guildId); @@ -77,6 +107,7 @@ export class GameStartCommands { const started = await this._game.start( interaction.guildId, type, + startingNumber, recreate, ); diff --git a/apps/kazu/src/modules/game/services/game.service.ts b/apps/kazu/src/modules/game/services/game.service.ts index 67ba67f..d6351e3 100644 --- a/apps/kazu/src/modules/game/services/game.service.ts +++ b/apps/kazu/src/modules/game/services/game.service.ts @@ -21,6 +21,7 @@ export class GameService { async start( guildId: string, type: GameType = GameType.NORMAL, + startingNumber: number = 1, recreate = false, shamedData?: { message: Message; @@ -48,13 +49,14 @@ export class GameService { await this.endGame(currentGame.id, GameStatus.FAILED, shamedData); } + const number = startingNumber - 1; await this._prisma.game.create({ data: { guildId, type, history: { create: { - number: 0, + number: number >= 0 ? number : 0, userId: this._client.user.id, }, }, @@ -63,7 +65,7 @@ export class GameService { if (channel.type === ChannelType.GuildText) { channel.send(`**A new game has started!** -Start the count from **1**`); +Start the count from **${startingNumber}**`); } return true; @@ -145,7 +147,7 @@ Used **1 server** save, There are **${saves}/${maxSaves}** server saves left.`); **Want to save the game?** Make sure to **/vote** for Kazu and earn yourself saves to save the game!`, ); - return this.start(guildId, game.type, true, { + return this.start(guildId, game.type, 1, true, { message, lastShameUserId: settings.lastShameUserId, roleId: settings.shameRoleId,