feat(new-game): dynamic race-to quick picks and defaults for 14/1
- 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
This commit is contained in:
2
.gitea
2
.gitea
@@ -1 +1 @@
|
||||
@https://gitea.schwenk.online/froxxxy/bscscore/issues/10
|
||||
https://gitea.schwenk.online/froxxxy/bscscore/issues/26
|
||||
@@ -312,6 +312,7 @@ const App = () => {
|
||||
onNext={handleRaceToNext}
|
||||
onCancel={() => setNewGameStep('gameType')}
|
||||
initialValue={newGameData.raceTo}
|
||||
gameType={newGameData.gameType}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user