Skip to content

Commit

Permalink
Tweak gameover check
Browse files Browse the repository at this point in the history
  • Loading branch information
Perlkonig committed Dec 14, 2024
1 parent 6fc79ac commit b7352cd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions api/abstractplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,14 @@ async function game(userid: string, pars: { id: string, cbit: string | number, m
if (engine === undefined) {
throw new Error(`Could not rehydrate the state for id "${pars.id}", cbit "${pars.cbit}", meta "${pars.metaGame}".`);
}
let player: number|undefined;
const pidx = game.players.findIndex(p => p.id === userid);
if (pidx >= 0) {
player = pidx + 1;
if (!engine.gameover) {
let player: number|undefined;
const pidx = game.players.findIndex(p => p.id === userid);
if (pidx >= 0) {
player = pidx + 1;
}
game.state = engine.serialize({strip: true, player});
}
game.state = engine.serialize({strip: true, player});
}

console.log(`Returning 200.`);
Expand Down

0 comments on commit b7352cd

Please sign in to comment.