시간 제한 없음은 정말 무제한, 대기실 설정은 바꾸면 바로 적용, 모르는 사람 기다리기(빠른 시작·공개 방) 제거
- 오목에서 [시간 제한 없음]을 골라도 30초가 흐르던 문제: 대기실 설정이 [설정 저장]을 눌러야 서버에 반영되어, 누르지 않고 [게임 시작]하면 기본값(한 수 30초)으로 시작했다. 이제 설정은 바꾸는 즉시 서버에 보낸다(저장 버튼 없음, 휴대폰 시트는 [닫기]만). 빠르게 여러 번 눌러도 먼저 온 방 정보가 새 값을 되돌리지 않게 lib/option-sync.ts로 맞춘다. - 시간 제한 없음(오목·체스·장기·오델로·바둑·쿼리도): 무응답 한도(idleLimitSec, 5~10분 뒤 시간패)와 그 카운트다운을 없앴다. 체스는 첫 수 제한도 피셔일 때만. 연결이 끊긴 사람의 접속 유예는 그대로. - 홈의 [지금 열린 방] 탭, 게임 소개의 [아무나와 빠른 시작]·기다리는 방 목록, 대기실의 방 공개 설정을 뺐다(방은 모두 친구만). 서버 API는 남겨 두고 화면에서만 부르지 않는다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { QrModal } from '../components/QrModal';
|
||||
import { api, type RoomPreview } from '../net/api';
|
||||
import { socket, useRoom } from '../net/socket';
|
||||
import { useSession } from '../store/session';
|
||||
import { OptionSync, withLocks } from '../lib/option-sync';
|
||||
import { loadGameUI } from '../games/registry';
|
||||
import type { GameUI } from '../games/types';
|
||||
import { sounds } from '../lib/feedback';
|
||||
@@ -390,7 +391,6 @@ function Lobby({ room, ui, me }: { room: RoomView; ui: GameUI; me: PublicUser })
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className="muted small">{room.visibility === 'public' ? '공개 방 (누구나 들어올 수 있어요)' : '친구만 (코드·링크로만 들어와요)'}</p>
|
||||
{practice && <p className="small">🤖 연습 게임이에요. 기록에는 남지 않아요.</p>}
|
||||
{me.kind === 'guest' && !practice && <GuestWarning />}
|
||||
{room.lockedOptions.length > 0 && <p className="muted small">🔒 일부 규칙은 관리자가 정해 두어서 바꿀 수 없어요.</p>}
|
||||
@@ -497,22 +497,22 @@ function SettingsSheet({ room, ui, onClose }: { room: RoomView; ui: GameUI; onCl
|
||||
);
|
||||
}
|
||||
|
||||
/** Host settings: game options + room options. Inline on PC, in a sheet on narrow screens. */
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function SettingsForm({ room, ui, inline, onDone }: { room: RoomView; ui: GameUI; inline?: boolean; onDone?: () => void }) {
|
||||
const [options, setOptions] = useState(room.options);
|
||||
const [visibility, setVisibility] = useState(room.visibility);
|
||||
const [allowSpectators, setAllowSpectators] = useState(room.allowSpectators);
|
||||
const [chatEnabled, setChatEnabled] = useState(room.chatEnabled);
|
||||
// Follow server-side changes (e.g. admin locks) when not editing.
|
||||
useEffect(() => setOptions(room.options), [room.options]);
|
||||
const dirty =
|
||||
JSON.stringify(options) !== JSON.stringify(room.options) ||
|
||||
visibility !== room.visibility ||
|
||||
allowSpectators !== room.allowSpectators ||
|
||||
chatEnabled !== room.chatEnabled;
|
||||
const save = () => {
|
||||
socket.send({ t: 'config', options, visibility, allowSpectators, chatEnabled });
|
||||
onDone?.();
|
||||
const sync = useRef(new OptionSync());
|
||||
useEffect(() => {
|
||||
if (sync.current.received(room.options)) setOptions(room.options);
|
||||
}, [room.options]);
|
||||
const changeOptions = (next: typeof options) => {
|
||||
// Admin-locked rules keep the room's value, exactly as the server will (so the echo matches).
|
||||
const out = withLocks(next, room.options, room.lockedOptions);
|
||||
sync.current.sent(room.options, out);
|
||||
setOptions(out);
|
||||
socket.send({ t: 'config', options: out });
|
||||
};
|
||||
const seg = (value: boolean, set: (v: boolean) => void, on: string, off: string) => (
|
||||
<div className="segmented">
|
||||
@@ -527,36 +527,24 @@ function SettingsForm({ room, ui, inline, onDone }: { room: RoomView; ui: GameUI
|
||||
return (
|
||||
<div className="stack" style={{ gap: 14 }}>
|
||||
{room.lockedOptions.length > 0 && <p className="muted small">🔒 관리자가 고정한 규칙은 바꿔도 저장되지 않아요.</p>}
|
||||
<ui.Options value={options} onChange={setOptions} />
|
||||
<p className="muted small">바꾸면 바로 적용돼요.</p>
|
||||
<ui.Options value={options} onChange={changeOptions} />
|
||||
<hr style={{ border: 0, borderTop: '1px solid var(--border)', width: '100%' }} />
|
||||
<div style={{ display: 'grid', gridTemplateColumns: inline ? 'repeat(3, minmax(0, 1fr))' : '1fr', gap: 12 }}>
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<strong>방 공개</strong>
|
||||
{room.seats.some((s) => s && isBotId(s.user.id)) ? (
|
||||
<p className="muted small">컴퓨터가 있는 방은 친구만 들어와요.</p>
|
||||
) : (
|
||||
seg(visibility === 'public', (v) => setVisibility(v ? 'public' : 'private'), '누구나', '친구만')
|
||||
)}
|
||||
</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: inline ? 'repeat(2, minmax(0, 1fr))' : '1fr', gap: 12 }}>
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<strong>관전</strong>
|
||||
{seg(allowSpectators, setAllowSpectators, '허용', '안 됨')}
|
||||
{seg(room.allowSpectators, (allowSpectators) => socket.send({ t: 'config', allowSpectators }), '허용', '안 됨')}
|
||||
</div>
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<strong>채팅</strong>
|
||||
{seg(chatEnabled, setChatEnabled, '켜기', '끄기')}
|
||||
{seg(room.chatEnabled, (chatEnabled) => socket.send({ t: 'config', chatEnabled }), '켜기', '끄기')}
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
<button className="btn btn-primary" style={{ flex: 2 }} disabled={inline && !dirty} onClick={save}>
|
||||
{inline ? (dirty ? '설정 저장' : '저장됨') : '저장'}
|
||||
{!inline && (
|
||||
<button className="btn btn-primary btn-block" onClick={onDone}>
|
||||
닫기
|
||||
</button>
|
||||
{!inline && (
|
||||
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={onDone}>
|
||||
취소
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user