(tic-tac-toe): Updated setGameOutcome to accept outcome as a parameter and integrated it into game result handling

This commit is contained in:
apetitco 2025-12-22 18:58:00 +01:00 committed by Maix0
parent 4a58f2e98b
commit dc62f3a98e
2 changed files with 4 additions and 4 deletions

View file

@ -14,9 +14,9 @@ export const TicTacToeImpl: Omit<ITicTacToeDb, keyof Database> = {
* @param gameId The game we want to write the outcome of. * @param gameId The game we want to write the outcome of.
* *
*/ */
setGameOutcome(this: ITicTacToeDb, id: GameId): void { setGameOutcome(this: ITicTacToeDb, id: GameId, outcome: string): void {
// Find a way to retrieve the outcome of the game. // Find a way to retrieve the outcome of the game.
this.prepare('INSERT INTO tictactoe (game, outcome) VALUES (@id, "draw" /* replace w/ game outcome */)').run({ id }); this.prepare('INSERT INTO tictactoe (game, outcome) VALUES (@id, @outcome)').run({ id });
}, },
/** /**
* whole function description * whole function description

View file

@ -7,7 +7,7 @@ import * as auth from '@shared/auth';
import * as swagger from '@shared/swagger'; import * as swagger from '@shared/swagger';
import * as utils from '@shared/utils'; import * as utils from '@shared/utils';
import { Server } from 'socket.io'; import { Server } from 'socket.io';
// import type { TicTacToeImpl } from '@shared/database/mixin/tictactoe'; import type { TicTacToeImpl } from '@shared/database/mixin/tictactoe';
declare const __SERVICE_NAME: string; declare const __SERVICE_NAME: string;
@ -83,7 +83,7 @@ async function onReady(fastify: FastifyInstance, game: TTC) {
turn: game.currentPlayer, turn: game.currentPlayer,
lastResult: result, lastResult: result,
}); });
// fastify.db.setGameOutcome(this, "011001"); fastify.db.setGameOutcome("011001", result);
} }
}); });