From 906f106b26c1795ebd7bf0f760391e0331dc1d02 Mon Sep 17 00:00:00 2001 From: Ross Andrews Date: Thu, 28 May 2026 23:19:05 -0500 Subject: [PATCH] Vary required round sum by player count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3 players → -105, 4-6 → -110, 7-8 → -100. Adds requiredRoundSum() to scoring.ts and threads it through isRoundScoreValid and the sum display in EnterScores. Co-Authored-By: Claude Sonnet 4.6 --- src/game/scoring.ts | 9 ++++++++- src/pages/EnterScores.tsx | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/game/scoring.ts b/src/game/scoring.ts index fc02fdf..fcf270b 100644 --- a/src/game/scoring.ts +++ b/src/game/scoring.ts @@ -2,8 +2,15 @@ export function isIndividualScoreValid(n: number): boolean { return n % 5 === 0 && n <= 110 } +export function requiredRoundSum(playerCount: number): number { + if (playerCount === 3) return -105 + if (playerCount >= 7) return -100 + return -110 +} + export function isRoundScoreValid(scores: number[]): boolean { - return scores.every(isIndividualScoreValid) && scores.reduce((a, b) => a + b, 0) === -110 + return scores.every(isIndividualScoreValid) + && scores.reduce((a, b) => a + b, 0) === requiredRoundSum(scores.length) } // Returns totals[i][j] = cumulative score for player j after round i. diff --git a/src/pages/EnterScores.tsx b/src/pages/EnterScores.tsx index b7f5f56..9f1ee49 100644 --- a/src/pages/EnterScores.tsx +++ b/src/pages/EnterScores.tsx @@ -2,7 +2,7 @@ import { useState } from 'react' import PageFrame from '../components/PageFrame' import PrimaryButton from '../components/PrimaryButton' import HelpModal from '../components/HelpModal' -import { isIndividualScoreValid, isRoundScoreValid } from '../game/scoring' +import { isIndividualScoreValid, isRoundScoreValid, requiredRoundSum } from '../game/scoring' import { type GameState } from '../types' import styles from './EnterScores.module.css' import sharedStyles from '../styles/shared.module.css' @@ -33,6 +33,7 @@ export default function EnterScores({ game, onSubmit, onBack, initialValues }: P })) } + const target = requiredRoundSum(game.players.length) const parsed = values.map(v => parseInt(v, 10)) const fieldError = values.map((v, i) => v !== '' && (isNaN(parsed[i]) || !isIndividualScoreValid(parsed[i]))) const allFilled = parsed.every(n => !isNaN(n)) @@ -66,8 +67,8 @@ export default function EnterScores({ game, onSubmit, onBack, initialValues }: P /> ))} -

- Sum: {sum} / −110 +

+ Sum: {sum} / {target}

)