fix: možnost připojit se ke hře Tetris během odpočtu před startem
This commit is contained in:
3 files changed
+62
-17
No files matched your search
@@ -318,7 +318,9 @@ export default function TetrisGame() {
|
||||
if (!login) return null;
|
||||
|
||||
const session = sessionRef.current;
|
||||
const showInvite = !open && phase === 'lobby' && !isPlayer;
|
||||
// Připojit se jde i během odpočtu před startem
|
||||
const joinable = phase === 'lobby' || phase === 'countdown';
|
||||
const showInvite = !open && joinable && !isPlayer;
|
||||
const showReturn = !open && isPlayer && inGame;
|
||||
const others = practice ? [] : (state?.players ?? []).filter(p => !(isPlayer && p.login === login));
|
||||
const ranked = [...(state?.players ?? [])].sort((a, b) => (a.place ?? 99) - (b.place ?? 99));
|
||||
@@ -433,6 +435,16 @@ export default function TetrisGame() {
|
||||
</>
|
||||
);
|
||||
case 'countdown':
|
||||
return (
|
||||
<>
|
||||
{!isPlayer && (
|
||||
<p className="text-center">
|
||||
Hra začne za <strong>{state?.countdown} s</strong> — ještě se můžete připojit.
|
||||
</p>
|
||||
)}
|
||||
{renderPlaying()}
|
||||
</>
|
||||
);
|
||||
case 'playing':
|
||||
return renderPlaying();
|
||||
case 'finished':
|
||||
@@ -482,17 +494,16 @@ export default function TetrisGame() {
|
||||
if (phase === 'idle' || phase === 'finished') {
|
||||
buttons.push(<Button key="new" onClick={() => send('tetris:join')}>{phase === 'idle' ? 'Založit lobby' : 'Nová hra'}</Button>);
|
||||
}
|
||||
if (phase === 'lobby') {
|
||||
if (!isPlayer) {
|
||||
buttons.push(<Button key="join" onClick={() => send('tetris:join')}>Připojit se</Button>);
|
||||
} else {
|
||||
buttons.push(<Button key="leave" variant="outline-secondary" onClick={() => send('tetris:leave')}>
|
||||
{login === state?.host ? 'Zrušit lobby' : 'Odejít'}
|
||||
</Button>);
|
||||
if (login === state?.host) {
|
||||
buttons.push(<Button key="start" onClick={() => send('tetris:start')}
|
||||
disabled={(state?.players.length ?? 0) < (state?.minPlayers ?? 1)}>Spustit hru</Button>);
|
||||
}
|
||||
if (joinable && !isPlayer) {
|
||||
buttons.push(<Button key="join" onClick={() => send('tetris:join')}>Připojit se</Button>);
|
||||
}
|
||||
if (phase === 'lobby' && isPlayer) {
|
||||
buttons.push(<Button key="leave" variant="outline-secondary" onClick={() => send('tetris:leave')}>
|
||||
{login === state?.host ? 'Zrušit lobby' : 'Odejít'}
|
||||
</Button>);
|
||||
if (login === state?.host) {
|
||||
buttons.push(<Button key="start" onClick={() => send('tetris:start')}
|
||||
disabled={(state?.players.length ?? 0) < (state?.minPlayers ?? 1)}>Spustit hru</Button>);
|
||||
}
|
||||
}
|
||||
buttons.push(<Button key="close" variant="secondary" onClick={() => setOpen(false)}>Zavřít</Button>);
|
||||
@@ -503,7 +514,9 @@ export default function TetrisGame() {
|
||||
<>
|
||||
{showInvite && (
|
||||
<button className="duel-invite tetris-invite" onClick={() => setOpen(true)}>
|
||||
{icon} <strong>{state?.host}</strong> zve na Tetris — připojit se
|
||||
{icon} {phase === 'countdown'
|
||||
? <>Tetris začíná za <strong>{state?.countdown} s</strong> — připojit se</>
|
||||
: <><strong>{state?.host}</strong> zve na Tetris — připojit se</>}
|
||||
</button>
|
||||
)}
|
||||
{showReturn && (
|
||||
|
||||
Reference in new issue
Block a user