모든 게임이 남는 화면 전체를 쓰도록: 게임별 폭 상한 제거, 판·카드·말을 --play-w/--play-h에 맞춰 키움
- 카드 게임: 펠트가 남는 높이를 채우고 손패·가운데 더미·자리 크기가 화면에 따라 커짐 - 판 게임: 체스·바둑·오목 등은 높이를 다 쓰고, 장기·쿼리도·젬블로는 넓은 화면에서 조작판을 판 옆으로 - 섯다: 자리를 판 크기에 맞춘 타원 위에 고르게 두고, 많을 때 자리 크기를 줄여 8명에서도 겹치지 않게 - 바퀴벌레 포커 6명·야단법석 달리기 5명 선수 뽑기가 PC에서 넘치지 않게 - 휴대폰·태블릿(1100px 아래) 배치는 그대로 - layout-survey: 컴퓨터 넣기 버튼 기다림, 넘친 높이(px) 표시 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,7 +68,31 @@ const CSS = `
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.qd-pawn { transition: none; }
|
||||
.qd-wall-new, .qd-turn-ring { animation: none; }
|
||||
}`;
|
||||
}
|
||||
.board-wrap.qd-side { flex-direction: row; align-items: center; justify-content: center; gap: 20px; }
|
||||
.qd-side > .qd-rows { flex: 0 1 380px; min-width: 0; }
|
||||
.qd-side .qd-modes { grid-template-columns: 1fr; }
|
||||
.qd-rows:empty { display: none; }`;
|
||||
|
||||
/** PC play-area size (.game-main, px), null under 1100px where the page scrolls and rows stay under the board. */
|
||||
function useWideMain(ref: React.RefObject<HTMLElement | null>) {
|
||||
const [size, setSize] = useState<{ w: number; h: number } | null>(null);
|
||||
useLayoutEffect(() => {
|
||||
const main = ref.current?.closest<HTMLElement>('.game-main');
|
||||
if (!main) return;
|
||||
const wide = matchMedia('(min-width: 1100px)');
|
||||
const update = () => setSize(wide.matches ? { w: main.clientWidth, h: main.clientHeight } : null);
|
||||
update();
|
||||
const ro = new ResizeObserver(update);
|
||||
ro.observe(main);
|
||||
wide.addEventListener('change', update);
|
||||
return () => {
|
||||
ro.disconnect();
|
||||
wide.removeEventListener('change', update);
|
||||
};
|
||||
}, [ref]);
|
||||
return size;
|
||||
}
|
||||
|
||||
/** 판 돌리기: 모델 좌표(x 오른쪽, y 위쪽, 0~9) ↔ 화면 좌표(y 아래쪽). 네 가지 모두 자기 자신이 역변환. */
|
||||
function makeTf(seat: Seat | null) {
|
||||
@@ -159,6 +183,8 @@ function QuoridorBoard({ view: v, players, act, pending, tapConfirm }: BoardProp
|
||||
const [cursor, setCursor] = useState<Pt>({ x: 4, y: 8 });
|
||||
const [kbd, setKbd] = useState(false);
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const wrapRef = useRef<HTMLDivElement>(null);
|
||||
const main = useWideMain(wrapRef);
|
||||
const svgRef = useRef<SVGSVGElement>(null);
|
||||
const prevCount = useRef(v.moveCount);
|
||||
const [shake, setShake] = useState(0);
|
||||
@@ -383,14 +409,25 @@ function QuoridorBoard({ view: v, players, act, pending, tapConfirm }: BoardProp
|
||||
return { x: N - off - w, y: 0, width: w, height: N };
|
||||
};
|
||||
|
||||
// PC: the board fills the play-area height. The rows (mode buttons, wall tray, hint) go beside it when that gives a
|
||||
// bigger board than stacking them under it (which needs about `under` px of height).
|
||||
const under = me ? (tapConfirm ? 190 : 175) : 60;
|
||||
const besideW = main ? Math.floor(Math.min(main.w - 320, main.h)) : 0;
|
||||
const stackW = main ? Math.floor(Math.min(main.w, main.h - under)) : 0;
|
||||
const beside = !!main && besideW > stackW;
|
||||
|
||||
return (
|
||||
<div className="board-wrap stack" style={{ gap: 10, maxWidth: 'min(100%, calc(100vh - 340px))', minWidth: 'min(100%, 300px)' }}>
|
||||
<div
|
||||
ref={wrapRef}
|
||||
className={`board-wrap stack${beside ? ' qd-side' : ''}`}
|
||||
style={{ gap: 10, maxWidth: beside ? 'none' : main ? `min(100%, ${stackW}px)` : 'min(100%, calc(100vh - 340px))', minWidth: 'min(100%, 300px)' }}
|
||||
>
|
||||
<style>{BOARD_MOTION_CSS + CSS}</style>
|
||||
<svg
|
||||
ref={svgRef}
|
||||
className="qd-board"
|
||||
viewBox={`${-PAD} ${-PAD} ${N + 2 * PAD} ${N + 2 * PAD}`}
|
||||
style={{ width: '100%', display: 'block', background: 'var(--wood)', borderRadius: 14, touchAction: 'manipulation', cursor: myTurn ? 'pointer' : 'default', boxShadow: 'var(--shadow)' }}
|
||||
style={{ width: '100%', display: 'block', background: 'var(--wood)', borderRadius: 14, touchAction: 'manipulation', cursor: myTurn ? 'pointer' : 'default', boxShadow: 'var(--shadow)', ...(beside && { flex: '0 0 auto', width: besideW }) }}
|
||||
data-my-seat={v.mySeat ?? ''}
|
||||
data-mode={mode}
|
||||
data-path={path && v.myShortestPath ? v.myShortestPath.map(label).join(' ') : ''}
|
||||
@@ -564,61 +601,63 @@ function QuoridorBoard({ view: v, players, act, pending, tapConfirm }: BoardProp
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{me && v.phase === 'playing' && me.status === 'playing' && (
|
||||
<div className="qd-modes" role="group" aria-label="할 일 고르기">
|
||||
<button type="button" className={`btn ${mode === 'move' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'move'} disabled={!myTurn} onClick={() => setModeTo('move')}>
|
||||
🚶 말 움직이기
|
||||
</button>
|
||||
<button type="button" className={`btn ${mode === 'wall' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'wall'} disabled={!canWall} onClick={() => setModeTo('wall')}>
|
||||
🧱 벽 세우기 ({wallsLeft}개)
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{myTurn && mode === 'wall' && (
|
||||
<div className="qd-tray">
|
||||
<span className={`qd-hint small${preview?.why ? ' bad' : ''}`} role="status">
|
||||
{!preview
|
||||
? '판의 홈(칸 사이) 교차점을 눌러 벽 자리를 골라요.'
|
||||
: preview.why
|
||||
? `${wallText(preview.wall, t.swap)}: ${preview.why}`
|
||||
: `${wallText(preview.wall, t.swap)} · 상대 길 +${preview.legal!.opp}칸${preview.legal!.me ? ` · 내 길 +${preview.legal!.me}칸` : ''}`}
|
||||
</span>
|
||||
<button type="button" className="btn btn-secondary qd-rotate" onClick={() => {
|
||||
const o = orient === 'h' ? 'v' : 'h';
|
||||
setOrient(o);
|
||||
if (wallAt) pinWall(wallAt, o);
|
||||
}} aria-label={`벽 방향 바꾸기, 지금 ${orient === 'h' ? '가로' : '세로'}`}>
|
||||
↻ {orient === 'h' ? '가로' : '세로'}
|
||||
</button>
|
||||
<button type="button" className="btn btn-primary qd-confirm" disabled={!previewAnchor || !!preview?.why || pending} onClick={() => previewAnchor && doWall(previewAnchor)}>
|
||||
벽 세우기 확인
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{myTurn && mode === 'move' && movePreview && (
|
||||
<div className="row">
|
||||
<button className="btn btn-primary" style={{ flex: 2 }} disabled={pending} onClick={() => doMove(movePreview)}>
|
||||
{label(t.screenToCell(movePreview))}으로 이동
|
||||
</button>
|
||||
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setMovePreview(null)}>
|
||||
취소
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{me && v.phase === 'playing' && !(myTurn && mode === 'wall') && (
|
||||
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
|
||||
{me.status === 'playing'
|
||||
? `내 말은 ${COLOR_KO[me.seat]}(${SEAT_KO[me.seat]})이에요. ${myGoal} 줄(${COLOR_KO[me.seat]} 띠)에 먼저 닿으면 이겨요.`
|
||||
: me.status === 'finished'
|
||||
? '목표에 도착했어요! 남은 사람들의 순위가 정해질 때까지 지켜봐요.'
|
||||
: '게임에서 빠졌어요. 계속 지켜볼 수 있어요.'}
|
||||
</p>
|
||||
)}
|
||||
{!me && (
|
||||
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
|
||||
{v.seats.map((x) => `${nick(x.playerId)}: ${COLOR_KO[x.seat]} → ${SIDE_KO[t.goalSide(x.seat)]} 줄`).join(' · ')}
|
||||
</p>
|
||||
)}
|
||||
<div className="stack qd-rows" style={{ gap: 10 }}>
|
||||
{me && v.phase === 'playing' && me.status === 'playing' && (
|
||||
<div className="qd-modes" role="group" aria-label="할 일 고르기">
|
||||
<button type="button" className={`btn ${mode === 'move' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'move'} disabled={!myTurn} onClick={() => setModeTo('move')}>
|
||||
🚶 말 움직이기
|
||||
</button>
|
||||
<button type="button" className={`btn ${mode === 'wall' ? 'btn-primary' : 'btn-secondary'}`} aria-pressed={mode === 'wall'} disabled={!canWall} onClick={() => setModeTo('wall')}>
|
||||
🧱 벽 세우기 ({wallsLeft}개)
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{myTurn && mode === 'wall' && (
|
||||
<div className="qd-tray">
|
||||
<span className={`qd-hint small${preview?.why ? ' bad' : ''}`} role="status">
|
||||
{!preview
|
||||
? '판의 홈(칸 사이) 교차점을 눌러 벽 자리를 골라요.'
|
||||
: preview.why
|
||||
? `${wallText(preview.wall, t.swap)}: ${preview.why}`
|
||||
: `${wallText(preview.wall, t.swap)} · 상대 길 +${preview.legal!.opp}칸${preview.legal!.me ? ` · 내 길 +${preview.legal!.me}칸` : ''}`}
|
||||
</span>
|
||||
<button type="button" className="btn btn-secondary qd-rotate" onClick={() => {
|
||||
const o = orient === 'h' ? 'v' : 'h';
|
||||
setOrient(o);
|
||||
if (wallAt) pinWall(wallAt, o);
|
||||
}} aria-label={`벽 방향 바꾸기, 지금 ${orient === 'h' ? '가로' : '세로'}`}>
|
||||
↻ {orient === 'h' ? '가로' : '세로'}
|
||||
</button>
|
||||
<button type="button" className="btn btn-primary qd-confirm" disabled={!previewAnchor || !!preview?.why || pending} onClick={() => previewAnchor && doWall(previewAnchor)}>
|
||||
벽 세우기 확인
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{myTurn && mode === 'move' && movePreview && (
|
||||
<div className="row">
|
||||
<button className="btn btn-primary" style={{ flex: 2 }} disabled={pending} onClick={() => doMove(movePreview)}>
|
||||
{label(t.screenToCell(movePreview))}으로 이동
|
||||
</button>
|
||||
<button className="btn btn-secondary" style={{ flex: 1 }} onClick={() => setMovePreview(null)}>
|
||||
취소
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{me && v.phase === 'playing' && !(myTurn && mode === 'wall') && (
|
||||
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
|
||||
{me.status === 'playing'
|
||||
? `내 말은 ${COLOR_KO[me.seat]}(${SEAT_KO[me.seat]})이에요. ${myGoal} 줄(${COLOR_KO[me.seat]} 띠)에 먼저 닿으면 이겨요.`
|
||||
: me.status === 'finished'
|
||||
? '목표에 도착했어요! 남은 사람들의 순위가 정해질 때까지 지켜봐요.'
|
||||
: '게임에서 빠졌어요. 계속 지켜볼 수 있어요.'}
|
||||
</p>
|
||||
)}
|
||||
{!me && (
|
||||
<p className="small muted" style={{ margin: 0, textAlign: 'center' }}>
|
||||
{v.seats.map((x) => `${nick(x.playerId)}: ${COLOR_KO[x.seat]} → ${SIDE_KO[t.goalSide(x.seat)]} 줄`).join(' · ')}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user