모든 게임이 남는 화면 전체를 쓰도록: 게임별 폭 상한 제거, 판·카드·말을 --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:
@@ -1,5 +1,5 @@
|
||||
/** 고스톱 / 맞고 화면 (docs/games/gostop.md §9). Points are room-only play points. */
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import type { BakKind, CardView, GostopOptions, GostopView, HandCardView, OutcomeView, SeatView, TurnTag } from '@bg/games/gostop';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar, Sheet } from '../../components/ui';
|
||||
@@ -49,6 +49,15 @@ function useNarrow(): boolean {
|
||||
return narrow;
|
||||
}
|
||||
|
||||
/** Card size factor for the board (PC: grows with the play area, see GostopBoard). */
|
||||
const CardScale = createContext(1);
|
||||
const HW = { sm: 40, md: 60, lg: 84 } as const;
|
||||
/** Card width in px for a HwatuCard size, scaled for the play area. */
|
||||
function useCardW(): (size: keyof typeof HW) => number {
|
||||
const k = useContext(CardScale);
|
||||
return (size) => Math.round(HW[size] * k);
|
||||
}
|
||||
|
||||
function totalMsOf(v: GostopView): number {
|
||||
if (v.phase === 'roundResult') return 10_000;
|
||||
const who = v.step === 'sell' ? v.sell?.current : v.turn;
|
||||
@@ -93,7 +102,7 @@ function statusText(v: GostopView, me: string | null, players: Record<string, Pu
|
||||
}
|
||||
|
||||
const CSS = `
|
||||
.gs { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 8px; align-self: center; margin: auto 0; }
|
||||
.gs { width: 100%; display: flex; flex-direction: column; gap: 8px; align-self: center; margin: auto 0; }
|
||||
.gs-opps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
|
||||
.gs-seat { background: var(--surface); color: var(--text); border-radius: 12px; padding: 6px 10px; border: 3px solid transparent;
|
||||
box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
|
||||
@@ -116,20 +125,20 @@ const CSS = `
|
||||
.gs-pile { display: flex; flex-direction: column; gap: 1px; min-width: 40px; }
|
||||
.gs-pile b { font-size: .78rem; font-weight: 800; color: var(--text-sub); white-space: nowrap; }
|
||||
.gs-pile-cards { display: flex; }
|
||||
.gs-pile-cards > * + * { margin-left: var(--ov, -30px); }
|
||||
.gs-pile-cards > * + * { margin-left: calc(var(--ov, -30px) * var(--gk, 1)); }
|
||||
.gs-cap[aria-expanded='true'] .gs-pile-cards > * + * { --ov: -14px; }
|
||||
.gs-table { border-radius: 20px; border: 8px solid var(--wood); box-shadow: var(--shadow); color: #fff; padding: 10px;
|
||||
background: radial-gradient(ellipse at center, rgba(255,255,255,.12), rgba(255,255,255,0) 65%), var(--felt);
|
||||
display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 10px; align-items: stretch; }
|
||||
display: grid; grid-template-columns: minmax(0, 1fr) calc(210px * var(--gk, 1)); gap: 10px; align-items: stretch; }
|
||||
.gs-floor { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; list-style: none; margin: 0; padding: 0; }
|
||||
.gs-slot { min-height: 104px; border-radius: 10px; border: 2px dashed rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; position: relative; }
|
||||
.gs-slot { min-height: calc(104px * var(--gk, 1)); border-radius: 10px; border: 2px dashed rgba(255,255,255,.16); display: flex; align-items: center; justify-content: center; position: relative; }
|
||||
.gs-slot .m { position: absolute; top: 1px; left: 6px; font-size: .72rem; font-weight: 700; color: rgba(255,255,255,.55); }
|
||||
.gs-slot.has { border-style: solid; border-color: rgba(255,255,255,.28); }
|
||||
.gs-slot.ppeok { border: 3px solid #f87171; background: rgba(239,68,68,.18); }
|
||||
.gs-slot.ppeok::after { content: '뻑'; position: absolute; right: 4px; top: 2px; font-size: .75rem; font-weight: 900; color: #fecaca; }
|
||||
.gs-slot.natural::after { content: '3장'; }
|
||||
.gs-slot-cards { display: flex; }
|
||||
.gs-slot-cards > * + * { margin-left: var(--sov, -40px); }
|
||||
.gs-slot-cards > * + * { margin-left: var(--sov, calc(-40px * var(--gk, 1))); }
|
||||
.gs-glow { animation: gs-blink .9s ease-in-out infinite; border-radius: 8px; }
|
||||
@keyframes gs-blink { 0%, 100% { filter: drop-shadow(0 0 2px #fde047); } 50% { filter: drop-shadow(0 0 10px #fde047) brightness(1.08); } }
|
||||
.gs-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
||||
@@ -166,6 +175,11 @@ const CSS = `
|
||||
.gs-res td { padding: 3px 4px; border-bottom: 1px solid var(--border); }
|
||||
.gs-res td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
|
||||
.gs-notice { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; margin: 0; }
|
||||
/* PC: fill the play column; the floor takes the height the seats leave (cards grow with the area, see GostopBoard). */
|
||||
@media (min-width: 1100px) {
|
||||
.gs { align-self: stretch; flex: 1 1 auto; min-height: 0; margin: 0; }
|
||||
.gs-table { flex: 1 1 auto; }
|
||||
}
|
||||
@media (max-width: 719px) {
|
||||
.gs-opps { grid-template-columns: 1fr; }
|
||||
.gs-table { grid-template-columns: 1fr; border-width: 5px; padding: 8px; }
|
||||
@@ -182,18 +196,20 @@ const CSS = `
|
||||
|
||||
function Card({ c, size = 'sm', className, style }: { c: CardView | null; size?: 'sm' | 'md' | 'lg'; className?: string; style?: React.CSSProperties }) {
|
||||
const card = c as HwatuInfo | null;
|
||||
const cw = useCardW();
|
||||
return className ? (
|
||||
<span className={className} style={{ display: 'inline-flex', ...style }}>
|
||||
<HwatuCard card={card} size={size} />
|
||||
<HwatuCard card={card} width={cw(size)} />
|
||||
</span>
|
||||
) : (
|
||||
<HwatuCard card={card} size={size} style={style} />
|
||||
<HwatuCard card={card} width={cw(size)} style={style} />
|
||||
);
|
||||
}
|
||||
|
||||
function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const groups = (['gwang', 'yeol', 'tti', 'pi'] as const).filter((k) => seat.captured[k].length > 0);
|
||||
const cw = useCardW();
|
||||
if (groups.length === 0)
|
||||
return (
|
||||
<span className="small muted" data-fx-cap={seat.id}>
|
||||
@@ -210,7 +226,7 @@ function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
|
||||
<span className="gs-pile-cards">
|
||||
{seat.captured[k].map((c) => (
|
||||
<span key={c.key} data-gs-cap={c.key} style={{ display: 'inline-flex' }}>
|
||||
<HwatuCard card={c as HwatuInfo} size="sm" />
|
||||
<HwatuCard card={c as HwatuInfo} width={cw('sm')} />
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
@@ -310,9 +326,28 @@ function SeatBox({ seat, v, players, me, deadline }: { seat: SeatView; v: Gostop
|
||||
function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>; narrow: boolean; players: Record<string, PublicUser> }) {
|
||||
const months = Array.from({ length: 12 }, (_, i) => i + 1);
|
||||
const pf = v.pendingFlip;
|
||||
const cw = useCardW();
|
||||
// PC: floor cards fill their month slot (3 overlapping cards across, one card high), never smaller than the base size.
|
||||
const floorRef = useRef<HTMLUListElement | null>(null);
|
||||
const [fit, setFit] = useState(0);
|
||||
useLayoutEffect(() => {
|
||||
const el = floorRef.current;
|
||||
if (!el) return undefined;
|
||||
const measure = () => {
|
||||
if (window.innerWidth < 1100) return setFit(0);
|
||||
const slotW = (el.clientWidth - 5 * 6) / 6;
|
||||
const slotH = (el.clientHeight - 6) / 2;
|
||||
setFit(Math.floor(Math.min(150, (slotW - 10) / 1.66, (slotH - 24) / 1.63)));
|
||||
};
|
||||
const ro = new ResizeObserver(measure);
|
||||
ro.observe(el);
|
||||
measure();
|
||||
return () => ro.disconnect();
|
||||
}, []);
|
||||
const fw = narrow ? 40 : Math.max(cw('md'), fit);
|
||||
return (
|
||||
<div className="gs-table" role="region" aria-label="바닥">
|
||||
<ul className="gs-floor" data-fx="gs-floor" aria-label="바닥 패(월별)">
|
||||
<ul className="gs-floor" ref={floorRef} data-fx="gs-floor" aria-label="바닥 패(월별)" style={fit ? ({ '--sov': `${-Math.round(fw * 0.67)}px` } as React.CSSProperties) : undefined}>
|
||||
{months.map((m) => {
|
||||
const g = v.floor.find((x) => x.month === m);
|
||||
const cls = `gs-slot${g ? ' has' : ''}${g && g.cards.length === 3 ? (g.natural ? ' ppeok natural' : ' ppeok') : ''}`;
|
||||
@@ -328,7 +363,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
|
||||
<span className="gs-slot-cards">
|
||||
{g.cards.map((c) => (
|
||||
<span key={c.key} className={glow.has(c.id) ? 'gs-glow' : undefined} data-gs-floor={c.key} style={{ display: 'inline-flex' }}>
|
||||
<HwatuCard card={c as HwatuInfo} size={narrow ? 'sm' : 'md'} />
|
||||
<HwatuCard card={c as HwatuInfo} width={fw} />
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
@@ -340,7 +375,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
|
||||
<div className="gs-side">
|
||||
<div className="gs-deck">
|
||||
<div data-fx="gs-deck" aria-label={`더미 ${v.deckCount}장`} style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 2 }}>
|
||||
<HwatuCard card={null} size={narrow ? 'sm' : 'md'} />
|
||||
<HwatuCard card={null} width={narrow ? 40 : cw('md')} />
|
||||
<strong>{v.deckCount}장</strong>
|
||||
</div>
|
||||
<div className="gs-info">
|
||||
@@ -358,7 +393,7 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
|
||||
<div aria-label={`뒤집은 패 ${pf.flipped.name}`} style={{ textAlign: 'center' }}>
|
||||
<div className="small">뒤집은 패</div>
|
||||
<span className="gs-glow" data-fx="gs-pflip" style={{ display: 'inline-flex' }}>
|
||||
<HwatuCard card={pf.flipped as HwatuInfo} size="sm" />
|
||||
<HwatuCard card={pf.flipped as HwatuInfo} width={cw('sm')} />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
@@ -426,6 +461,7 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
|
||||
const [ask, setAsk] = useState<Ask>(null);
|
||||
const canPlay = v.step === 'play' && v.turn === v.me && !pending;
|
||||
const hints = v.rules.hints;
|
||||
const cw = useCardW();
|
||||
useEffect(() => {
|
||||
setLifted(null);
|
||||
setAsk(null);
|
||||
@@ -476,7 +512,7 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
|
||||
onFocus={() => onFocusCard(h)}
|
||||
onBlur={() => onFocusCard(null)}
|
||||
>
|
||||
<HwatuCard card={h.card as HwatuInfo} size="md" />
|
||||
<HwatuCard card={h.card as HwatuInfo} width={cw('md')} />
|
||||
{tag && <span className={`tag${h.canShake ? ' shake' : ''}`}>{tag}</span>}
|
||||
</button>
|
||||
);
|
||||
@@ -1115,6 +1151,23 @@ function useGostopFx(v: GostopView, me: string | null, players: Record<string, P
|
||||
function GostopBoard(props: BoardProps<GostopView>) {
|
||||
const { view: v, me, players } = props;
|
||||
const narrow = useNarrow();
|
||||
// PC: cards grow with the play area (1 at the old 1100 px column, up to 1.7×; the height check keeps it on screen).
|
||||
const rootRef = useRef<HTMLDivElement | null>(null);
|
||||
const [k, setK] = useState(1);
|
||||
useLayoutEffect(() => {
|
||||
const el = rootRef.current;
|
||||
if (!el) return undefined;
|
||||
const wide = matchMedia('(min-width: 1100px)');
|
||||
const measure = () => setK(wide.matches ? Math.min(1.7, Math.max(1, Math.min(el.clientWidth / 1100, el.clientHeight / 640))) : 1);
|
||||
const ro = new ResizeObserver(measure);
|
||||
ro.observe(el);
|
||||
wide.addEventListener('change', measure);
|
||||
measure();
|
||||
return () => {
|
||||
ro.disconnect();
|
||||
wide.removeEventListener('change', measure);
|
||||
};
|
||||
}, []);
|
||||
const [focus, setFocus] = useState<HandCardView | null>(null);
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const mine = isMyTurn(v, me);
|
||||
@@ -1149,22 +1202,24 @@ function GostopBoard(props: BoardProps<GostopView>) {
|
||||
const glow = new Set<number>(v.rules.hints && focus ? focus.matches : []);
|
||||
if (v.pendingFlip) for (const c of v.pendingFlip.options) glow.add(c.id);
|
||||
return (
|
||||
<div className="gs">
|
||||
<style>{CSS}</style>
|
||||
<ul className="gs-opps" aria-label={me ? '다른 사람' : '플레이어'}>
|
||||
{others.map((s) => (
|
||||
<SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={props.deadline} />
|
||||
))}
|
||||
</ul>
|
||||
<Floor v={v} glow={glow} narrow={narrow} players={players} />
|
||||
<RoundResult {...props} />
|
||||
<MyArea {...props} onFocusCard={setFocus} />
|
||||
<Decisions {...props} />
|
||||
{banner}
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
</div>
|
||||
<CardScale.Provider value={k}>
|
||||
<div className="gs" ref={rootRef} style={{ '--gk': k.toFixed(2) } as React.CSSProperties}>
|
||||
<style>{CSS}</style>
|
||||
<ul className="gs-opps" aria-label={me ? '다른 사람' : '플레이어'}>
|
||||
{others.map((s) => (
|
||||
<SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={props.deadline} />
|
||||
))}
|
||||
</ul>
|
||||
<Floor v={v} glow={glow} narrow={narrow} players={players} />
|
||||
<RoundResult {...props} />
|
||||
<MyArea {...props} onFocusCard={setFocus} />
|
||||
<Decisions {...props} />
|
||||
{banner}
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
</div>
|
||||
</CardScale.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user