diff --git a/src/components/NewGame.tsx b/src/components/NewGame.tsx index 53d87af..c5b2ad9 100644 --- a/src/components/NewGame.tsx +++ b/src/components/NewGame.tsx @@ -2,6 +2,7 @@ import { h } from 'preact'; import { useState, useEffect, useRef } from 'preact/hooks'; import styles from './NewGame.module.css'; import modalStyles from './PlayerSelectModal.module.css'; +import { PlayerSelectModal } from './new-game/PlayerSelectModal'; import { UI_CONSTANTS, WIZARD_STEPS, @@ -16,29 +17,7 @@ import { } from '../utils/constants'; import type { BreakRule } from '../types/game'; -interface PlayerSelectModalProps { - players: string[]; - onSelect: (player: string) => void; - onClose: () => void; -} - -export const PlayerSelectModal = ({ players, onSelect, onClose }: PlayerSelectModalProps) => ( -
-
e.stopPropagation()}> -
-

Alle Spieler

- -
-
- {players.map(player => ( - - ))} -
-
-
-); +// PlayerSelectModal moved to ./new-game/PlayerSelectModal interface PlayerStepProps { playerNameHistory: string[]; @@ -811,10 +790,10 @@ const RaceToStep = ({ onNext, onCancel, initialValue = '', gameType }: RaceToSte interface BreakRuleStepProps { onNext: (rule: BreakRule) => void; onCancel: () => void; - initialValue?: BreakRule | ''; + initialValue?: BreakRule | 'winnerbreak'; } -const BreakRuleStep = ({ onNext, onCancel, initialValue = '' }: BreakRuleStepProps) => { +const BreakRuleStep = ({ onNext, onCancel, initialValue = 'winnerbreak' }: BreakRuleStepProps) => { const [rule, setRule] = useState(initialValue); return ( @@ -866,11 +845,18 @@ interface BreakOrderStepProps { initialSecond?: number; } -const BreakOrderStep = ({ players, rule, onNext, onCancel, initialFirst = 0, initialSecond }: BreakOrderStepProps) => { +const BreakOrderStep = ({ players, rule, onNext, onCancel, initialFirst = 1, initialSecond }: BreakOrderStepProps) => { const playerCount = players.filter(Boolean).length; const [first, setFirst] = useState(initialFirst); const [second, setSecond] = useState(initialSecond); + // Default selections: player 1 breaks first; if 3 players with wechselbreak, player 2 breaks second + useEffect(() => { + if (!initialSecond && rule === 'wechselbreak' && playerCount === 3) { + setSecond(2); + } + }, [initialSecond, rule, playerCount]); + const handleFirst = (idx: number) => { setFirst(idx); // Auto-advance cases: winnerbreak (any players) OR wechselbreak with 2 players @@ -904,7 +890,7 @@ const BreakOrderStep = ({ players, rule, onNext, onCancel, initialFirst = 0, ini {rule === 'wechselbreak' && playerCount === 3 && ( <> -
Wer bricht als Zweites?
+
Wer hat den zweiten Anstoss?
{players.filter(Boolean).map((name, idx) => ( diff --git a/src/components/new-game/PlayerSelectModal.tsx b/src/components/new-game/PlayerSelectModal.tsx new file mode 100644 index 0000000..0f72a3a --- /dev/null +++ b/src/components/new-game/PlayerSelectModal.tsx @@ -0,0 +1,28 @@ +import { h } from 'preact'; +import modalStyles from '../PlayerSelectModal.module.css'; + +interface PlayerSelectModalProps { + players: string[]; + onSelect: (player: string) => void; + onClose: () => void; +} + +export const PlayerSelectModal = ({ players, onSelect, onClose }: PlayerSelectModalProps) => ( +
+
e.stopPropagation()}> +
+

Alle Spieler

+ +
+
+ {players.map(player => ( + + ))} +
+
+
+); + +