모든 게임이 남는 화면 전체를 쓰도록: 게임별 폭 상한 제거, 판·카드·말을 --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/poker.md §9). Chips are room-only play points. */
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import type { BetActionType, LegalBetView, LogEntry, PokerMode, PokerOptions, PokerView, SeatView, Side, ViewCard } from '@bg/games/poker';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
|
||||
@@ -7,6 +7,7 @@ import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { PLAYING_CARD_CREDIT, PlayingCard } from '../../components/cards/PlayingCard';
|
||||
import { Chips, PlayChipNotice, formatChips } from '../../components/cards/Chips';
|
||||
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
|
||||
import { useWide } from '../../lib/media';
|
||||
import { bump, cssEsc, flyFrom, flyGhost, fxEl, reducedMotion, seatEl, useBanner, useChange } from '../card-fx';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
@@ -60,12 +61,15 @@ const isDrawMode = (m: PokerMode) => m === 'badugi' || m === 'fiveDraw';
|
||||
/** Rank of a card id for the client-side "A를 남기면 4장" check. */
|
||||
const isAce = (c: string) => c[0] === 'A';
|
||||
|
||||
/** Width of my own (large) cards: 88 px, more on wide PC screens (see PokerBoard). */
|
||||
const MyCardW = createContext(88);
|
||||
|
||||
const CSS = `
|
||||
.pk-table { position: relative; width: 100%; aspect-ratio: 16 / 11; border-radius: 180px; border: 10px solid var(--wood);
|
||||
background: radial-gradient(ellipse at center, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 60%), var(--felt); box-shadow: var(--shadow); }
|
||||
.pk-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: var(--seat-w, 172px); z-index: 1;
|
||||
background: var(--surface); color: var(--text); border-radius: 12px; padding: 6px 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.25);
|
||||
border: 3px solid transparent; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; transition: border-color .2s; }
|
||||
border: 3px solid transparent; display: flex; flex-direction: column; gap: 4px; font-size: calc(0.85rem * var(--pkf, 1)); transition: border-color .2s; }
|
||||
.pk-seat.turn { border-color: var(--focus); }
|
||||
.pk-seat.me { border-color: var(--primary); }
|
||||
.pk-seat.me.turn { border-color: var(--focus); }
|
||||
@@ -73,7 +77,7 @@ const CSS = `
|
||||
.pk-seat.out { opacity: 0.6; }
|
||||
.pk-center { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); text-align: center; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); max-width: 52%; }
|
||||
.pk-board { display: flex; gap: 6px; justify-content: center; margin: 6px 0; }
|
||||
.pk-slot { width: 64px; height: 90px; border-radius: 8px; border: 2px dashed rgba(255,255,255,.35); flex: none; }
|
||||
.pk-slot { width: calc(64px * var(--pks, 1)); height: calc(90px * var(--pks, 1)); border-radius: 8px; border: 2px dashed rgba(255,255,255,.35); flex: none; }
|
||||
.pk-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
|
||||
.pk-actions .btn { min-height: 64px; flex-direction: column; gap: 0; padding: 0 8px; line-height: 1.15; font-size: 1.1rem; }
|
||||
.pk-actions .btn small { font-weight: 600; font-size: .85rem; opacity: .9; }
|
||||
@@ -83,6 +87,11 @@ const CSS = `
|
||||
.pk-x::after { content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; color: #dc2626; font-size: 3rem; font-weight: 900; pointer-events: none; }
|
||||
.pk-raise { display: grid; gap: 8px; }
|
||||
.pk-raise input[type=range] { width: 100%; min-height: 40px; }
|
||||
/* PC: the table is as wide as the play column and takes the height my area leaves (seats and cards grow, see PokerBoard). */
|
||||
@media (min-width: 1100px) {
|
||||
.pk-wrap.board-wrap { max-width: none; align-self: stretch; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
|
||||
.pk-table { flex: 1 1 0; aspect-ratio: auto; min-height: 420px; }
|
||||
}
|
||||
@media (max-width: 719px) {
|
||||
.pk-table { aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border-radius: 20px; border-width: 6px; }
|
||||
.pk-seat { position: static; transform: none; width: auto; }
|
||||
@@ -114,7 +123,7 @@ function seatBadges(seat: SeatView, v: PokerView): [string, string][] {
|
||||
return b;
|
||||
}
|
||||
|
||||
function SeatCards({ seat, v, me }: { seat: SeatView; v: PokerView; me: string | null }) {
|
||||
function SeatCards({ seat, v, me, k }: { seat: SeatView; v: PokerView; me: string | null; k: number }) {
|
||||
const sd = v.showdown?.find((e) => e.id === seat.id);
|
||||
const cards: { c: ViewCard; key: string; title?: string }[] = [];
|
||||
if (seat.forehead !== undefined) cards.push({ c: seat.forehead, key: 'f', title: seat.forehead ? undefined : seat.id === me ? '내 이마 카드(나만 못 봐요)' : '이마 카드' });
|
||||
@@ -130,17 +139,17 @@ function SeatCards({ seat, v, me }: { seat: SeatView; v: PokerView; me: string |
|
||||
<PlayingCard
|
||||
key={x.key}
|
||||
card={x.c}
|
||||
size="sm"
|
||||
width={Math.round(44 * k)}
|
||||
highlight={!!x.c && best.has(x.c)}
|
||||
title={x.title}
|
||||
style={i > 0 ? { marginLeft: cards.length > 5 ? -24 : -16 } : undefined}
|
||||
style={i > 0 ? { marginLeft: Math.round((cards.length > 5 ? -24 : -16) * k) } : undefined}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v: PokerView; players: Record<string, PublicUser>; me: string | null; deadline: number | null; x: number; y: number }) {
|
||||
function SeatBox({ seat, v, players, me, deadline, x, y, k }: { seat: SeatView; v: PokerView; players: Record<string, PublicUser>; me: string | null; deadline: number | null; x: number; y: number; k: number }) {
|
||||
const u = userOf(players, seat.id);
|
||||
const badges = seatBadges(seat, v);
|
||||
const waiting = v.waiting.includes(seat.id) && v.handPhase !== 'handEnd';
|
||||
@@ -187,7 +196,7 @@ function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v:
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<SeatCards seat={seat} v={v} me={me} />
|
||||
<SeatCards seat={seat} v={v} me={me} k={k} />
|
||||
{!sd && v.foldShown?.id === seat.id && <strong style={{ color: 'var(--primary)', textAlign: 'center' }}>{v.foldShown.handName}</strong>}
|
||||
{sd && (
|
||||
<strong style={{ color: 'var(--primary)', textAlign: 'center' }}>
|
||||
@@ -199,7 +208,7 @@ function SeatBox({ seat, v, players, me, deadline, x, y }: { seat: SeatView; v:
|
||||
);
|
||||
}
|
||||
|
||||
function CenterInfo({ v, players }: { v: PokerView; players: Record<string, PublicUser> }) {
|
||||
function CenterInfo({ v, players, k }: { v: PokerView; players: Record<string, PublicUser>; k: number }) {
|
||||
const limit = v.options.endCondition === 'hands' ? `/${v.options.handLimit}` : '';
|
||||
const penalty = v.penalties.reduce((a, p) => a + p.amount, 0);
|
||||
return (
|
||||
@@ -207,11 +216,11 @@ function CenterInfo({ v, players }: { v: PokerView; players: Record<string, Publ
|
||||
{v.streetName && <div className="pk-badge" style={{ background: '#fde047', color: '#422006', fontSize: '0.95rem', padding: '2px 12px' }}>{v.streetName}</div>}
|
||||
{isCommunity(v.mode) && (
|
||||
<div className="pk-board" aria-label="공용 카드" data-fx="poker-board">
|
||||
{Array.from({ length: 5 }, (_, i) => (v.board[i] ? <PlayingCard key={v.board[i]} card={v.board[i]!} size="md" /> : <span key={`e${i}`} className="pk-slot" aria-hidden />))}
|
||||
{Array.from({ length: 5 }, (_, i) => (v.board[i] ? <PlayingCard key={v.board[i]} card={v.board[i]!} width={Math.round(64 * k)} /> : <span key={`e${i}`} className="pk-slot" aria-hidden />))}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: '0.95rem', opacity: 0.9 }}>모인 칩</div>
|
||||
<div style={{ fontSize: '2.2rem', fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite" data-fx="poker-pot">
|
||||
<div style={{ fontSize: `${(2.2 * (1 + (k - 1) / 2)).toFixed(2)}rem`, fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite" data-fx="poker-pot">
|
||||
{formatChips(v.pot)}
|
||||
</div>
|
||||
{v.pots.length > 1 && (
|
||||
@@ -249,6 +258,24 @@ function PokerBoard({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
const showKey = `${v.handNo}-${v.handPhase}`;
|
||||
const [banner, showBanner] = useBanner();
|
||||
usePokerFx(v, me, players, showBanner);
|
||||
// PC: seats, cards and the pot grow with the table (1 at the old 890×600 table, up to 1.6×).
|
||||
const wide = useWide();
|
||||
const tableRef = useRef<HTMLDivElement | null>(null);
|
||||
const [[tableW, tableH], setTableSize] = useState([890, 600]);
|
||||
useLayoutEffect(() => {
|
||||
const el = tableRef.current;
|
||||
if (!el) return undefined;
|
||||
const measure = () => setTableSize([el.clientWidth, el.clientHeight]);
|
||||
const ro = new ResizeObserver(measure);
|
||||
ro.observe(el);
|
||||
measure();
|
||||
return () => ro.disconnect();
|
||||
}, []);
|
||||
const k = wide ? Math.min(1.6, Math.max(1, Math.min(tableW / 890, tableH / 600))) : 1;
|
||||
// My cards follow the width only (my area's height decides the table's height, so no loop).
|
||||
const lgW = Math.round(88 * (wide ? Math.min(1.4, Math.max(1, tableW / 1300)) : 1));
|
||||
// Seats (≈170 px × k tall, centred on the oval) stay inside the felt when the table is short and wide.
|
||||
const ry = wide ? Math.max(28, Math.min(38, 50 - ((85 * k + 6) / Math.max(1, tableH)) * 100)) : 38;
|
||||
|
||||
useEffect(() => {
|
||||
if (mine && !prevWaiting.current) {
|
||||
@@ -266,22 +293,35 @@ function PokerBoard({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
}, [showKey]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return (
|
||||
<div className="board-wrap stack" style={{ gap: 12 }}>
|
||||
<style>{CSS}</style>
|
||||
<div className="pk-table" role="region" aria-label="포커 테이블" style={{ '--seat-w': n > 6 ? '150px' : '176px' } as React.CSSProperties}>
|
||||
{v.seats.map((s, i) => {
|
||||
const rel = (i - myIdx + n) % n;
|
||||
const ang = Math.PI / 2 + (rel * 2 * Math.PI) / n;
|
||||
return <SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={deadline} x={50 + 40 * Math.cos(ang)} y={50 + 38 * Math.sin(ang)} />;
|
||||
})}
|
||||
<CenterInfo v={v} players={players} />
|
||||
<MyCardW.Provider value={lgW}>
|
||||
<div className="pk-wrap board-wrap stack" style={{ gap: 12 }}>
|
||||
<style>{CSS}</style>
|
||||
<div
|
||||
className="pk-table"
|
||||
ref={tableRef}
|
||||
role="region"
|
||||
aria-label="포커 테이블"
|
||||
style={{ '--seat-w': `${Math.round((n > 6 ? 150 : 176) * k)}px`, '--pks': k.toFixed(2), '--pkf': (1 + (k - 1) / 2).toFixed(2) } as React.CSSProperties}
|
||||
>
|
||||
{v.seats.map((s, i) => {
|
||||
const rel = (i - myIdx + n) % n;
|
||||
const ang = Math.PI / 2 + (rel * 2 * Math.PI) / n;
|
||||
// PC: pull side seats toward the table's corners so a short, wide table keeps them apart.
|
||||
const c = Math.cos(ang);
|
||||
const sn = Math.sin(ang);
|
||||
const cx = wide ? Math.sign(c) * Math.abs(c) ** 0.7 : c;
|
||||
const sy = wide ? Math.sign(sn) * Math.abs(sn) ** 0.7 : sn;
|
||||
return <SeatBox key={s.id} seat={s} v={v} players={players} me={me} deadline={deadline} x={50 + 40 * cx} y={50 + ry * sy} k={k} />;
|
||||
})}
|
||||
<CenterInfo v={v} players={players} k={k} />
|
||||
</div>
|
||||
<MyArea v={v} me={me} players={players} act={act} pending={pending} />
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{banner}
|
||||
</div>
|
||||
<MyArea v={v} me={me} players={players} act={act} pending={pending} />
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{banner}
|
||||
</div>
|
||||
</MyCardW.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -693,25 +733,26 @@ function RevealBox({ v, act, pending }: { v: PokerView; act: (a: unknown) => voi
|
||||
}
|
||||
|
||||
function MyCards({ v, seat }: { v: PokerView; seat: SeatView }) {
|
||||
const lgW = useContext(MyCardW);
|
||||
const sd = v.showdown?.find((e) => e.id === seat.id);
|
||||
const best = new Set(sd?.best ?? []);
|
||||
return (
|
||||
<div className="pk-mine" aria-label="내 카드" data-fx="poker-mine">
|
||||
{seat.forehead !== undefined && (
|
||||
<div className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot="f">
|
||||
<PlayingCard card={seat.forehead} size="lg" title={seat.forehead ? undefined : '내 이마 카드(나만 못 봐요)'} />
|
||||
<PlayingCard card={seat.forehead} width={lgW} title={seat.forehead ? undefined : '내 이마 카드(나만 못 봐요)'} />
|
||||
<span className="small muted">이마</span>
|
||||
</div>
|
||||
)}
|
||||
{seat.hole.map((c, i) => (
|
||||
<div key={`h${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot={c ?? `h${i}`}>
|
||||
<PlayingCard card={c} size="lg" highlight={!!c && best.has(c)} />
|
||||
<PlayingCard card={c} width={lgW} highlight={!!c && best.has(c)} />
|
||||
{(isSevenMode(v.mode) || v.mode === 'indian') && <span className="small muted">{v.mode === 'indian' ? '손' : '나만 봄'}</span>}
|
||||
</div>
|
||||
))}
|
||||
{seat.up.map((c, i) => (
|
||||
<div key={`u${i}`} className="stack" style={{ gap: 2, alignItems: 'center' }} data-slot={c ?? `u${i}`}>
|
||||
<PlayingCard card={c} size="lg" highlight={!!c && best.has(c)} />
|
||||
<PlayingCard card={c} width={lgW} highlight={!!c && best.has(c)} />
|
||||
<span className="small muted">공개</span>
|
||||
</div>
|
||||
))}
|
||||
@@ -723,6 +764,7 @@ function MyCards({ v, seat }: { v: PokerView; seat: SeatView }) {
|
||||
function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unknown) => void; pending: boolean }) {
|
||||
const [discard, setDiscard] = useState<string | null>(null);
|
||||
const [open, setOpen] = useState<string | null>(null);
|
||||
const lgW = useContext(MyCardW);
|
||||
const tap = (c: string) => {
|
||||
sfx.select();
|
||||
if (!discard) setDiscard(c);
|
||||
@@ -741,7 +783,7 @@ function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unkno
|
||||
<div className="pk-mine" data-fx="poker-mine">
|
||||
{cards.map((c) => (
|
||||
<span key={c} className={c === discard ? 'pk-x' : undefined} data-slot={c}>
|
||||
<PlayingCard card={c} size="lg" selected={c === open} dimmed={c === discard} onClick={() => tap(c)} title={c === discard ? '버릴 카드(다시 누르면 취소)' : c === open ? '보여 줄 카드' : undefined} />
|
||||
<PlayingCard card={c} width={lgW} selected={c === open} dimmed={c === discard} onClick={() => tap(c)} title={c === discard ? '버릴 카드(다시 누르면 취소)' : c === open ? '보여 줄 카드' : undefined} />
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
@@ -768,6 +810,7 @@ function ChoicePicker({ cards, act, pending }: { cards: string[]; act: (a: unkno
|
||||
/** 교환(바둑이 / 5카드 드로우): tap to lift the cards to change. */
|
||||
function DrawPicker({ v, hole, act, pending }: { v: PokerView; hole: string[]; act: (a: unknown) => void; pending: boolean }) {
|
||||
const [sel, setSel] = useState<string[]>([]);
|
||||
const lgW = useContext(MyCardW);
|
||||
const { drawMax, drawAceBonus } = v.my;
|
||||
const keepsAce = hole.some((c) => isAce(c) && !sel.includes(c));
|
||||
const limit = drawAceBonus && keepsAce ? drawMax + 1 : drawMax;
|
||||
@@ -785,7 +828,7 @@ function DrawPicker({ v, hole, act, pending }: { v: PokerView; hole: string[]; a
|
||||
</p>
|
||||
<div className="pk-mine">
|
||||
{hole.map((c) => (
|
||||
<PlayingCard key={c} card={c} size="lg" selected={sel.includes(c)} onClick={() => {
|
||||
<PlayingCard key={c} card={c} width={lgW} selected={sel.includes(c)} onClick={() => {
|
||||
sfx.select();
|
||||
setSel((s) => (s.includes(c) ? s.filter((x) => x !== c) : [...s, c]));
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user