From 0247c7d384b85c65e259dabc49d1c16cf0c1e7e4 Mon Sep 17 00:00:00 2001 From: Frank Schwenk Date: Tue, 24 Jun 2025 10:08:07 +0200 Subject: [PATCH] feat(new-game): dynamic race-to quick picks and defaults for 14/1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Passes selected game type to RaceToStep in App.jsx - RaceToStep now shows quick pick values 60, 70, 80, 90, 100 (default 80) for 14/1, 1–9 (default 5) for others - Number input always displays the default if none selected, updates on game type change - Updates .gitea to reference issue #26 for traceability Refs #26 --- .gitea | 2 +- src/components/App.jsx | 1 + src/components/NewGame.jsx | 23 ++++++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.gitea b/.gitea index b1647bf..e77c3f5 100644 --- a/.gitea +++ b/.gitea @@ -1 +1 @@ -@https://gitea.schwenk.online/froxxxy/bscscore/issues/10 \ No newline at end of file +https://gitea.schwenk.online/froxxxy/bscscore/issues/26 \ No newline at end of file diff --git a/src/components/App.jsx b/src/components/App.jsx index 8962ce5..d291002 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -312,6 +312,7 @@ const App = () => { onNext={handleRaceToNext} onCancel={() => setNewGameStep('gameType')} initialValue={newGameData.raceTo} + gameType={newGameData.gameType} /> )} diff --git a/src/components/NewGame.jsx b/src/components/NewGame.jsx index 10c0b25..f38a63c 100644 --- a/src/components/NewGame.jsx +++ b/src/components/NewGame.jsx @@ -560,11 +560,28 @@ const GameTypeStep = ({ onNext, onCancel, initialValue = '' }) => { * @param {Function} props.onNext * @param {Function} props.onCancel * @param {string|number} [props.initialValue] + * @param {string} [props.gameType] * @returns {import('preact').VNode} */ -const RaceToStep = ({ onNext, onCancel, initialValue = '' }) => { - const [raceTo, setRaceTo] = useState(initialValue); - const quickPicks = [1, 2, 3, 4, 5, 6, 7, 8, 9]; +const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }) => { + let quickPicks, defaultValue; + if (gameType === '14/1 endlos') { + quickPicks = [60, 70, 80, 90, 100]; + defaultValue = 80; + } else { + quickPicks = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + defaultValue = 5; + } + const [raceTo, setRaceTo] = useState(initialValue !== '' ? initialValue : defaultValue); + + useEffect(() => { + if ((initialValue === '' || initialValue === undefined) && raceTo !== defaultValue) { + setRaceTo(defaultValue); + } + if (initialValue !== '' && initialValue !== undefined && initialValue !== raceTo) { + setRaceTo(initialValue); + } + }, [gameType, initialValue, defaultValue]); const handleQuickPick = (value) => { setRaceTo(value);