fix: prevent endlos games from ending immediately on first score
- Change endlos raceTo from 0 to Infinity to prevent automatic completion - Update NewGame component to handle Infinity values properly - Add Infinity checks in game completion and winner logic - Fix game progress calculation for endless games Fixes issue where selecting 'endlos' mode would end the match immediately when any player scored their first point.
This commit is contained in:
@@ -80,6 +80,9 @@ export class GameService {
|
||||
static isGameCompleted(game: Game): boolean {
|
||||
if (game.status === 'completed') return true;
|
||||
|
||||
// If raceTo is Infinity, the game never completes automatically
|
||||
if (game.raceTo === Infinity) return false;
|
||||
|
||||
if ('players' in game) {
|
||||
// EndlosGame
|
||||
return game.players.some(player => player.score >= game.raceTo);
|
||||
@@ -96,6 +99,9 @@ export class GameService {
|
||||
static getGameWinner(game: Game): string | null {
|
||||
if (!this.isGameCompleted(game)) return null;
|
||||
|
||||
// If raceTo is Infinity, there's no automatic winner
|
||||
if (game.raceTo === Infinity) return null;
|
||||
|
||||
if ('players' in game) {
|
||||
// EndlosGame
|
||||
const winner = game.players.find(player => player.score >= game.raceTo);
|
||||
|
||||
Reference in New Issue
Block a user