From dc62f3a98e5ba7ab9e10448702287484585cce02 Mon Sep 17 00:00:00 2001 From: apetitco Date: Mon, 22 Dec 2025 18:58:00 +0100 Subject: [PATCH] (tic-tac-toe): Updated `setGameOutcome` to accept outcome as a parameter and integrated it into game result handling --- src/@shared/src/database/mixin/tictactoe.ts | 4 ++-- src/tic-tac-toe/src/app.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/@shared/src/database/mixin/tictactoe.ts b/src/@shared/src/database/mixin/tictactoe.ts index f09420d..656ba04 100644 --- a/src/@shared/src/database/mixin/tictactoe.ts +++ b/src/@shared/src/database/mixin/tictactoe.ts @@ -14,9 +14,9 @@ export const TicTacToeImpl: Omit = { * @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. - 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 diff --git a/src/tic-tac-toe/src/app.ts b/src/tic-tac-toe/src/app.ts index 7b1a3b2..69614eb 100644 --- a/src/tic-tac-toe/src/app.ts +++ b/src/tic-tac-toe/src/app.ts @@ -7,7 +7,7 @@ import * as auth from '@shared/auth'; import * as swagger from '@shared/swagger'; import * as utils from '@shared/utils'; 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; @@ -83,7 +83,7 @@ async function onReady(fastify: FastifyInstance, game: TTC) { turn: game.currentPlayer, lastResult: result, }); - // fastify.db.setGameOutcome(this, "011001"); + fastify.db.setGameOutcome("011001", result); } });