한 판 더: 투표 대신 그 방 대기실로 돌아가기

- 결과 창 [🔁 한 판 더] → 누른 사람만 대기실 화면으로(탭마다 sessionStorage로 기억, 새로고침해도 유지)
- 앉은 사람(방장 제외)은 돌아오면서 준비 완료, 방장이 [게임 시작]
- 한 명이 안 누르면 결과 창에서 계속 기다리던 문제 해결
- e2e(omok·tutorial) 흐름, docs/03·06·07 갱신

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-11 01:29:43 +09:00
parent 4c967f4de4
commit ebf82fd105
6 changed files with 31 additions and 18 deletions

View File

@@ -91,6 +91,9 @@ function Room({ code, me }: { code: string; me: PublicUser }) {
const [ui, setUi] = useState<GameUI | null>(null);
const [leaveAsk, setLeaveAsk] = useState(false);
const [chatOpen, setChatOpen] = useState(false);
// [한 판 더] takes me back to this room's lobby after game N (kept per tab so a reload stays there).
const lobbyKey = `bg:lobby:${code}`;
const [lobbyAfter, setLobbyAfter] = useState<number | null>(() => Number(sessionStorage.getItem(lobbyKey)) || null);
const gameId = room?.gameId;
useEffect(() => {
@@ -144,7 +147,15 @@ function Room({ code, me }: { code: string; me: PublicUser }) {
}
const g = { nameKo: gameName(room.gameId) };
const inGame = room.status === 'playing' || room.status === 'paused' || (room.status === 'finished' && !!game);
const backInLobby = room.status === 'finished' && lobbyAfter === room.gameNo;
const inGame = room.status === 'playing' || room.status === 'paused' || (room.status === 'finished' && !!game && !backInLobby);
const toLobby = () => {
sessionStorage.setItem(lobbyKey, String(room.gameNo));
setLobbyAfter(room.gameNo);
// Seated people come back ready, so the host sees who wants another game.
const seat = room.seats.find((s) => s?.user.id === me.id);
if (seat && room.hostId !== me.id && !seat.ready) socket.send({ t: 'ready', ready: true });
};
// Games with their own chat channels (마피아) close the room chat while playing (the server refuses it too).
const roomChatClosed = !!ui.ownChat && (room.status === 'playing' || room.status === 'paused');
const doLeave = () => {
@@ -225,7 +236,7 @@ function Room({ code, me }: { code: string; me: PublicUser }) {
) : (
<Lobby room={room} ui={ui} me={me} />
)}
{room.status === 'finished' && result && game && <ResultPanel room={room} me={me} players={players} onLeave={doLeave} />}
{room.status === 'finished' && result && game && !backInLobby && <ResultPanel room={room} me={me} players={players} onLeave={doLeave} onAgain={toLobby} />}
<EmoteBubbles room={room} />
{chatOpen && !roomChatClosed && (
<Sheet onClose={() => setChatOpen(false)} label="채팅">
@@ -628,15 +639,12 @@ function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui
);
}
function ResultPanel({ room, me, players, onLeave }: { room: RoomView; me: PublicUser; players: Record<string, PublicUser>; onLeave: () => void }) {
function ResultPanel({ room, me, players, onLeave, onAgain }: { room: RoomView; me: PublicUser; players: Record<string, PublicUser>; onLeave: () => void; onAgain: () => void }) {
const result = useRoom((s) => s.result)!;
const [hidden, setHidden] = useState(false);
const played = useRef(false);
const seatedAll = room.seats.filter(Boolean).map((s) => s!.user.id);
const amSeated = seatedAll.includes(me.id);
// Computer players always agree to a rematch.
const seated = seatedAll.filter((u) => !isBotId(u));
const voted = room.rematchVotes.includes(me.id);
// Solo games (e.g. 요트 다이스) have one ranked player: neither a draw nor a win.
const solo = result.ranking.flat().length === 1;
const allFirst = !solo && result.ranking.length === 1;
@@ -678,11 +686,10 @@ function ResultPanel({ room, me, players, onLeave }: { room: RoomView; me: Publi
)),
)}
</div>
{amSeated && (
<button className="btn btn-primary btn-block" disabled={voted} onClick={() => socket.send({ t: 'rematch' })}>
{voted ? `다른 사람을 기다리는 중… (${room.rematchVotes.length}/${seated.length})` : `🔁 한 판 더 (${room.rematchVotes.length}/${seated.length})`}
</button>
)}
{/* Back to this room's lobby: seats, computers and settings can change before the host starts again. */}
<button className="btn btn-primary btn-block" onClick={onAgain}>
🔁 한 판 더
</button>
{/* One primary action (한 판 더); the rest share one quieter row. */}
<div className="row" style={{ gap: 8, flexWrap: 'nowrap' }}>
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setHidden(true)}>