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:
@@ -575,7 +575,8 @@ const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }) => {
|
||||
}, [gameType, initialValue, defaultValue]);
|
||||
|
||||
const handleQuickPick = (value) => {
|
||||
setRaceTo(value);
|
||||
// For endlos (endless) games, use Infinity to prevent automatic completion
|
||||
setRaceTo(value === 0 ? 'Infinity' : value);
|
||||
};
|
||||
|
||||
const handleInputChange = (e) => {
|
||||
@@ -584,7 +585,9 @@ const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }) => {
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
onNext(parseInt(raceTo, 10) || 0);
|
||||
// Handle Infinity for endlos games, otherwise parse as integer
|
||||
const raceToValue = raceTo === 'Infinity' ? Infinity : (parseInt(raceTo, 10) || 0);
|
||||
onNext(raceToValue);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -600,7 +603,7 @@ const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }) => {
|
||||
<div className={styles['endlos-container']}>
|
||||
<button
|
||||
type="button"
|
||||
className={`${styles['race-to-btn']} ${styles['endlos-btn']} ${raceTo === 0 ? styles.selected : ''}`}
|
||||
className={`${styles['race-to-btn']} ${styles['endlos-btn']} ${raceTo === 'Infinity' ? styles.selected : ''}`}
|
||||
onClick={() => handleQuickPick(0)}
|
||||
>
|
||||
Endlos
|
||||
|
||||
Reference in New Issue
Block a user