From 27ed51301103f5ac794b056e28444883adecbc08 Mon Sep 17 00:00:00 2001 From: EJClaw Date: Sun, 11 Oct 2026 01:44:20 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=80=EA=B8=B0=EC=8B=A4=20=EA=B2=8C?= =?UTF-8?q?=EC=9E=84=20=EC=84=A4=EC=A0=95:=20=EC=B0=B8=EC=97=AC=EC=9E=90?= =?UTF-8?q?=EB=8F=84=20=EB=B3=B4=EA=B8=B0=20=EC=A0=84=EC=9A=A9=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=A0=84=EC=B2=B4=20=EC=84=A4=EC=A0=95=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 방장이 아닌 사람도 방장과 같은 설정 화면(자세한 설정 포함)을 본다. 모든 버튼·입력은 잠겨 있고 "자세한 설정" 펼치기만 된다. 휴대폰은 [설정 보기], PC는 카드 안에 바로 펼침. 서버는 이미 방장 외 config를 거절한다. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/pages/RoomPage.tsx | 64 +++++++++++++++++++++++++-------- apps/web/src/styles/global.css | 11 ++++++ docs/06-lobby-rooms.md | 2 +- e2e/omok.e2e.ts | 15 ++++++++ 4 files changed, 77 insertions(+), 15 deletions(-) diff --git a/apps/web/src/pages/RoomPage.tsx b/apps/web/src/pages/RoomPage.tsx index d639281..e298eef 100644 --- a/apps/web/src/pages/RoomPage.tsx +++ b/apps/web/src/pages/RoomPage.tsx @@ -1,5 +1,5 @@ /** 방: 대기실 ↔ 게임 ↔ 결과를 한 주소에서 전환 (docs/06 §5–§9). */ -import { useEffect, useMemo, useRef, useState } from 'react'; +import { useEffect, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from 'react'; import { Link, useNavigate, useParams } from 'react-router'; import { botsAllowed, formatRoomCode, isBotId, type PublicUser, type RoomView } from '@bg/shared/lite'; import { Avatar, CodeLabel, ConfirmSheet, CopyButton, ShareButton, Sheet, TopBar } from '../components/ui'; @@ -409,16 +409,17 @@ function Lobby({ room, ui, me }: { room: RoomView; ui: GameUI; me: PublicUser })

게임 설정

{ui.optionsSummary(room.options)}

- {isHost && !wide && ( + {!wide && ( )} + {!isHost &&

👑 설정은 방장만 바꿀 수 있어요. 여기서는 볼 수만 있어요.

} {practice &&

🤖 연습 게임이에요. 기록에는 남지 않아요.

} {room.lockedOptions.length > 0 &&

🔒 일부 규칙은 관리자가 정해 두어서 바꿀 수 없어요.

} - {isHost && wide && } + {wide && } ); const guestLine = me.kind === 'guest' && !practice && ; @@ -466,7 +467,7 @@ function Lobby({ room, ui, me }: { room: RoomView; ui: GameUI; me: PublicUser }) {qr && setQr(false)} />} - {settings && setSettings(false)} />} + {settings && setSettings(false)} />} {askStart && ( socket.send({ t: 'start' })} onClose={() => setAskStart(false)} /> )} @@ -508,20 +509,23 @@ function HostMenu({ room, target }: { room: RoomView; target: PublicUser }) { ); } -function SettingsSheet({ room, ui, onClose }: { room: RoomView; ui: GameUI; onClose: () => void }) { +function SettingsSheet({ room, ui, readOnly, onClose }: { room: RoomView; ui: GameUI; readOnly: boolean; onClose: () => void }) { return (

게임 설정

- + {readOnly &&

👑 설정은 방장만 바꿀 수 있어요.

} +
); } /** - * Host settings: game options + room options. Inline on PC, in a sheet on narrow screens. - * Every change is sent right away, so [게임 시작] always uses what is on screen. + * Game options + room options. Inline on PC, in a sheet on narrow screens. + * Host: every change is sent right away, so [게임 시작] always uses what is on screen. + * Everyone else (`readOnly`): the same form showing the room's current options, with every control locked + * (only "▼ 자세한 설정" still opens, so the hidden rules can be read too). The server refuses non-host config anyway. */ -function SettingsForm({ room, ui, inline, onDone }: { room: RoomView; ui: GameUI; inline?: boolean; onDone?: () => void }) { +function SettingsForm({ room, ui, inline, readOnly, onDone }: { room: RoomView; ui: GameUI; inline?: boolean; readOnly?: boolean; onDone?: () => void }) { const [options, setOptions] = useState(room.options); const sync = useRef(new OptionSync()); useEffect(() => { @@ -546,17 +550,23 @@ function SettingsForm({ room, ui, inline, onDone }: { room: RoomView; ui: GameUI ); return (
- {room.lockedOptions.length > 0 &&

🔒 관리자가 고정한 규칙은 바꿔도 저장되지 않아요.

} - + {!readOnly && room.lockedOptions.length > 0 &&

🔒 관리자가 고정한 규칙은 바꿔도 저장되지 않아요.

} + {readOnly ? ( + + {}} /> + + ) : ( + + )}
관전 - {seg(room.allowSpectators, (allowSpectators) => socket.send({ t: 'config', allowSpectators }), '허용', '안 됨')} + {readOnly ? {seg(room.allowSpectators, () => {}, '허용', '안 됨')} : seg(room.allowSpectators, (allowSpectators) => socket.send({ t: 'config', allowSpectators }), '허용', '안 됨')}
채팅 - {seg(room.chatEnabled, (chatEnabled) => socket.send({ t: 'config', chatEnabled }), '켜기', '끄기')} + {readOnly ? {seg(room.chatEnabled, () => {}, '켜기', '끄기')} : seg(room.chatEnabled, (chatEnabled) => socket.send({ t: 'config', chatEnabled }), '켜기', '끄기')}
{!inline && ( @@ -568,6 +578,32 @@ function SettingsForm({ room, ui, inline, onDone }: { room: RoomView; ui: GameUI ); } +/** + * Locks every control inside (each game's options form has its own buttons, selects and inputs), except + * disclosure toggles (`aria-expanded`, e.g. "▼ 자세한 설정") so hidden rules can still be opened and read. + * Re-locks whatever the form renders later (opening "자세한 설정" adds new controls). + */ +function ReadOnlyControls({ children }: { children: ReactNode }) { + const ref = useRef(null); + useLayoutEffect(() => { + const root = ref.current!; + const lock = () => { + root.querySelectorAll('button:not([aria-expanded]), input, select, textarea').forEach((el) => { + if (!el.disabled) el.disabled = true; + }); + }; + lock(); + const mo = new MutationObserver(lock); + mo.observe(root, { childList: true, subtree: true, attributes: true, attributeFilter: ['disabled'] }); + return () => mo.disconnect(); + }, []); + return ( +
+ {children} +
+ ); +} + // ---------------------------------------------------------------- game function GameView({ room, ui, me, players, pending, slow }: { room: RoomView; ui: GameUI; me: PublicUser; players: Record; pending: boolean; slow: boolean }) { diff --git a/apps/web/src/styles/global.css b/apps/web/src/styles/global.css index 35fd167..ecc02de 100644 --- a/apps/web/src/styles/global.css +++ b/apps/web/src/styles/global.css @@ -1370,6 +1370,17 @@ button.header-user { gap: 6px; } +/* 참여자가 보는 게임 설정(보기 전용): 고른 값은 또렷하게, 나머지는 흐리게. 눌러도 안 바뀐다는 게 보이도록. */ +.options-view :disabled { + cursor: default; + color: inherit; + opacity: 0.5; +} +.options-view [aria-pressed='true']:disabled, +.options-view :is(input, select, textarea):disabled { + opacity: 1; +} + /* ===================================================================== PC 정리 (2026-10-09, "PC버전을 좀더"): 넓은 화면에서 한 줄 화면을 1,200px로 늘리지 않는다. ===================================================================== */ diff --git a/docs/06-lobby-rooms.md b/docs/06-lobby-rooms.md index ead141b..0119bab 100644 --- a/docs/06-lobby-rooms.md +++ b/docs/06-lobby-rooms.md @@ -39,7 +39,7 @@ - 닉네임(자리, 관전자 목록, 결과 화면)을 누르면 기록 카드가 뜬다: 이 게임의 판·승·패·무·승률, 이 방 전적, 전체 게임 합계. 패 = 판 - 승 - 무(1등이 아니면 패). 컴퓨터는 누를 수 없다. `GET /api/users/:id/stats`(로그인 필요). - 게스트에게는 [게임 시작]/[준비하기] 아래에 한 줄로 "⚠️ 게스트 기록은 하루 동안 안 들어오면 지워져요."를 보인다(연습 방 제외). - 규칙 설명은 대기실에 펼쳐 두지 않는다. 방 막대의 [📖 규칙]으로 본다. -3. **게임 설정 요약**: "오목 · 렌주룰 · 한 수 30초" + 방장에게만 [설정 바꾸기]. +3. **게임 설정**: 요약 "오목 · 렌주룰 · 한 수 30초" + 방장은 [설정 바꾸기], 나머지는 [설정 보기](PC는 카드 안에 바로 펼침). 참여자도 방장과 같은 설정 화면(자세한 설정 포함)을 보지만 모든 버튼이 잠겨 있어 바꿀 수 없다. "👑 설정은 방장만 바꿀 수 있어요" 안내. 방장이 바꾸면 바로 따라 바뀐다(2026-10-11). 서버도 방장 외 `config`를 거절한다. 4. **아래 고정 버튼**(엄지 닿는 곳): - 방장: [게임 시작] — 최소 인원이 안 되면 비활성 + "1명 더 필요해요" 안내. 모두 준비가 아니어도 시작 가능하되 "준비 안 된 사람이 있어요. 시작할까요?" 확인. - 나머지: [준비하기] / [준비 취소]. diff --git a/e2e/omok.e2e.ts b/e2e/omok.e2e.ts index 41a9fe9..b7628a4 100644 --- a/e2e/omok.e2e.ts +++ b/e2e/omok.e2e.ts @@ -96,6 +96,21 @@ try { await a.getByText('자유룰 · 15줄 · 시간 제한 없음').waitFor(); await b.getByText('자유룰 · 15줄 · 시간 제한 없음').waitFor(); await a.screenshot({ path: join(SHOTS, '1-lobby-pc.png') }); + // B (not host) can open the same settings, read-only: the host's choices show, nothing can be pressed, + // and "자세한 설정" still opens so the hidden rules can be read too. + await b.getByText('설정은 방장만 바꿀 수 있어요').first().waitFor(); + if (await b.getByRole('button', { name: '설정 바꾸기' }).count()) throw new Error('non-host sees 설정 바꾸기'); + await b.getByRole('button', { name: '설정 보기' }).click(); + const sheet = b.getByRole('dialog', { name: '게임 설정' }); + const free = sheet.getByRole('button', { name: '자유룰' }); + if ((await free.getAttribute('aria-pressed')) !== 'true' || !(await free.isDisabled())) throw new Error('read-only 자유룰 not shown as chosen + locked'); + if (!(await sheet.getByRole('button', { name: '렌주룰' }).isDisabled())) throw new Error('non-host can press 렌주룰'); + if (!(await sheet.getByRole('button', { name: '허용' }).isDisabled())) throw new Error('non-host can press 관전 허용'); + await sheet.getByRole('button', { name: '▼ 자세한 설정' }).click(); + if (!(await sheet.getByRole('button', { name: '19줄' }).isDisabled())) throw new Error('non-host can press 19줄 (자세한 설정)'); + await b.screenshot({ path: join(SHOTS, '5b-lobby-phone-settings-view.png') }); + await sheet.getByRole('button', { name: '닫기', exact: true }).click(); + await b.getByText('자유룰 · 15줄 · 시간 제한 없음').waitFor(); await a.getByRole('button', { name: '▶ 게임 시작' }).click(); await a.getByRole('button', { name: '시작하기' }).click(); await a.getByText('내 차례예요').waitFor();