diff --git a/packages/server/src/games/game-service.ts b/packages/server/src/games/game-service.ts index 39fac23..5ad8ec7 100644 --- a/packages/server/src/games/game-service.ts +++ b/packages/server/src/games/game-service.ts @@ -1,6 +1,6 @@ import { eq, and } from "drizzle-orm" import type { Database } from "../db/client" -import { predictions, dishes, dishGuesses } from "../db/schema" +import { predictions } from "../db/schema" export class GameService { constructor(private db: Database) {} @@ -8,9 +8,10 @@ export class GameService { async persistPrediction(data: { playerId: string roomId: string - predictedWinner: string - top3: string[] - nulPointsPick: string + first: string + second: string + third: string + last: string }) { // Delete existing prediction for this player+room, then insert await this.db @@ -19,46 +20,10 @@ export class GameService { await this.db.insert(predictions).values({ playerId: data.playerId, roomId: data.roomId, - predictedWinner: data.predictedWinner, - top3: data.top3, - nulPointsPick: data.nulPointsPick, + first: data.first, + second: data.second, + third: data.third, + last: data.last, }) } - - async persistDish(data: { - id: string - roomId: string - name: string - correctCountry: string - }) { - await this.db.insert(dishes).values({ - id: data.id, - roomId: data.roomId, - name: data.name, - correctCountry: data.correctCountry, - }) - } - - async persistDishGuess(data: { - playerId: string - dishId: string - guessedCountry: string - }) { - // Delete existing guess for this player+dish, then insert - await this.db - .delete(dishGuesses) - .where(and(eq(dishGuesses.playerId, data.playerId), eq(dishGuesses.dishId, data.dishId))) - await this.db.insert(dishGuesses).values({ - playerId: data.playerId, - dishId: data.dishId, - guessedCountry: data.guessedCountry, - }) - } - - async markDishesRevealed(roomId: string) { - await this.db - .update(dishes) - .set({ revealed: true }) - .where(eq(dishes.roomId, roomId)) - } }