count game history stats for users

This commit is contained in:
Nathaniel Tampus
2023-04-02 18:24:21 +08:00
parent 92dfc0c778
commit 577cba6ff4
6 changed files with 94 additions and 26 deletions

View File

@@ -138,7 +138,7 @@ export async function claimAbandoned(this: Socket, type: "win" | "draw") {
game.winner = "black";
}
const { id } = (await GameModel.create(game)) as Game;
const { id } = (await GameModel.save(game)) as Game;
game.id = id;
const gameOver = {
@@ -202,7 +202,7 @@ export async function sendMove(this: Socket, m: { from: string; to: string; prom
}
game.endReason = reason;
const { id } = (await GameModel.create(game)) as Game; // save game to db
const { id } = (await GameModel.save(game)) as Game; // save game to db
game.id = id;
io.to(game.code as string).emit("gameOver", { reason, winnerName, winnerSide, id });
}