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

- 결과 창 [🔁 한 판 더] → 누른 사람만 대기실 화면으로(탭마다 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)}>

View File

@@ -34,7 +34,7 @@
| `act` | `cs: number`, `a: Action` | 게임 행동. `cs`는 클라이언트 행동 번호(1부터 증가) |
| `chat` | `text`(1~200자) | 채팅 |
| `emote` | `id` | 빠른 반응(👍, 😂, "잘했어요!" 등 고정 목록) |
| `rematch` | — | 게임 끝난 뒤 "한 판 더" 투표 |
| `rematch` | — | 게임 끝난 뒤 "한 판 더" 투표(2026-10-11부터 화면은 [한 판 더]로 대기실에 돌아가고 이 메시지는 쓰지 않음) |
| `void` | — | 방장: 오류로 멈춘 게임을 무효로 끝내기 |
| `sync` | — | 전체 상태 다시 요청 |
| `ping` | `ts` | 지연 측정(10초마다) |

View File

@@ -66,7 +66,7 @@
## 9. 게임 끝
- 결과 화면: 순위, 점수, 핵심 장면 요약(예: "흑 5목 완성"), [한 판 더] [게임 바꾸기] [나가기].
- [한 판 더]는 투표: 자리에 앉은 사람 모두 누르면 같은 설정으로 즉시 새 게임(선/딜러는 규칙에 따라 교대). 안 누르는 사람이 있으면 그 사람이 [관전하기]로 일어나거나 방장이 [게임 시작]으로 바로 시작할 수 있다.
- [한 판 더]는 누른 사람을 그 방 대기실로 돌려보낸다(2026-10-11, 전에는 모두 눌러야 시작하는 투표라 한 명이 안 누르면 결과 창에서 계속 기다렸다). 자리에 앉은 사람이 누르면 "준비 완료"가 되어 방장이 누가 또 하고 싶은지 본다. 대기실에서 자리·컴퓨터·설정을 바꾼 뒤 방장이 [게임 시작]. 아직 결과 창을 보는 사람은 방장이 시작하면 새 판으로 넘어간다. 어느 판 뒤에 대기실로 왔는지는 탭마다 기억해서(`sessionStorage`) 새로고침해도 대기실에 남는다. 서버의 `rematch` 투표 메시지는 남아 있지만 화면에서는 쓰지 않는다.
- 기록: 끝난 게임은 `game_results`에 저장, 방 안에서 "이번 방 전적"(예: OO 3승 2패) 표시.
## 10. 공개 방 목록 (화면에서 뺌)

View File

@@ -115,7 +115,7 @@
- 방 막대 버튼은 마우스 환경에서 40px(막대 52px 안에 여유), 터치 기기에서는 48px.
- 방 안(대기실·게임·결과)에서는 사이트 상단 메뉴를 숨기고 방 막대(← 홈 · 게임 이름 · 🔗 방 코드 · 📖 규칙 · ⚙️ 설정 · 🚪 나가기) 한 줄만 둔다. 판이 그만큼 커진다. 높이 계산은 CSS 변수 `--site-h`(방 안에서는 0)를 쓴다.
- 채팅의 빠른 반응(이모지·짧은 말)은 한 줄. 넘치면 옆으로 밀어 본다.
- 결과 창: 진한 버튼은 [🔁 한 판 더] 하나. [판 보기]·[▶ 다시 보기]는 한 줄에 나란히, [방 나가기]는 글자 버튼, 공정성 확인은 접어 둔다.
- 결과 창: 진한 버튼은 [🔁 한 판 더] 하나(누르면 그 방 대기실로 돌아간다, docs/06 §결과). [판 보기]·[▶ 다시 보기]는 한 줄에 나란히, [방 나가기]는 글자 버튼, 공정성 확인은 접어 둔다.
### 3.6 관리자 (PC)
왼쪽 사이드바(220px)에 메뉴, 오른쪽에 내용. 표는 PC에서 표 형태, 좁은 화면에서는 카드 목록.
@@ -180,7 +180,7 @@
- 게임 상세
- 대기실(방장/참가자/관전자, 인원 부족/가득 참)
- 게임 화면(내 차례/남의 차례/연결 끊김/자리 비움/일시 정지)
- 결과 화면(승/패/무승부, 한 판 더 투표 중, ▶ 다시 보기)
- 결과 화면(승/패/무승부, 한 판 더 → 대기실, ▶ 다시 보기)
- 계정(게스트/디스코드, 내 게임 기록 목록 + [다시 보기])
- 다시 보기(`/replay/:gamePk`: 판은 읽기 전용, 처음/이전/재생·멈춤/다음/끝 + 슬라이더. PC는 오른쪽 칸, 폰은 아래 고정 막대. 못 보는 게임은 안내 문구, docs/09 §8)
- 오류(방 없음, 방 가득 참, 서버 업데이트, 오프라인)

View File

@@ -142,9 +142,13 @@ try {
await b.screenshot({ path: join(SHOTS, '4-result-phone.png') });
});
await step('한 판 더 → 새 게임 시작', async () => {
await a.getByRole('button', { name: /한 판 더/ }).click();
await step('한 판 더 → 대기실로 돌아가 준비 → 방장이 새 게임 시작', async () => {
await b.getByRole('button', { name: /한 판 더/ }).click();
await b.getByRole('button', { name: '준비 취소' }).waitFor();
await a.getByRole('button', { name: /한 판 더/ }).click();
await a.getByLabel('자리').getByText('준비 완료').waitFor();
await a.screenshot({ path: join(SHOTS, '5-back-in-lobby-pc.png') });
await a.getByRole('button', { name: '▶ 게임 시작' }).click();
await a.getByText(/차례예요|생각 중이에요/).waitFor();
});

View File

@@ -116,8 +116,10 @@ try {
await step('두 번째 판: 요약 카드가 다시 나오지 않아요', async () => {
await a.getByRole('button', { name: /기권/ }).click();
await a.getByRole('button', { name: '기권하기' }).click();
await a.getByRole('button', { name: /한 판 더/ }).click();
await b.getByRole('button', { name: /한 판 더/ }).click();
await a.getByRole('button', { name: /한 판 더/ }).click();
await a.getByLabel('자리').getByText('준비 완료').waitFor();
await a.getByRole('button', { name: '▶ 게임 시작' }).click();
await a.getByText(/차례예요|생각 중이에요/).first().waitFor();
await a.waitForTimeout(800);
if ((await cards(a).count()) + (await cards(b).count())) throw new Error('cards shown again');