섯다 화면 다시 만듦(한게임 섯다처럼): 초록 테이블·가운데 판돈·숫자 키 베팅 버튼·족보 도우미, 동전 날아가기·카드 나눠 주기·뒤집기·큰 글자 연출과 소리, 실제 화투 그림(Wikimedia Commons, CC BY-SA 4.0, 고스톱도 같이), 원·판돈 표기(돈 표현 검사에서 섯다만 예외), 문서·E2E
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* Hwatu card drawn in SVG (our own simple artwork, no commercial hwatu images — docs/games/seotda.md §12).
|
||||
* Large month number + kind badge so the card is readable without knowing the pictures.
|
||||
* Hwatu card: the real 48-card hwatu artwork from Wikimedia Commons "SVG Hwatu" (Marcus Richert after Louie Mantia Jr.,
|
||||
* CC BY-SA 4.0 — ./hwatu/ATTRIBUTION.txt, docs/games/seotda.md "화투 그림"), bundled from our own origin (no external
|
||||
* URLs). A small month badge stays on top so beginners can read the card at a glance;
|
||||
* 쌍피 / bonus cards get their value tag (고스톱). The back and the bonus cards are drawn here.
|
||||
*/
|
||||
import type { CSSProperties, ReactNode } from 'react';
|
||||
import type { CSSProperties } from 'react';
|
||||
|
||||
export interface HwatuInfo {
|
||||
id: number;
|
||||
@@ -13,172 +15,180 @@ export interface HwatuInfo {
|
||||
piValue?: number;
|
||||
}
|
||||
|
||||
const MONTH_COLOR = ['#6b7280', '#15803d', '#be185d', '#db2777', '#1f2937', '#7c3aed', '#dc2626', '#b91c1c', '#111827', '#ca8a04', '#c2410c', '#7c2d12', '#1e40af'];
|
||||
const MONTH_NAME = ['보너스', '송학', '매조', '벚꽃', '흑싸리', '난초', '모란', '홍싸리', '공산', '국화', '단풍', '오동', '비'];
|
||||
const KIND_BADGE: Record<HwatuInfo['kind'], string> = { gwang: '光', yeol: '열', tti: '띠', pi: '피', ssangpi: '쌍피', bonus: '+' };
|
||||
const TTI_COLOR = { hong: '#dc2626', cheong: '#2563eb', cho: '#15803d', plain: '#dc2626' };
|
||||
const TTI_TEXT = { hong: '홍단', cheong: '청단', cho: '', plain: '' };
|
||||
/** Attribution of the card artwork (CC BY-SA 4.0 asks for it); shown in the rules of the games that use these cards. */
|
||||
export const HWATU_CREDIT =
|
||||
'화투 그림: Marcus Richert(Louie Mantia, Jr.의 Hanafuda 그림 바탕), Spenĉjo — Wikimedia Commons "SVG Hwatu", CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/). 크기만 줄여 썼어요.';
|
||||
|
||||
/** A small motif per month (flowers/plants), drawn with basic shapes. */
|
||||
function Motif({ month, color }: { month: number; color: string }): ReactNode {
|
||||
const c = color;
|
||||
switch (month) {
|
||||
case 1: // 송학: pine
|
||||
return <path d="M50 52 L28 92 H72 Z M50 72 L22 116 H78 Z" fill={c} opacity="0.85" />;
|
||||
case 2: // 매조: plum blossoms
|
||||
case 3: // 벚꽃
|
||||
return (
|
||||
<g fill={c} opacity="0.85">
|
||||
{[[34, 70], [62, 62], [50, 92], [70, 100], [30, 108]].map(([x, y], i) => (
|
||||
<circle key={i} cx={x} cy={y} r="10" />
|
||||
))}
|
||||
</g>
|
||||
);
|
||||
case 4: // 흑싸리
|
||||
case 7: // 홍싸리
|
||||
return (
|
||||
<g stroke={c} strokeWidth="5" strokeLinecap="round" opacity="0.85">
|
||||
{[30, 45, 60, 75].map((x, i) => (
|
||||
<line key={i} x1={x} y1="52" x2={x - 6} y2={100 + (i % 2) * 14} />
|
||||
))}
|
||||
</g>
|
||||
);
|
||||
case 5: // 난초: iris leaves
|
||||
return (
|
||||
<g fill="none" stroke={c} strokeWidth="5" opacity="0.85">
|
||||
<path d="M40 120 Q34 80 44 52" />
|
||||
<path d="M55 120 Q62 84 52 54" />
|
||||
<path d="M70 120 Q76 92 68 64" />
|
||||
</g>
|
||||
);
|
||||
case 6: // 모란: peony
|
||||
return (
|
||||
<g fill={c} opacity="0.85">
|
||||
<circle cx="50" cy="86" r="22" />
|
||||
<circle cx="50" cy="86" r="10" fill="#fde68a" />
|
||||
</g>
|
||||
);
|
||||
case 8: // 공산: hill
|
||||
return <path d="M8 120 Q50 52 92 120 Z" fill={c} opacity="0.85" />;
|
||||
case 9: // 국화
|
||||
return (
|
||||
<g fill={c} opacity="0.9">
|
||||
{Array.from({ length: 10 }, (_, i) => {
|
||||
const a = (i / 10) * Math.PI * 2;
|
||||
return <ellipse key={i} cx={50 + Math.cos(a) * 14} cy={88 + Math.sin(a) * 14} rx="8" ry="4" transform={`rotate(${(a * 180) / Math.PI} ${50 + Math.cos(a) * 14} ${88 + Math.sin(a) * 14})`} />;
|
||||
})}
|
||||
<circle cx="50" cy="88" r="7" fill="#78350f" />
|
||||
</g>
|
||||
);
|
||||
case 10: // 단풍: maple
|
||||
return <path d="M50 58 L58 78 L78 74 L64 90 L74 108 L50 98 L26 108 L36 90 L22 74 L42 78 Z" fill={c} opacity="0.9" />;
|
||||
case 11: // 오동
|
||||
return (
|
||||
<g fill={c} opacity="0.85">
|
||||
<ellipse cx="38" cy="82" rx="16" ry="22" />
|
||||
<ellipse cx="64" cy="94" rx="16" ry="22" />
|
||||
</g>
|
||||
);
|
||||
case 12: // 비: rain lines + umbrella
|
||||
return (
|
||||
<g stroke={c} strokeWidth="3" opacity="0.85">
|
||||
{[20, 35, 50, 65, 80].map((x) => (
|
||||
<line key={x} x1={x} y1="54" x2={x - 8} y2="118" />
|
||||
))}
|
||||
</g>
|
||||
);
|
||||
default:
|
||||
return <text x="50" y="98" fontSize="36" textAnchor="middle" fill={c}>★</text>;
|
||||
}
|
||||
export type HwatuSize = 'sm' | 'md' | 'lg' | 'xl';
|
||||
const WIDTH: Record<HwatuSize, number> = { sm: 40, md: 60, lg: 84, xl: 108 };
|
||||
/** Height / width of the artwork (103.2 × 168.2). */
|
||||
export const HWATU_RATIO = 1.63;
|
||||
|
||||
/**
|
||||
* URL of a card face (ids 0..47). Vite turns this pattern into hashed /assets/ files (cached for good, also by the
|
||||
* service worker); in tests it is just a file URL.
|
||||
*/
|
||||
export const hwatuSrc = (id: number): string => new URL(`./hwatu/${id}.svg`, import.meta.url).href;
|
||||
|
||||
/** Card back: deep red lacquer with a thin gold frame, like a real hwatu back. */
|
||||
export function HwatuBack({ w, h }: { w: number; h: number }) {
|
||||
return (
|
||||
<svg viewBox="0 0 100 163" width={w} height={h} aria-hidden style={{ display: 'block' }}>
|
||||
<defs>
|
||||
<linearGradient id="hwb-g" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0" stopColor="#c8102e" />
|
||||
<stop offset="1" stopColor="#8a0b1f" />
|
||||
</linearGradient>
|
||||
<pattern id="hwb-p" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
||||
<rect width="10" height="10" fill="none" />
|
||||
<path d="M0 5h10M5 0v10" stroke="#ffffff" strokeOpacity="0.07" strokeWidth="1.2" />
|
||||
</pattern>
|
||||
</defs>
|
||||
<rect x="1" y="1" width="98" height="161" rx="7" fill="url(#hwb-g)" stroke="#4a0510" strokeWidth="2" />
|
||||
<rect x="1" y="1" width="98" height="161" rx="7" fill="url(#hwb-p)" />
|
||||
<rect x="8" y="8" width="84" height="147" rx="4" fill="none" stroke="#f6c453" strokeOpacity="0.55" strokeWidth="1.5" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export type HwatuSize = 'sm' | 'md' | 'lg';
|
||||
const WIDTH: Record<HwatuSize, number> = { sm: 40, md: 60, lg: 84 };
|
||||
function BonusFace({ w, h, value }: { w: number; h: number; value: number }) {
|
||||
return (
|
||||
<svg viewBox="0 0 100 163" width={w} height={h} aria-hidden style={{ display: 'block' }}>
|
||||
<rect x="1" y="1" width="98" height="161" rx="7" fill="#e3262b" />
|
||||
<rect x="7" y="7" width="86" height="149" rx="5" fill="#fffaf0" />
|
||||
<circle cx="50" cy="70" r="27" fill="#f6c453" stroke="#b45309" strokeWidth="3" />
|
||||
<text x="50" y="81" fontSize="30" fontWeight="900" fill="#7c2d12" textAnchor="middle" fontFamily="Pretendard Variable, sans-serif">
|
||||
{value}
|
||||
</text>
|
||||
<text x="50" y="128" fontSize="20" fontWeight="900" fill="#b91c1c" textAnchor="middle" fontFamily="Pretendard Variable, sans-serif">
|
||||
보너스
|
||||
</text>
|
||||
<text x="50" y="148" fontSize="15" fontWeight="800" fill="#7c2d12" textAnchor="middle" fontFamily="Pretendard Variable, sans-serif">
|
||||
{value}피
|
||||
</text>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function HwatuCard({
|
||||
card,
|
||||
size = 'md',
|
||||
width,
|
||||
selected,
|
||||
dimmed,
|
||||
highlight,
|
||||
showMonth = true,
|
||||
onClick,
|
||||
className,
|
||||
style,
|
||||
}: {
|
||||
card: HwatuInfo | null;
|
||||
size?: HwatuSize;
|
||||
/** Exact width in px (overrides `size`). */
|
||||
width?: number;
|
||||
selected?: boolean;
|
||||
dimmed?: boolean;
|
||||
highlight?: boolean;
|
||||
/** Small month number badge (on by default). */
|
||||
showMonth?: boolean;
|
||||
onClick?: () => void;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
}) {
|
||||
const w = WIDTH[size];
|
||||
const h = Math.round(w * 1.6);
|
||||
const w = width ?? WIDTH[size];
|
||||
const h = Math.round(w * HWATU_RATIO);
|
||||
const Tag = onClick ? 'button' : 'span';
|
||||
const radius = Math.max(3, Math.round(w * 0.07));
|
||||
const s: CSSProperties = {
|
||||
position: 'relative',
|
||||
width: w,
|
||||
height: h,
|
||||
flex: 'none',
|
||||
display: 'inline-block',
|
||||
padding: 0,
|
||||
border: 0,
|
||||
borderRadius: radius,
|
||||
background: 'none',
|
||||
cursor: onClick ? 'pointer' : 'default',
|
||||
opacity: dimmed ? 0.45 : 1,
|
||||
transform: selected ? `translateY(${-Math.round(w * 0.2)}px)` : undefined,
|
||||
transition: 'transform 0.12s ease',
|
||||
filter: highlight ? 'drop-shadow(0 0 6px #f59e0b)' : 'drop-shadow(0 1px 2px rgba(0,0,0,0.3))',
|
||||
boxShadow: selected ? '0 0 0 3px #2563eb' : undefined,
|
||||
filter: highlight ? 'drop-shadow(0 0 6px #f59e0b)' : 'drop-shadow(0 1px 2px rgba(0,0,0,0.35))',
|
||||
verticalAlign: 'bottom',
|
||||
...style,
|
||||
};
|
||||
if (!card) {
|
||||
return (
|
||||
<Tag style={s} onClick={onClick} aria-label="뒤집힌 화투">
|
||||
<svg viewBox="0 0 100 160" width={w} height={h} aria-hidden>
|
||||
<rect x="1" y="1" width="98" height="158" rx="8" fill="#991b1b" stroke="#450a0a" strokeWidth="3" />
|
||||
<rect x="10" y="10" width="80" height="140" rx="5" fill="#b91c1c" />
|
||||
</svg>
|
||||
<Tag style={s} onClick={onClick} aria-label="뒤집힌 화투" className={className}>
|
||||
<HwatuBack w={w} h={h} />
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
const color = MONTH_COLOR[card.month] ?? '#374151';
|
||||
const badge = Math.max(12, Math.round(w * 0.24));
|
||||
// 고스톱 passes 쌍피 as kind 'pi' with piValue 2.
|
||||
const tag = card.kind === 'ssangpi' || (card.kind === 'pi' && (card.piValue ?? 1) >= 2) ? '쌍피' : null;
|
||||
return (
|
||||
<Tag style={s} onClick={onClick} aria-label={card.name} aria-pressed={onClick ? !!selected : undefined} title={card.name}>
|
||||
<svg viewBox="0 0 100 160" width={w} height={h} aria-hidden>
|
||||
<rect x="1" y="1" width="98" height="158" rx="8" fill="#fffaf0" stroke={selected ? '#2563eb' : '#1f2937'} strokeWidth={selected ? 6 : 3} />
|
||||
{card.kind === 'bonus' ? (
|
||||
<text x="50" y="102" fontSize="34" fontWeight="900" fill="#b45309" textAnchor="middle" fontFamily="Pretendard Variable, sans-serif">
|
||||
{card.piValue ?? 2}피
|
||||
</text>
|
||||
) : (
|
||||
<Motif month={card.month} color={color} />
|
||||
)}
|
||||
{card.kind === 'tti' && (
|
||||
<g>
|
||||
<rect x="58" y="30" width="18" height="90" rx="3" fill={TTI_COLOR[card.tti ?? 'plain']} />
|
||||
{TTI_TEXT[card.tti ?? 'plain'] && (
|
||||
<text x="67" y="62" fontSize="13" fontWeight="800" fill="#fff" textAnchor="middle" style={{ writingMode: 'vertical-rl' } as CSSProperties}>
|
||||
{TTI_TEXT[card.tti ?? 'plain']}
|
||||
</text>
|
||||
)}
|
||||
</g>
|
||||
)}
|
||||
{(card.kind === 'gwang' || card.kind === 'yeol') && (
|
||||
<g>
|
||||
<circle cx="78" cy="120" r="15" fill={card.kind === 'gwang' ? '#dc2626' : '#a16207'} />
|
||||
<text x="78" y="127" fontSize={card.kind === 'gwang' ? 20 : 16} fontWeight="800" fill="#fff" textAnchor="middle">
|
||||
{card.kind === 'gwang' ? '光' : '열'}
|
||||
</text>
|
||||
</g>
|
||||
)}
|
||||
{/* Month number: large and always readable */}
|
||||
<rect x="6" y="6" width="38" height="38" rx="8" fill={color} />
|
||||
<text x="25" y="35" fontSize="28" fontWeight="900" fill="#fff" textAnchor="middle" fontFamily="Pretendard Variable, sans-serif">
|
||||
{card.month || '+'}
|
||||
</text>
|
||||
<text x="50" y="154" fontSize="13" fontWeight="700" fill="#374151" textAnchor="middle" fontFamily="Pretendard Variable, sans-serif">
|
||||
{MONTH_NAME[card.month]} · {card.kind === 'bonus' ? `${card.piValue ?? 2}피` : card.kind === 'tti' ? (TTI_TEXT[card.tti ?? 'plain'] || '띠') : KIND_BADGE[card.kind] === '光' ? '광' : KIND_BADGE[card.kind] === '열' ? '열끗' : KIND_BADGE[card.kind]}
|
||||
</text>
|
||||
</svg>
|
||||
<Tag
|
||||
style={s}
|
||||
onClick={onClick}
|
||||
aria-label={card.name}
|
||||
aria-pressed={onClick ? !!selected : undefined}
|
||||
title={card.name}
|
||||
className={className}
|
||||
>
|
||||
{card.kind === 'bonus' || card.id >= 48 ? (
|
||||
<BonusFace w={w} h={h} value={card.piValue ?? 2} />
|
||||
) : (
|
||||
<img src={hwatuSrc(card.id)} alt="" draggable={false} width={w} height={h} decoding="async" style={{ display: 'block', width: w, height: h, borderRadius: radius }} />
|
||||
)}
|
||||
{showMonth && card.month > 0 && (
|
||||
<span
|
||||
aria-hidden
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: Math.round(w * 0.05),
|
||||
right: Math.round(w * 0.05),
|
||||
minWidth: badge,
|
||||
height: badge,
|
||||
padding: '0 2px',
|
||||
borderRadius: badge,
|
||||
background: 'rgba(17,24,39,0.82)',
|
||||
color: '#fff',
|
||||
fontSize: Math.max(9, Math.round(badge * 0.66)),
|
||||
fontWeight: 800,
|
||||
lineHeight: `${badge}px`,
|
||||
textAlign: 'center',
|
||||
fontFamily: 'Pretendard Variable, sans-serif',
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
{card.month}
|
||||
</span>
|
||||
)}
|
||||
{tag && (
|
||||
<span
|
||||
aria-hidden
|
||||
style={{
|
||||
position: 'absolute',
|
||||
left: '50%',
|
||||
bottom: Math.round(w * 0.06),
|
||||
transform: 'translateX(-50%)',
|
||||
padding: '0 4px',
|
||||
borderRadius: 4,
|
||||
background: '#f6c453',
|
||||
color: '#7c2d12',
|
||||
fontSize: Math.max(9, Math.round(w * 0.2)),
|
||||
fontWeight: 900,
|
||||
lineHeight: 1.25,
|
||||
whiteSpace: 'nowrap',
|
||||
fontFamily: 'Pretendard Variable, sans-serif',
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</span>
|
||||
)}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
1
apps/web/src/components/cards/hwatu/0.svg
Normal file
|
After Width: | Height: | Size: 26 KiB |
1
apps/web/src/components/cards/hwatu/1.svg
Normal file
|
After Width: | Height: | Size: 19 KiB |
1
apps/web/src/components/cards/hwatu/10.svg
Normal file
|
After Width: | Height: | Size: 51 KiB |
1
apps/web/src/components/cards/hwatu/11.svg
Normal file
|
After Width: | Height: | Size: 56 KiB |
1
apps/web/src/components/cards/hwatu/12.svg
Normal file
|
After Width: | Height: | Size: 34 KiB |
1
apps/web/src/components/cards/hwatu/13.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
1
apps/web/src/components/cards/hwatu/14.svg
Normal file
|
After Width: | Height: | Size: 26 KiB |
1
apps/web/src/components/cards/hwatu/15.svg
Normal file
|
After Width: | Height: | Size: 27 KiB |
1
apps/web/src/components/cards/hwatu/16.svg
Normal file
|
After Width: | Height: | Size: 29 KiB |
1
apps/web/src/components/cards/hwatu/17.svg
Normal file
|
After Width: | Height: | Size: 21 KiB |
1
apps/web/src/components/cards/hwatu/18.svg
Normal file
|
After Width: | Height: | Size: 18 KiB |
1
apps/web/src/components/cards/hwatu/19.svg
Normal file
|
After Width: | Height: | Size: 20 KiB |
1
apps/web/src/components/cards/hwatu/2.svg
Normal file
|
After Width: | Height: | Size: 12 KiB |
1
apps/web/src/components/cards/hwatu/20.svg
Normal file
|
After Width: | Height: | Size: 50 KiB |
1
apps/web/src/components/cards/hwatu/21.svg
Normal file
|
After Width: | Height: | Size: 27 KiB |
1
apps/web/src/components/cards/hwatu/22.svg
Normal file
|
After Width: | Height: | Size: 29 KiB |
1
apps/web/src/components/cards/hwatu/23.svg
Normal file
|
After Width: | Height: | Size: 23 KiB |
1
apps/web/src/components/cards/hwatu/24.svg
Normal file
|
After Width: | Height: | Size: 54 KiB |
1
apps/web/src/components/cards/hwatu/25.svg
Normal file
|
After Width: | Height: | Size: 27 KiB |
1
apps/web/src/components/cards/hwatu/26.svg
Normal file
|
After Width: | Height: | Size: 24 KiB |
1
apps/web/src/components/cards/hwatu/27.svg
Normal file
|
After Width: | Height: | Size: 20 KiB |
1
apps/web/src/components/cards/hwatu/28.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="103.2" height="168.2" preserveAspectRatio="none" version="1.1" viewBox="0 0 103.2 168.2" xmlns="http://www.w3.org/2000/svg"><path d="m13.3 7.2c-4.67 0-7 2.33-7 7v139.8c0 4.67 2.33 7 7 7h76.6c4.67 0 7-2.33 7-7v-139.8c0-4.67-2.33-7-7-7z" fill="#fff"/><path d="m3.3 3.15c-.17 10.85 1.3 101.25 1.3 101.25l94.7 9.5 1.25-110.75c-32.28.58-64.87-1.85-97.25 0zm46.45 19c18.68-.54 33.23 16.56 33.23 31.59 0 21.84-16.42 34.31-33.38 34.31-14.18 0-32.68-12.1-32.68-32.42 0-16.47 11.61-32.87 32.83-33.48z" fill="#ef1d1e"/><path d="m48.05 21.45c-8.53.4-15.92 3.75-22.15 10.05-6.6 6.67-9.78 14.78-9.55 24.35.37 11.97 5.65 21.23 15.85 27.8 6.37 4.07 13.38 5.7 21.05 4.9 9.1-.97 16.6-4.95 22.5-11.95 5.73-6.77 8.32-14.82 7.75-24.15-.5-8.27-3.9-15.47-10.2-21.6-6.9-6.7-15.32-9.83-25.25-9.4zm.92 1.21c6.93-.28 13.46 1.72 19.58 5.99 6.2 4.33 10.35 10.15 12.45 17.45 2.8 9.93 1.22 19.15-4.75 27.65-2.9 4.13-6.42 7.37-10.55 9.7-3.97 2.23-8.35 3.55-13.15 3.95-8.4.3-15.68-1.82-21.85-6.35-5.63-4.17-9.48-9.43-11.55-15.8-2.87-9.07-2.08-17.63 2.35-25.7h.05l.05-.05c4.57-8.23 11.33-13.5 20.3-15.8 2.4-.6 4.76-.95 7.07-1.04zm-8.22 70.09c-2.53.27-4.43.43-5.7.5-.6 0-1.35.08-2.25.25-.97.17-1.7.28-2.2.35-.17.03-1.22.23-3.15.6-2.37.57-3.83.93-4.4 1.1l-6.5 2.25c-.8.27-1.9.72-3.3 1.35-1.5.67-2.62 1.13-3.35 1.4-2.03.73-3.97 1.77-5.8 3.1l-.82 59.4 95.11 1.07-.89-52.96c-1-.87-2.92-2.22-5.75-4.05-2.03-1.33-4.47-2.8-7.3-4.4-1.93-1.1-4.67-2.38-8.2-3.85-3.03-1.1-5.3-1.93-6.8-2.5-2.13-.77-5.77-1.65-10.9-2.65-.43-.07-2.75-.28-6.95-.65l-2.75-.2c-.47 0-1.13-.03-2-.1l-3.1.05c-1.33-.07-2.33-.08-3-.05z"/><g transform="translate(479.2 -235.55)"><path transform="translate(-848.6,2.2)" d="m399.45 353.05c-4.87 0-9.02 1.72-12.45 5.15-3.4 3.43-5.1 7.58-5.1 12.45s1.7 9.02 5.1 12.45c3.43 3.43 7.58 5.15 12.45 5.15s9.02-1.72 12.45-5.15 5.15-7.58 5.15-12.45-1.72-9.02-5.15-12.45-7.58-5.15-12.45-5.15z" fill="#ef1d1e"/><path transform="translate(-848.6,2.2)" d="m397.62 356.15c-.52.06-.91.55-1.17 1.45-.3 1-.3 2.55 0 4.65.03.93.05 1.82.05 2.65-.03.97-.1 1.85-.2 2.65-.73.23-1.38.47-1.95.7-2.07.83-3.1 1.65-3.1 2.45v.25l.15.4h.4c.03 0 1.67-.4 4.9-1.2-.27.9-.85 1.93-1.75 3.1-.83 1.1-1.58 1.97-2.25 2.6-.7.67-1.15 1.12-1.35 1.35-.13.2-.52.55-1.15 1.05-.6.47-1.18.82-1.75 1.05-.6.23-.9.48-.9.75 0 .17.13.35.4.55.27.17.6.25 1 .25.97 0 2.25-.8 3.85-2.4 1.6-1.63 2.65-2.78 3.15-3.45s1.1-1.62 1.8-2.85c.67-1.23 1.15-2.1 1.45-2.6v-.05c.06 0 .11-.02.15-.05-.04.04-.09.07-.15.1.07 1.03.13 2 .2 2.9l-.35 5.5c0 1.33.38 2.27 1.15 2.8.73.5 2.27.78 4.6.85 2.3.13 4.07-.32 5.3-1.35 1.33-1.07 1.93-2.18 1.8-3.35-.07-1.13-.35-1.95-.85-2.45s-.92-.82-1.25-.95c-.4-.07-.78.48-1.15 1.65-.43 1.13-.92 1.82-1.45 2.05-.57.2-1.37.4-2.4.6-1.07.3-1.73.45-2 .45-1 0-1.52-1.07-1.55-3.2.07-2.1.1-3.2.1-3.3 0-.97-.02-1.55-.05-1.75-.13-.3-.37-.6-.7-.9 2.83-1 4.25-1.88 4.25-2.65 0-.53-.2-.87-.6-1-.17-.1-.58-.15-1.25-.15-.6 0-1.22.15-1.85.45-1.1.47-1.9.8-2.4 1-.07-.33-.1-.77-.1-1.3 0-.83.08-1.77.25-2.8 0-.2.02-.42.05-.65.17-1.3.25-2.32.25-3.05s-.02-1.23-.05-1.5c-.23-.87-.67-1.3-1.3-1.3-.08-.01-.16-.01-.23 0zm5.73 1.75c-.6.47-1.38 1.22-2.35 2.25-.97 1.03-1.45 1.9-1.45 2.6 0 .67.02 1.02.05 1.05.07.07.1.12.1.15.13.1.23.15.3.15.33 0 1.27-.55 2.8-1.65 1.63-1.2 2.45-2.05 2.45-2.55 0-.43-.2-.87-.6-1.3-.4-.47-.83-.7-1.3-.7zm-12.5 4.6c-.3 0-.55.18-.75.55-.13.33-.2.65-.2.95 0 .83.17 1.45.5 1.85.3.3.77.48 1.4.55.2.03.43.05.7.05.2-.03.43-.08.7-.15.1-.03.22-.1.35-.2.83-.33 1.25-.75 1.25-1.25 0-.43-.15-.72-.45-.85-.17-.07-.62-.17-1.35-.3-.6-.07-1.02-.3-1.25-.7-.27-.33-.57-.5-.9-.5z" fill="#fff"/><path transform="translate(-848.6,2.2)" d="m399.45 353.05c-4.87 0-9.02 1.72-12.45 5.15-3.4 3.43-5.1 7.58-5.1 12.45s1.7 9.02 5.1 12.45c3.43 3.43 7.58 5.15 12.45 5.15s9.02-1.72 12.45-5.15 5.15-7.58 5.15-12.45-1.72-9.02-5.15-12.45-7.58-5.15-12.45-5.15z" fill="none" stroke="#000"/></g><g transform="translate(-447.2 -373.75)"><path transform="translate(160.15,84.1)" d="m292.05 289.65c-3.33 0-5 1.67-5 5v158.2c0 3.33 1.67 5 5 5h93.2c3.33 0 5-1.67 5-5v-158.2c0-3.33-1.67-5-5-5zm8.3 7.2h76.6c4.67 0 7 2.33 7 7v139.8c0 4.67-2.33 7-7 7h-76.6c-4.67 0-7-2.33-7-7v-139.8c0-4.67 2.33-7 7-7z" fill="#ef1d1e"/><path transform="translate(160.15,84.1)" d="m300.35 296.85c-4.67 0-7 2.33-7 7v139.8c0 4.67 2.33 7 7 7h76.6c4.67 0 7-2.33 7-7v-139.8c0-4.67-2.33-7-7-7z" fill="none" stroke="#000" stroke-width="1.2"/></g></svg>
|
||||
|
After Width: | Height: | Size: 4.2 KiB |
1
apps/web/src/components/cards/hwatu/29.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
1
apps/web/src/components/cards/hwatu/3.svg
Normal file
|
After Width: | Height: | Size: 10 KiB |
1
apps/web/src/components/cards/hwatu/30.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="103.2" height="168.2" preserveAspectRatio="none" version="1.1" viewBox="0 0 103.2 168.2" xmlns="http://www.w3.org/2000/svg"><path d="m13.3 7.2c-4.67 0-7 2.33-7 7v139.8c0 4.67 2.33 7 7 7h76.6c4.67 0 7-2.33 7-7v-139.8c0-4.67-2.33-7-7-7z" fill="#fff"/><path d="m41.15 88.75c-1.6.07-3.2.22-4.8.45-3.07.4-5.35.75-6.85 1.05-3.43.7-5.65 1.18-6.65 1.45-1.5.4-3.72 1.13-6.65 2.2-3.9 1.43-6.35 2.42-7.35 2.95-1.63.7-2.83 1.27-3.6 1.7l-1.7 67.5c.46.42 97.25 0 97.25 0l-3.7-59.55c-1.87-1.67-3.3-2.87-4.3-3.6-1.07-.77-2.7-1.82-4.9-3.15-2.3-1.3-4.32-2.38-6.05-3.25-1.27-.6-3.47-1.5-6.6-2.7-1.9-.73-3.6-1.3-5.1-1.7-2.2-.47-3.85-.83-4.95-1.1-2.73-.6-4.8-.98-6.2-1.15l-3.75-.55c-2.5-.23-4-.37-4.5-.4-2.17.1-3.78.07-4.85-.1-.87-.1-2.45-.12-4.75-.05z"/><g transform="translate(-555.75,-373.75)"><path transform="translate(160.15,84.1)" d="m400.6 289.65c-3.33 0-5 1.67-5 5v158.2c0 3.33 1.67 5 5 5h93.2c3.33 0 5-1.67 5-5v-158.2c0-3.33-1.67-5-5-5zm8.3 7.2h76.6c4.67 0 7 2.33 7 7v139.8c0 4.67-2.33 7-7 7h-76.6c-4.67 0-7-2.33-7-7v-139.8c0-4.67 2.33-7 7-7z" fill="#ef1d1e"/><path transform="translate(160.15,84.1)" d="m408.9 296.85c-4.67 0-7 2.33-7 7v139.8c0 4.67 2.33 7 7 7h76.6c4.67 0 7-2.33 7-7v-139.8c0-4.67-2.33-7-7-7z" fill="none" stroke="#000" stroke-width="1.2"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
1
apps/web/src/components/cards/hwatu/31.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="103.2" height="168.2" preserveAspectRatio="none" version="1.1" viewBox="0 0 103.2 168.2" xmlns="http://www.w3.org/2000/svg"><path d="m13.3 7.2c-4.67 0-7 2.33-7 7v139.8c0 4.67 2.33 7 7 7h76.6c4.67 0 7-2.33 7-7v-139.8c0-4.67-2.33-7-7-7z" fill="#fff"/><path d="m46.2 81.65c-1.8 0-3.35.07-4.65.2-3.77.33-6.58.62-8.45.85-2.53.27-4.38.53-5.55.8-2.33.5-4.7 1.1-7.1 1.8-2.57.7-4.72 1.4-6.45 2.1-.37.17-2.32 1.1-5.85 2.8-1.93 1.07-3.32 1.97-4.15 2.7l-.6 73.15h97.25l-1.55-67.2c-1.27-1.1-2.14-1.82-2.6-2.15-.1-.07-.2-.11-.3-.18-.36-.28-.5-.48-.9-.77-.53-.4-2.22-1.48-5.05-3.25-1.93-1.2-4.27-2.4-7-3.6-1.33-.6-3.58-1.47-6.75-2.6-1.97-.77-3.3-1.23-4-1.4-2.77-.6-4.85-1.08-6.25-1.45-.4-.13-1.02-.22-1.85-.25-.87-.03-1.48-.1-1.85-.2-.8-.23-1.77-.42-2.9-.55-1.27-.13-2.23-.25-2.9-.35-2.13-.27-4.12-.4-5.95-.4-2.07-.03-3.6-.05-4.6-.05z"/><g transform="translate(-773.5,-373.75)"><path transform="translate(160.15,84.1)" d="m618.35 289.65c-3.33 0-5 1.67-5 5v158.2c0 3.33 1.67 5 5 5h93.2c3.33 0 5-1.67 5-5v-158.2c0-3.33-1.67-5-5-5zm8.3 7.2h76.6c4.67 0 7 2.33 7 7v139.8c0 4.67-2.33 7-7 7h-76.6c-4.67 0-7-2.33-7-7v-139.8c0-4.67 2.33-7 7-7z" fill="#ef1d1e"/><path transform="translate(160.15,84.1)" d="m626.65 296.85c-4.67 0-7 2.33-7 7v139.8c0 4.67 2.33 7 7 7h76.6c4.67 0 7-2.33 7-7v-139.8c0-4.67-2.33-7-7-7z" fill="none" stroke="#000" stroke-width="1.2"/></g></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1
apps/web/src/components/cards/hwatu/32.svg
Normal file
|
After Width: | Height: | Size: 50 KiB |
1
apps/web/src/components/cards/hwatu/33.svg
Normal file
|
After Width: | Height: | Size: 37 KiB |
1
apps/web/src/components/cards/hwatu/34.svg
Normal file
|
After Width: | Height: | Size: 35 KiB |
1
apps/web/src/components/cards/hwatu/35.svg
Normal file
|
After Width: | Height: | Size: 36 KiB |
1
apps/web/src/components/cards/hwatu/36.svg
Normal file
|
After Width: | Height: | Size: 56 KiB |
1
apps/web/src/components/cards/hwatu/37.svg
Normal file
|
After Width: | Height: | Size: 32 KiB |
1
apps/web/src/components/cards/hwatu/38.svg
Normal file
|
After Width: | Height: | Size: 28 KiB |
1
apps/web/src/components/cards/hwatu/39.svg
Normal file
|
After Width: | Height: | Size: 30 KiB |
1
apps/web/src/components/cards/hwatu/4.svg
Normal file
|
After Width: | Height: | Size: 36 KiB |
1
apps/web/src/components/cards/hwatu/40.svg
Normal file
|
After Width: | Height: | Size: 36 KiB |
1
apps/web/src/components/cards/hwatu/41.svg
Normal file
|
After Width: | Height: | Size: 15 KiB |
1
apps/web/src/components/cards/hwatu/42.svg
Normal file
|
After Width: | Height: | Size: 18 KiB |
1
apps/web/src/components/cards/hwatu/43.svg
Normal file
|
After Width: | Height: | Size: 19 KiB |
1
apps/web/src/components/cards/hwatu/44.svg
Normal file
|
After Width: | Height: | Size: 54 KiB |
1
apps/web/src/components/cards/hwatu/45.svg
Normal file
|
After Width: | Height: | Size: 40 KiB |
1
apps/web/src/components/cards/hwatu/46.svg
Normal file
|
After Width: | Height: | Size: 18 KiB |
1
apps/web/src/components/cards/hwatu/47.svg
Normal file
|
After Width: | Height: | Size: 21 KiB |
1
apps/web/src/components/cards/hwatu/5.svg
Normal file
|
After Width: | Height: | Size: 30 KiB |
1
apps/web/src/components/cards/hwatu/6.svg
Normal file
|
After Width: | Height: | Size: 32 KiB |
1
apps/web/src/components/cards/hwatu/7.svg
Normal file
|
After Width: | Height: | Size: 25 KiB |
1
apps/web/src/components/cards/hwatu/8.svg
Normal file
|
After Width: | Height: | Size: 65 KiB |
1
apps/web/src/components/cards/hwatu/9.svg
Normal file
|
After Width: | Height: | Size: 55 KiB |
14
apps/web/src/components/cards/hwatu/ATTRIBUTION.txt
Normal file
@@ -0,0 +1,14 @@
|
||||
화투 그림 출처 (Hwatu card artwork)
|
||||
|
||||
0.svg ~ 47.svg (화투 48장, 파일 이름 = 게임 엔진의 카드 id = (월-1)*4 + 칸)
|
||||
|
||||
- 원본: Wikimedia Commons "Category:SVG Hwatu"
|
||||
https://commons.wikimedia.org/wiki/Category:SVG_Hwatu
|
||||
(File:Hwatu January Hikari.svg ~ File:Hwatu December Kasu.svg, 2026-10-13 받음)
|
||||
- 만든 사람: Marcus Richert (Louie Mantia, Jr.의 Hanafuda 그림을 바탕으로 한국 화투처럼 다시 칠하고 일부 선을 고침),
|
||||
카드별 파일 분리: Spenĉjo
|
||||
- 라이선스: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
|
||||
- 바꾼 점: 좌표를 소수 둘째 자리로 반올림하고 공백·주석을 지워 파일 크기를 줄였다. 그림 내용은 바꾸지 않았다.
|
||||
이 파일들(변형본)도 CC BY-SA 4.0 으로 배포한다.
|
||||
|
||||
원본 파일 → 이 폴더 파일 대응은 docs/games/seotda.md "화투 그림" 절에 있다.
|
||||
724
apps/web/src/games/seotda/board.tsx
Normal file
@@ -0,0 +1,724 @@
|
||||
/**
|
||||
* 섯다 판 화면 (docs/games/seotda.md §9), 한게임 섯다처럼: 초록 테이블 둘레에 자리, 가운데 판돈, 아래쪽 내 자리에 큰 패와
|
||||
* 족보 이름, 그 밑에 숫자 키가 붙은 베팅 버튼. 돈은 이 방 안에서만 쓰는 놀이용 원(§12).
|
||||
* Sound and motion follow view changes (anyone's bet, deal, reveal, payout), so other players' moves play too.
|
||||
*/
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
|
||||
import type { BetLogEntry, BetType, CardSlot, PotOutcome, SeotdaCardView, SeotdaSeatView, SeotdaView } from '@bg/games/seotda';
|
||||
import { formatWon, formatWonDelta, formatWonShort } from '@bg/games/seotda/money';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { HwatuCard } from '../../components/cards/HwatuCard';
|
||||
import { haptic, sfx, sounds } from '../../lib/feedback';
|
||||
import { usePhone } from '../../lib/media';
|
||||
import type { BoardProps } from '../types';
|
||||
|
||||
export const BET_KO: Record<BetType, string> = { check: '체크', ping: '삥', call: '콜', ddadang: '따당', quarter: '쿼터', half: '하프', full: '풀', die: '다이' };
|
||||
/** Number keys like 한게임 섯다 (콜 7, 다이 8, 삥 4, 체크 5, 따당 1, 하프 0); 쿼터 2 and 풀 9 are ours. */
|
||||
export const BET_KEY: Record<BetType, string> = { call: '7', die: '8', ping: '4', check: '5', ddadang: '1', half: '0', quarter: '2', full: '9' };
|
||||
export const BET_HELP: Record<BetType, string> = {
|
||||
check: '걸지 않고 다음 사람에게 넘겨요',
|
||||
ping: '기본금만큼 걸어요',
|
||||
call: '앞사람이 건 만큼 맞춰요',
|
||||
ddadang: '앞사람이 건 돈의 두 배를 걸어요',
|
||||
quarter: '맞춘 뒤 판돈의 4분의 1을 더 걸어요',
|
||||
half: '맞춘 뒤 판돈의 절반을 더 걸어요',
|
||||
full: '맞춘 뒤 판돈만큼 더 걸어요',
|
||||
die: '이번 판을 포기해요',
|
||||
};
|
||||
const BET_COLOR: Record<BetType, string> = {
|
||||
call: '#2563eb',
|
||||
die: '#b91c1c',
|
||||
half: '#ea580c',
|
||||
ping: '#0f766e',
|
||||
check: '#15803d',
|
||||
ddadang: '#7c3aed',
|
||||
quarter: '#0e7490',
|
||||
full: '#be123c',
|
||||
};
|
||||
const REASON_KO: Record<PotOutcome['reason'], string> = {
|
||||
normal: '',
|
||||
ttaengjabi: '땡잡이',
|
||||
amhaeng: '암행어사',
|
||||
gusa: '구사 재경기',
|
||||
mungGusa: '멍텅구리구사 재경기',
|
||||
tie: '같은 족보',
|
||||
limit: '재경기 횟수 초과로 나눔',
|
||||
fold: '모두 다이',
|
||||
};
|
||||
export const REMATCH_KO = { gusa: '구사', mungGusa: '멍텅구리구사', tie: '같은 족보' } as const;
|
||||
|
||||
export const nick = (players: Record<string, PublicUser>, id: string) => players[id]?.nickname ?? '알 수 없음';
|
||||
export const userOf = (players: Record<string, PublicUser>, id: string): PublicUser =>
|
||||
players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' };
|
||||
export const isCard = (c: CardSlot): c is SeotdaCardView => !('hidden' in c);
|
||||
|
||||
export function totalMsOf(v: SeotdaView): number {
|
||||
const o = v.options;
|
||||
if (v.phase === 'rebuy' || v.handPhase === 'rejoin') return o.decisionSeconds * 1000;
|
||||
if (v.handPhase === 'handEnd') return 5000;
|
||||
if (o.turnSeconds === null) return 0;
|
||||
if (v.handPhase === 'choose') return (o.turnSeconds + 10) * 1000;
|
||||
const turn = v.seats.find((s) => s.id === v.toAct);
|
||||
return turn?.away ? 5000 : o.turnSeconds * 1000;
|
||||
}
|
||||
|
||||
/** Big banner over the table after a showdown (or none). */
|
||||
function bannerOf(v: SeotdaView): string | null {
|
||||
const pots = v.showdown?.pots ?? [];
|
||||
if (pots.some((p) => p.reason === 'ttaengjabi')) return '땡잡이!';
|
||||
if (pots.some((p) => p.reason === 'amhaeng')) return '암행어사 출두!';
|
||||
if (pots.some((p) => p.type === 'rematch' && p.reason === 'gusa')) return '구사 재경기';
|
||||
if (pots.some((p) => p.type === 'rematch' && p.reason === 'mungGusa')) return '멍텅구리구사 재경기';
|
||||
if (pots.some((p) => p.type === 'rematch')) return '같은 족보 재경기';
|
||||
const win = pots.find((p) => p.type === 'win');
|
||||
const name = win ? v.showdown!.hands.find((h) => h.id === win.winners[0])?.name : null;
|
||||
if (name && /광땡|장땡/.test(name)) return `${name}!`;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Hand names worth a gold badge (땡 and up). */
|
||||
const isBig = (name: string) => /광땡|땡$|장땡/.test(name) && name !== '땡잡이';
|
||||
|
||||
const CSS = `
|
||||
.sd-wrap { width: 100%; max-width: 1060px; display: flex; flex-direction: column; gap: 10px; align-self: center; }
|
||||
.sd-table { position: relative; width: 100%; aspect-ratio: 16 / 9.4; min-height: 470px; border-radius: 44px; border: 12px solid #5b3a1e;
|
||||
background: radial-gradient(ellipse at 50% 45%, #2f8a5c 0%, #1d6a44 55%, #134b30 100%); box-shadow: inset 0 0 0 3px rgba(255,255,255,.08), inset 0 0 60px rgba(0,0,0,.35), 0 8px 24px rgba(0,0,0,.3); }
|
||||
.sd-table::before { content: ''; position: absolute; inset: 14px; border-radius: 30px; border: 2px dashed rgba(255,255,255,.12); pointer-events: none; }
|
||||
.sd-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: 156px; z-index: 2;
|
||||
background: rgba(10, 22, 16, .78); color: #f8fafc; border-radius: 12px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px;
|
||||
border: 2px solid rgba(255,255,255,.12); box-shadow: 0 3px 10px rgba(0,0,0,.35); font-size: .82rem; transition: border-color .2s, opacity .2s; }
|
||||
.sd-seat.turn { border-color: #fbbf24; box-shadow: 0 0 0 3px rgba(251,191,36,.35), 0 3px 10px rgba(0,0,0,.35); }
|
||||
.sd-seat.out { opacity: .55; }
|
||||
.sd-seat.win { border-color: #fde047; box-shadow: 0 0 0 3px rgba(253,224,71,.5), 0 0 22px rgba(253,224,71,.45); }
|
||||
.sd-seat .nm { font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.sd-money { font-variant-numeric: tabular-nums; font-weight: 800; color: #fde68a; white-space: nowrap; }
|
||||
.sd-cards { display: flex; justify-content: center; min-height: 52px; align-items: flex-end; }
|
||||
.sd-tag { display: inline-block; border-radius: 999px; padding: 0 7px; font-weight: 800; font-size: .74rem; line-height: 1.5; white-space: nowrap; }
|
||||
.sd-act { position: absolute; top: -14px; right: -8px; z-index: 3; border-radius: 10px; padding: 1px 9px; font-weight: 900; font-size: .85rem; color: #fff;
|
||||
box-shadow: 0 2px 6px rgba(0,0,0,.35); pointer-events: none; }
|
||||
.sd-hand { text-align: center; font-weight: 900; font-size: .92rem; border-radius: 8px; padding: 1px 4px; background: rgba(255,255,255,.12); color: #fff; }
|
||||
.sd-hand.big { background: linear-gradient(180deg, #fde047, #f59e0b); color: #422006; }
|
||||
.sd-delta { text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }
|
||||
.sd-delta.plus { color: #86efac; } .sd-delta.minus { color: #fca5a5; }
|
||||
.sd-center { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); text-align: center; color: #fff; z-index: 1; min-width: 220px; }
|
||||
.sd-pot-label { display: inline-block; font-size: .9rem; font-weight: 800; letter-spacing: .1em; background: rgba(0,0,0,.35); border-radius: 999px; padding: 1px 12px; }
|
||||
.sd-pot { font-size: 2.3rem; font-weight: 900; font-variant-numeric: tabular-nums; color: #fde68a; text-shadow: 0 2px 6px rgba(0,0,0,.55); line-height: 1.15; }
|
||||
.sd-pile { position: relative; height: 34px; width: 120px; margin: 0 auto 2px; }
|
||||
.sd-pile i { position: absolute; bottom: 0; width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff7c2, #f5b301 55%, #b45309);
|
||||
border: 2px solid #92400e; box-shadow: 0 2px 3px rgba(0,0,0,.4); }
|
||||
.sd-info { font-size: .82rem; opacity: .92; margin-top: 2px; }
|
||||
.sd-banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; z-index: 6; font-size: 3rem; font-weight: 900; color: #fde047;
|
||||
-webkit-text-stroke: 2px #7c2d12; text-shadow: 0 4px 12px rgba(0,0,0,.6); white-space: nowrap; }
|
||||
.sd-fly { position: absolute; left: var(--sx); top: var(--sy); width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; z-index: 7; pointer-events: none;
|
||||
background: radial-gradient(circle at 35% 35%, #fff7c2, #f5b301 55%, #b45309); border: 2px solid #92400e;
|
||||
animation: sd-fly .55s cubic-bezier(.3,.7,.4,1) both; animation-delay: var(--d, 0ms); }
|
||||
@keyframes sd-fly { from { transform: translate(0, 0) scale(.9); opacity: 1; } 85% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(.7); opacity: 0; } }
|
||||
.sd-me { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 2; display: flex; align-items: flex-end; gap: 14px;
|
||||
background: rgba(10, 22, 16, .72); border: 2px solid rgba(255,255,255,.14); border-radius: 16px; padding: 8px 14px; color: #fff; max-width: 96%; }
|
||||
.sd-me.turn { border-color: #fbbf24; box-shadow: 0 0 0 3px rgba(251,191,36,.35); }
|
||||
.sd-me.win { border-color: #fde047; box-shadow: 0 0 0 3px rgba(253,224,71,.5), 0 0 22px rgba(253,224,71,.45); }
|
||||
.sd-me .mine { display: flex; gap: 6px; align-items: flex-end; }
|
||||
.sd-me .meta { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
|
||||
.sd-myhand { font-size: 1.45rem; font-weight: 900; color: #fde047; text-shadow: 0 2px 4px rgba(0,0,0,.5); line-height: 1.15; }
|
||||
.sd-bar { display: flex; gap: 12px; align-items: stretch; justify-content: center; flex-wrap: wrap; }
|
||||
.sd-bets { display: grid; grid-template-columns: repeat(3, minmax(92px, 1fr)); gap: 8px; flex: 1; max-width: 560px; }
|
||||
.sd-bet { position: relative; min-height: 58px; border: 0; border-radius: 12px; color: #fff; font-weight: 900; font-size: 1.15rem; cursor: pointer;
|
||||
display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.2); }
|
||||
.sd-bet small { font-size: .78rem; font-weight: 700; opacity: .95; font-variant-numeric: tabular-nums; }
|
||||
.sd-bet kbd { position: absolute; top: 4px; left: 6px; font: 700 .7rem/1 inherit; opacity: .8; background: rgba(0,0,0,.25); border-radius: 4px; padding: 2px 4px; }
|
||||
.sd-bet:disabled { filter: grayscale(.85) brightness(.85); opacity: .45; cursor: default; box-shadow: none; }
|
||||
.sd-bet:not(:disabled):hover { filter: brightness(1.1); }
|
||||
.sd-bet:not(:disabled):active { transform: translateY(1px); }
|
||||
.sd-help { margin: 0; text-align: center; min-height: 1.4em; }
|
||||
@media (max-width: 719px) {
|
||||
.sd-table { aspect-ratio: auto; min-height: 0; border-width: 7px; border-radius: 22px; padding: 10px 8px; display: flex; flex-direction: column; gap: 8px; }
|
||||
.sd-table::before { inset: 6px; border-radius: 16px; }
|
||||
.sd-others { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 6px; }
|
||||
.sd-seat { position: relative; left: auto; top: auto; transform: none; width: auto; padding: 5px 6px; font-size: .76rem; }
|
||||
.sd-cards { min-height: 40px; }
|
||||
.sd-act { top: -9px; right: auto; left: -4px; font-size: .74rem; padding: 0 7px; }
|
||||
.sd-center { position: relative; left: auto; top: auto; transform: none; min-width: 0; padding: 2px 0; }
|
||||
.sd-pot { font-size: 1.8rem; }
|
||||
.sd-pile { height: 26px; }
|
||||
.sd-pile i { width: 20px; height: 20px; }
|
||||
.sd-banner { position: fixed; top: 38%; font-size: 2.2rem; }
|
||||
.sd-me { position: relative; left: auto; bottom: auto; transform: none; max-width: none; justify-content: center; gap: 10px; padding: 8px; }
|
||||
.sd-me .meta { min-width: 0; flex: 1; }
|
||||
.sd-myhand { font-size: 1.15rem; }
|
||||
.sd-bets { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; max-width: none; }
|
||||
.sd-bet { min-height: 56px; font-size: 1.05rem; }
|
||||
.sd-bet kbd { display: none; }
|
||||
}
|
||||
`;
|
||||
|
||||
// ---------------------------------------------------------------- table positions
|
||||
|
||||
/** Seats other than mine around the table: from my left, over the top, to my right (PC). */
|
||||
function seatPos(rel: number, others: number): { x: number; y: number } {
|
||||
const t = rel / (others + 1);
|
||||
const ang = ((150 + t * 240) * Math.PI) / 180;
|
||||
return { x: 50 + 41 * Math.cos(ang), y: 49 + 36 * Math.sin(ang) };
|
||||
}
|
||||
|
||||
/** Pile of coins in the middle; more coins for a bigger 판돈 (up to 9). */
|
||||
function Pile({ pot, base }: { pot: number; base: number }) {
|
||||
const n = pot <= 0 ? 0 : Math.min(9, 1 + Math.floor(Math.log2(Math.max(1, pot / Math.max(1, base)))));
|
||||
return (
|
||||
<div className="sd-pile" aria-hidden>
|
||||
{Array.from({ length: n }, (_, i) => (
|
||||
<i key={i} style={{ left: 47 + ((i % 3) - 1) * 22 + (i > 2 ? 6 : 0), bottom: Math.floor(i / 3) * 6 }} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- seats
|
||||
|
||||
function SeatCards({ seat, view: v, width }: { seat: SeotdaSeatView; view: SeotdaView; width: number }) {
|
||||
if (!seat.cards.length) return <div className="sd-cards" />;
|
||||
const tag = `${v.handNo}-${v.rematchNo}`;
|
||||
return (
|
||||
<div className="sd-cards">
|
||||
{seat.cards.map((c, i) =>
|
||||
isCard(c) ? (
|
||||
<HwatuCard key={c.key} card={c} width={width} className="anim-flip" style={{ marginLeft: i ? -Math.round(width * 0.3) : 0, ['--anim-delay' as string]: `${i * 90}ms` }} />
|
||||
) : (
|
||||
<HwatuCard key={`b${tag}-${i}`} card={null} width={width} className="anim-deal" style={{ marginLeft: i ? -Math.round(width * 0.3) : 0, ['--anim-delay' as string]: `${i * 80}ms` }} />
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ActBubble({ seat }: { seat: SeotdaSeatView }) {
|
||||
const a = seat.folded ? { type: 'die' as BetType, amount: 0 } : seat.lastAction;
|
||||
if (!a) return null;
|
||||
return (
|
||||
<span key={`${a.type}-${a.amount}`} className="sd-act anim-pop" style={{ background: BET_COLOR[a.type] }}>
|
||||
{BET_KO[a.type]}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
interface SeatProps {
|
||||
seat: SeotdaSeatView;
|
||||
view: SeotdaView;
|
||||
players: Record<string, PublicUser>;
|
||||
me: string | null;
|
||||
deadline: number | null;
|
||||
pos: { x: number; y: number } | null;
|
||||
cardW: number;
|
||||
winner: boolean;
|
||||
setRef: (id: string, el: HTMLElement | null) => void;
|
||||
}
|
||||
|
||||
function Seat({ seat, view: v, players, me, deadline, pos, cardW, winner, setRef }: SeatProps) {
|
||||
const u = userOf(players, seat.id);
|
||||
const out = seat.status === 'eliminated' || seat.folded || (!seat.inHand && v.handPhase !== null);
|
||||
const tags: [string, string][] = [];
|
||||
if (seat.left) tags.push(['나감', '#b91c1c']);
|
||||
else if (seat.away) tags.push(['자리 비움', '#b45309']);
|
||||
if (seat.status === 'eliminated') tags.push(['탈락', '#475569']);
|
||||
if (seat.status === 'busted') tags.push(['다시 받는 중', '#b45309']);
|
||||
if (seat.allIn) tags.push(['올인', '#1d4ed8']);
|
||||
if (seat.chosen === true) tags.push(['고름', '#15803d']);
|
||||
if (seat.chosen === false) tags.push(['고르는 중', '#475569']);
|
||||
const timed = seat.isTurn || seat.chosen === false;
|
||||
const style = pos ? ({ '--x': `${pos.x}%`, '--y': `${pos.y}%` } as CSSProperties) : undefined;
|
||||
return (
|
||||
<div
|
||||
ref={(el) => setRef(seat.id, el)}
|
||||
className={`sd-seat${seat.isTurn ? ' turn' : ''}${out ? ' out' : ''}${winner ? ' win' : ''}`}
|
||||
style={style}
|
||||
aria-label={`${u.nickname}, 보유 ${formatWon(seat.stack)}${seat.isDealer ? ', 선' : ''}${seat.folded ? ', 다이' : ''}${tags.length ? `, ${tags.map((t) => t[0]).join(', ')}` : ''}`}
|
||||
>
|
||||
<ActBubble seat={seat} />
|
||||
<div className="row" style={{ gap: 5, flexWrap: 'nowrap' }}>
|
||||
<Avatar user={u} size={22} />
|
||||
<span className="nm">
|
||||
{u.nickname}
|
||||
{seat.id === me && ' (나)'}
|
||||
</span>
|
||||
{seat.isDealer && (
|
||||
<span className="sd-tag" style={{ background: '#facc15', color: '#422006' }} title="선(먼저 받고 먼저 거는 사람)">
|
||||
선
|
||||
</span>
|
||||
)}
|
||||
{timed && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine={seat.id === me} size={26} />}
|
||||
</div>
|
||||
<div className="row" style={{ justifyContent: 'space-between', gap: 4, flexWrap: 'nowrap' }}>
|
||||
<span className="sd-money" title="보유 금액">
|
||||
{formatWonShort(seat.stack)}원
|
||||
</span>
|
||||
{seat.matchBet > 0 && (
|
||||
<span className="small" style={{ opacity: 0.85, whiteSpace: 'nowrap' }} title="이번 판에 건 돈">
|
||||
건 돈 {formatWonShort(seat.matchBet)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<SeatCards seat={seat} view={v} width={cardW} />
|
||||
{seat.handName && <div className={`sd-hand${isBig(seat.handName) ? ' big' : ''} anim-pop`}>{seat.handName}</div>}
|
||||
{seat.handDelta !== null && seat.handDelta !== 0 && (
|
||||
<div className={`sd-delta anim-slide-up ${seat.handDelta > 0 ? 'plus' : 'minus'}`}>{formatWonDelta(seat.handDelta)}</div>
|
||||
)}
|
||||
{tags.length > 0 && (
|
||||
<div className="row" style={{ gap: 3 }}>
|
||||
{tags.map(([t, c]) => (
|
||||
<span key={t} className="sd-tag" style={{ background: c, color: '#fff' }}>
|
||||
{t}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** My place at the bottom of the table: big cards, 족보 name, money. */
|
||||
function MySeat({ seat, view: v, players, deadline, winner, setRef, phone }: { seat: SeotdaSeatView; view: SeotdaView; players: Record<string, PublicUser>; deadline: number | null; winner: boolean; setRef: SeatProps['setRef']; phone: boolean }) {
|
||||
const u = userOf(players, seat.id);
|
||||
const cards = seat.cards;
|
||||
const w = phone ? (cards.length > 2 ? 62 : 74) : cards.length > 2 ? 78 : 92;
|
||||
const tag = `${v.handNo}-${v.rematchNo}`;
|
||||
const h = v.myHand;
|
||||
return (
|
||||
<div ref={(el) => setRef(seat.id, el)} className={`sd-me${seat.isTurn ? ' turn' : ''}${winner ? ' win' : ''}`} aria-label={`내 자리, 보유 ${formatWon(seat.stack)}`}>
|
||||
<ActBubble seat={seat} />
|
||||
<div className="mine" aria-label="내 패">
|
||||
{cards.length === 0 && <span className="small" style={{ opacity: 0.8, alignSelf: 'center' }}>{seat.inHand ? '패를 기다리는 중' : '이번 판은 쉬어요'}</span>}
|
||||
{cards.map((c, i) =>
|
||||
isCard(c) ? (
|
||||
<HwatuCard
|
||||
key={c.key}
|
||||
card={c}
|
||||
width={w}
|
||||
className="anim-deal"
|
||||
highlight={!!v.myChosen?.includes(c.id)}
|
||||
dimmed={(!!v.myChosen && !v.myChosen.includes(c.id)) || seat.folded}
|
||||
style={{ ['--anim-delay' as string]: `${i * 110}ms`, ['--from-y' as string]: '-180px' }}
|
||||
/>
|
||||
) : (
|
||||
<HwatuCard key={`m${tag}-${i}`} card={null} width={w} />
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
<div className="meta">
|
||||
<div className="row" style={{ gap: 6, flexWrap: 'nowrap' }}>
|
||||
<Avatar user={u} size={22} />
|
||||
<strong style={{ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{u.nickname} (나)</strong>
|
||||
{seat.isDealer && (
|
||||
<span className="sd-tag" style={{ background: '#facc15', color: '#422006' }}>
|
||||
선
|
||||
</span>
|
||||
)}
|
||||
{(seat.isTurn || seat.chosen === false) && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine size={30} />}
|
||||
</div>
|
||||
<span className="sd-money" style={{ fontSize: '1.05rem' }}>
|
||||
{formatWon(seat.stack)}
|
||||
</span>
|
||||
{h && seat.inHand && !seat.folded && !seat.handName && (
|
||||
<span className="sd-myhand" aria-live="polite">
|
||||
{h.name}
|
||||
</span>
|
||||
)}
|
||||
{h && seat.inHand && !seat.folded && !seat.handName && v.options.hints && <span className="small" style={{ opacity: 0.9 }}>{h.hint}</span>}
|
||||
{seat.folded && <span className="small" style={{ opacity: 0.9 }}>다이했어요. 내 패는 나만 볼 수 있어요.</span>}
|
||||
{seat.handName && <div className={`sd-myhand anim-pop`}>{seat.handName}</div>}
|
||||
{seat.handDelta !== null && seat.handDelta !== 0 && (
|
||||
<div className={`sd-delta anim-slide-up ${seat.handDelta > 0 ? 'plus' : 'minus'}`} style={{ textAlign: 'left', fontSize: '1.1rem' }}>
|
||||
{formatWonDelta(seat.handDelta)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Center({ view: v, potRef }: { view: SeotdaView; potRef: (el: HTMLElement | null) => void }) {
|
||||
const limit = v.options.endCondition === 'hands' ? `/${v.options.handLimit}` : '';
|
||||
// On the result screen the paid pots are no longer in v.pot (only a carried rematch pot is).
|
||||
const paid =
|
||||
v.handPhase === 'handEnd' ? (v.foldWin?.amount ?? (v.showdown?.pots ?? []).filter((p) => p.type !== 'rematch').reduce((a, p) => a + p.amount, 0)) : 0;
|
||||
const shown = v.pot + paid;
|
||||
const [bump, setBump] = useState(0);
|
||||
const last = useRef(v.pot);
|
||||
useEffect(() => {
|
||||
if (v.pot > last.current) setBump((b) => b + 1);
|
||||
last.current = v.pot;
|
||||
}, [v.pot]);
|
||||
return (
|
||||
<div className="sd-center" ref={potRef}>
|
||||
{v.rematchNo > 0 && v.rematchReason && (
|
||||
<div className="sd-tag" style={{ background: '#fde047', color: '#422006', fontSize: '.9rem', padding: '1px 12px', marginBottom: 4 }}>
|
||||
재경기 {v.rematchNo}회차 · {REMATCH_KO[v.rematchReason]}
|
||||
</div>
|
||||
)}
|
||||
<Pile pot={shown} base={v.baseUnit} />
|
||||
<div className="sd-pot-label">판돈</div>
|
||||
<div key={bump} className={`sd-pot${bump ? ' anim-bump' : ''}`} aria-live="polite" aria-label={`판돈 ${formatWon(shown)}`}>
|
||||
{formatWon(shown)}
|
||||
</div>
|
||||
{v.pots.length > 1 && v.handPhase === 'betting' && (
|
||||
<div className="small" style={{ opacity: 0.9 }}>
|
||||
{v.pots.map((p, i) => (
|
||||
<div key={i}>
|
||||
{i === v.pots.length - 1 ? '메인' : `사이드 ${i + 1}`} {formatWonShort(p.amount)}원
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="sd-info">
|
||||
{v.phase === 'finished' ? '게임 끝' : `${Math.max(1, v.handNo)}${limit}판`} · 기본금 {formatWon(v.baseUnit)}
|
||||
{v.handPhase === 'betting' && v.currentBet > 0 ? ` · 콜 ${formatWonShort(v.currentBet)}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- effects (sound + motion from view changes)
|
||||
|
||||
interface Fly {
|
||||
id: number;
|
||||
sx: number;
|
||||
sy: number;
|
||||
dx: number;
|
||||
dy: number;
|
||||
d: number;
|
||||
}
|
||||
|
||||
function useTableEffects(v: SeotdaView, me: string | null, tableRef: React.RefObject<HTMLDivElement | null>, seatEls: React.MutableRefObject<Map<string, HTMLElement>>, potEl: React.MutableRefObject<HTMLElement | null>) {
|
||||
const [flies, setFlies] = useState<Fly[]>([]);
|
||||
const [banner, setBanner] = useState<{ text: string; key: number } | null>(null);
|
||||
const seen = useRef<{ match: string; log: number; cards: number; phase: string | null } | null>(null);
|
||||
const flyId = useRef(0);
|
||||
|
||||
const center = (el: HTMLElement | null | undefined) => {
|
||||
const t = tableRef.current?.getBoundingClientRect();
|
||||
const r = el?.getBoundingClientRect();
|
||||
if (!t || !r) return null;
|
||||
return { x: r.left + r.width / 2 - t.left, y: r.top + r.height / 2 - t.top };
|
||||
};
|
||||
const launch = (from: string | 'pot', to: string | 'pot', n: number) => {
|
||||
const a = center(from === 'pot' ? potEl.current : seatEls.current.get(from));
|
||||
const b = center(to === 'pot' ? potEl.current : seatEls.current.get(to));
|
||||
if (!a || !b) return;
|
||||
const add: Fly[] = Array.from({ length: n }, (_, i) => ({ id: ++flyId.current, sx: a.x + (i % 2 ? 6 : -6), sy: a.y, dx: b.x - a.x, dy: b.y - a.y, d: i * 70 }));
|
||||
setFlies((f) => [...f, ...add]);
|
||||
const ids = new Set(add.map((x) => x.id));
|
||||
setTimeout(() => setFlies((f) => f.filter((x) => !ids.has(x.id))), 700 + n * 70);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const match = `${v.handNo}-${v.rematchNo}`;
|
||||
const cards = v.seats.reduce((a, s) => a + s.cards.length, 0);
|
||||
const prev = seen.current;
|
||||
seen.current = { match, log: v.betLog.length, cards, phase: v.handPhase };
|
||||
if (!prev) return; // first render: nothing to replay
|
||||
const sameMatch = prev.match === match;
|
||||
// Deal: a new (re)match or more cards on the table.
|
||||
if (!sameMatch || cards > prev.cards) {
|
||||
if (!sameMatch) sfx.shuffle();
|
||||
const dealt = sameMatch ? cards - prev.cards : cards;
|
||||
if (v.handPhase === 'betting' || v.handPhase === 'choose') sfx.deal(Math.min(6, Math.max(1, dealt)), 60);
|
||||
}
|
||||
// Bets since last time (anyone's): coins fly from the seat to the 판돈.
|
||||
const fresh: BetLogEntry[] = sameMatch ? v.betLog.slice(prev.log) : v.betLog;
|
||||
fresh.forEach((e, i) => {
|
||||
setTimeout(() => {
|
||||
if (e.t === 'die') sfx.whoosh();
|
||||
else if (e.amount <= 0) sfx.tick();
|
||||
else {
|
||||
const n = e.t === 'ping' || e.t === 'call' ? 2 : e.t === 'full' ? 5 : e.t === 'quarter' ? 3 : 4;
|
||||
sfx.chips(n);
|
||||
launch(e.p, 'pot', n);
|
||||
}
|
||||
}, i * 220);
|
||||
});
|
||||
// Result: reveal, payout, banner.
|
||||
if (v.handPhase === 'handEnd' && prev.phase !== 'handEnd') {
|
||||
if (v.showdown) sfx.cardFlip();
|
||||
const winners = new Set<string>();
|
||||
if (v.foldWin) winners.add(v.foldWin.winner);
|
||||
for (const p of v.showdown?.pots ?? []) if (p.type !== 'rematch') for (const w of p.winners) winners.add(w);
|
||||
const b = bannerOf(v);
|
||||
setTimeout(() => {
|
||||
for (const w of winners) launch('pot', w, 5);
|
||||
if (winners.size) sfx.collect();
|
||||
if (b) {
|
||||
setBanner({ text: b, key: Date.now() });
|
||||
if (/땡잡이|암행어사|광땡|장땡/.test(b)) sfx.fanfare();
|
||||
else sfx.pop();
|
||||
}
|
||||
if (me && winners.has(me)) {
|
||||
sounds.win();
|
||||
haptic([40, 30, 80]);
|
||||
} else if (me && v.showdown?.hands.some((h) => h.id === me) && !v.showdown.pots.some((p) => p.type === 'rematch' && p.winners.includes(me))) sounds.lose();
|
||||
}, v.showdown ? 450 : 150);
|
||||
}
|
||||
}); // every render: cheap comparisons against the refs
|
||||
|
||||
useEffect(() => {
|
||||
if (!banner) return undefined;
|
||||
const t = setTimeout(() => setBanner(null), 1700);
|
||||
return () => clearTimeout(t);
|
||||
}, [banner]);
|
||||
|
||||
return { flies, banner };
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- bet bar
|
||||
|
||||
function BetBar({ view: v, me, act, pending, players }: { view: SeotdaView; me: string; act: (a: unknown) => void; pending: boolean; players: Record<string, PublicUser> }) {
|
||||
const seat = v.seats.find((s) => s.id === me)!;
|
||||
const myTurn = v.toAct === me && v.handPhase === 'betting';
|
||||
const legal = new Map(v.legal.map((l) => [l.type, l]));
|
||||
const [hover, setHover] = useState<BetType | null>(null);
|
||||
const types: BetType[] = ['call', 'die', 'half', 'ping', 'check', 'ddadang'];
|
||||
if (v.options.quarter) types.push('quarter');
|
||||
if (v.options.maxRaise === 'full') types.push('full');
|
||||
const press = (t: BetType) => {
|
||||
if (!myTurn || pending || !legal.has(t)) return;
|
||||
sfx.click();
|
||||
act({ type: t });
|
||||
};
|
||||
// Number keys (PC), like 한게임 섯다. Ignored while typing in the chat.
|
||||
const pressRef = useRef(press);
|
||||
pressRef.current = press;
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
||||
const el = e.target as HTMLElement | null;
|
||||
if (el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT' || el.isContentEditable)) return;
|
||||
const t = (Object.keys(BET_KEY) as BetType[]).find((k) => BET_KEY[k] === e.key);
|
||||
if (t) {
|
||||
pressRef.current(t);
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', onKey);
|
||||
return () => window.removeEventListener('keydown', onKey);
|
||||
}, []);
|
||||
const hoverBet = hover ? legal.get(hover) : undefined;
|
||||
return (
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<div className="sd-bar">
|
||||
<div className="sd-bets" role="group" aria-label="베팅">
|
||||
{types.map((t) => {
|
||||
const l = legal.get(t);
|
||||
const enabled = myTurn && !!l && !pending;
|
||||
return (
|
||||
<button
|
||||
key={t}
|
||||
type="button"
|
||||
className={`sd-bet${enabled && t !== 'die' ? ' anim-pop' : ''}`}
|
||||
style={{ background: BET_COLOR[t] }}
|
||||
disabled={!enabled}
|
||||
title={`${BET_HELP[t]} (숫자 ${BET_KEY[t]})`}
|
||||
aria-keyshortcuts={BET_KEY[t]}
|
||||
onMouseEnter={() => setHover(t)}
|
||||
onMouseLeave={() => setHover(null)}
|
||||
onFocus={() => setHover(t)}
|
||||
onBlur={() => setHover(null)}
|
||||
onClick={() => press(t)}
|
||||
>
|
||||
<kbd aria-hidden>{BET_KEY[t]}</kbd>
|
||||
<span>{BET_KO[t]}</span>
|
||||
<small>{l ? (l.amount > 0 ? `${formatWonShort(l.amount)}원${l.allIn ? ' 올인' : ''}` : t === 'die' ? '포기' : '0원') : ' '}</small>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<p className="small muted sd-help">
|
||||
{myTurn
|
||||
? hoverBet
|
||||
? `${BET_KO[hover!]}: ${BET_HELP[hover!]}. 걸고 나면 내 돈 ${formatWon(seat.stack - hoverBet.amount)}, 판돈 ${formatWon(v.pot + hoverBet.amount)}`
|
||||
: v.forcedHalf
|
||||
? `베팅 규칙 ${v.options.betRule}: 첫 베팅은 하프 또는 다이만 할 수 있어요.`
|
||||
: '내 차례예요. 버튼이나 숫자 키로 걸어요.'
|
||||
: v.toAct
|
||||
? `${nick(players, v.toAct)}님 차례예요.`
|
||||
: ' '}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 3장 섯다 choice and result
|
||||
|
||||
function ChooseBox({ view: v, me, act, pending }: { view: SeotdaView; me: string; act: (a: unknown) => void; pending: boolean }) {
|
||||
const seat = v.seats.find((s) => s.id === me)!;
|
||||
const [pick, setPick] = useState<number[]>([]);
|
||||
useEffect(() => setPick([]), [v.handNo, v.rematchNo]);
|
||||
const cards = seat.cards.filter(isCard);
|
||||
const preview = pick.length === 2 ? v.myCombos?.find((c) => c.cardIds.includes(pick[0]!) && c.cardIds.includes(pick[1]!)) : null;
|
||||
const toggle = (id: number) => setPick((p) => (p.includes(id) ? p.filter((x) => x !== id) : p.length >= 2 ? [p[1]!, id] : [...p, id]));
|
||||
return (
|
||||
<div className="card stack" style={{ gap: 8, padding: 12 }}>
|
||||
<p style={{ margin: 0, textAlign: 'center' }}>
|
||||
<strong>쓸 패 2장을 골라 주세요.</strong> 남는 1장은 아무에게도 보이지 않아요.
|
||||
</p>
|
||||
<div className="row" style={{ justifyContent: 'center', gap: 10 }}>
|
||||
{cards.map((c) => (
|
||||
<HwatuCard key={c.key} card={c} size="lg" selected={pick.includes(c.id)} onClick={() => toggle(c.id)} />
|
||||
))}
|
||||
</div>
|
||||
{v.options.hints && v.myCombos && (
|
||||
<div className="row" style={{ justifyContent: 'center', gap: 6 }}>
|
||||
{v.myCombos.map((c) => (
|
||||
<button key={c.cardIds.join()} type="button" className={`btn btn-sm ${c.best ? 'btn-soft' : 'btn-ghost'}`} onClick={() => setPick([...c.cardIds])}>
|
||||
{c.name}
|
||||
{c.best ? ' (추천)' : ''}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<button type="button" className="btn btn-primary" disabled={pick.length !== 2 || pending} onClick={() => act({ type: 'choose', cardIds: [pick[0], pick[1]] })}>
|
||||
{preview ? `${preview.name}(으)로 정하기` : '두 장을 고르세요'}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function resultLine(v: SeotdaView, players: Record<string, PublicUser>): string {
|
||||
if (v.foldWin) return `${nick(players, v.foldWin.winner)}님이 판돈 ${formatWon(v.foldWin.amount)}을 가져갔어요(모두 다이).`;
|
||||
if (!v.showdown) return '';
|
||||
return v.showdown.pots
|
||||
.map((p) => {
|
||||
const who = p.winners.map((id) => nick(players, id)).join('·');
|
||||
const name = v.showdown!.hands.find((h) => h.id === p.winners[0])?.name ?? '';
|
||||
if (p.type === 'rematch') return `${REASON_KO[p.reason]}: ${who}님이 다시 겨뤄요(판돈 ${formatWon(p.amount)} 그대로)`;
|
||||
if (p.type === 'split') return `${who}님이 ${formatWon(p.amount)}을 나눠 가졌어요${p.reason === 'limit' ? '(재경기 횟수 초과)' : ''}`;
|
||||
return `${who}님이 ${name}${p.reason === 'normal' ? '' : ' 발동'}(으)로 ${formatWon(p.amount)}을 가져갔어요`;
|
||||
})
|
||||
.join(' / ');
|
||||
}
|
||||
|
||||
function ResultPanel({ view: v, players }: { view: SeotdaView; players: Record<string, PublicUser> }) {
|
||||
return (
|
||||
<div className="card stack" style={{ gap: 4, padding: 12 }} aria-live="polite">
|
||||
<strong>{v.next === 'rematch' ? '재경기가 정해졌어요' : '이번 판 결과'}</strong>
|
||||
{v.foldWin && (
|
||||
<span>
|
||||
{nick(players, v.foldWin.winner)}님이 판돈 {formatWon(v.foldWin.amount)}을 가져갔어요. 모두 다이해서 패는 공개하지 않아요.
|
||||
</span>
|
||||
)}
|
||||
{v.showdown?.pots.map((p, i) => {
|
||||
const who = p.winners.map((id) => nick(players, id)).join(' · ');
|
||||
const name = v.showdown!.hands.find((h) => h.id === p.winners[0])?.name;
|
||||
const label = v.showdown!.pots.length > 1 ? `${i === v.showdown!.pots.length - 1 ? '메인' : '사이드'} ${formatWon(p.amount)}: ` : `판돈 ${formatWon(p.amount)}: `;
|
||||
return (
|
||||
<span key={i}>
|
||||
{label}
|
||||
{p.type === 'win' && (
|
||||
<>
|
||||
<strong>{who}</strong> 승리 ({name}
|
||||
{p.reason === 'ttaengjabi' || p.reason === 'amhaeng' ? ' 발동' : ''})
|
||||
</>
|
||||
)}
|
||||
{p.type === 'split' && (
|
||||
<>
|
||||
<strong>{who}</strong> 나눠 가짐{p.reason === 'limit' ? ' (재경기 횟수 초과)' : ' (같은 족보)'}
|
||||
</>
|
||||
)}
|
||||
{p.type === 'rematch' && (
|
||||
<>
|
||||
<strong>{REASON_KO[p.reason]}</strong>: {who}님이 다시 겨뤄요. 판돈은 그대로 남아요.
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- board
|
||||
|
||||
export function SeotdaBoard({ view: v, me, players, act, pending, deadline }: BoardProps<SeotdaView>) {
|
||||
const phone = usePhone();
|
||||
const n = v.seats.length;
|
||||
const myIdx = v.seats.findIndex((s) => s.id === me);
|
||||
const mySeat = myIdx >= 0 ? v.seats[myIdx]! : null;
|
||||
const base = Math.max(0, myIdx);
|
||||
const others = v.seats.map((s, i) => ({ s, rel: (i - base + n) % n })).filter((x) => x.s.id !== mySeat?.id).sort((a, b) => a.rel - b.rel);
|
||||
const tableRef = useRef<HTMLDivElement | null>(null);
|
||||
const seatEls = useRef(new Map<string, HTMLElement>());
|
||||
const potEl = useRef<HTMLElement | null>(null);
|
||||
const setRef = (id: string, el: HTMLElement | null) => {
|
||||
if (el) seatEls.current.set(id, el);
|
||||
else seatEls.current.delete(id);
|
||||
};
|
||||
const { flies, banner } = useTableEffects(v, me, tableRef, seatEls, potEl);
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const prevToAct = useRef(v.toAct);
|
||||
useLayoutEffect(() => {
|
||||
if (v.toAct && v.toAct !== prevToAct.current) {
|
||||
if (v.toAct === me) {
|
||||
haptic(40);
|
||||
sounds.myTurn();
|
||||
setAnnounce('내 차례예요.');
|
||||
} else setAnnounce(`${nick(players, v.toAct)}님 차례예요.`);
|
||||
}
|
||||
prevToAct.current = v.toAct;
|
||||
}, [v.toAct]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
const winners = new Set<string>();
|
||||
if (v.handPhase === 'handEnd') {
|
||||
if (v.foldWin) winners.add(v.foldWin.winner);
|
||||
for (const p of v.showdown?.pots ?? []) if (p.type !== 'rematch') for (const w of p.winners) winners.add(w);
|
||||
}
|
||||
const cardW = phone ? (v.options.cardMode === 'three' ? 24 : 28) : v.options.cardMode === 'three' ? 38 : 46;
|
||||
const cols = phone ? (others.length > 4 ? 3 : 2) : 0;
|
||||
const othersEls: ReactNode = others.map(({ s, rel }) => (
|
||||
<Seat
|
||||
key={s.id}
|
||||
seat={s}
|
||||
view={v}
|
||||
players={players}
|
||||
me={me}
|
||||
deadline={deadline}
|
||||
pos={phone ? null : seatPos(mySeat ? rel : rel + 1, mySeat ? n - 1 : n)}
|
||||
cardW={cardW}
|
||||
winner={winners.has(s.id)}
|
||||
setRef={setRef}
|
||||
/>
|
||||
));
|
||||
return (
|
||||
<div className="sd-wrap">
|
||||
<style>{CSS}</style>
|
||||
<div className="sd-table" ref={tableRef} role="region" aria-label="섯다 테이블">
|
||||
{phone ? (
|
||||
<div className="sd-others" style={{ '--cols': cols } as CSSProperties}>
|
||||
{othersEls}
|
||||
</div>
|
||||
) : (
|
||||
othersEls
|
||||
)}
|
||||
<Center view={v} potRef={(el) => (potEl.current = el)} />
|
||||
{mySeat && <MySeat seat={mySeat} view={v} players={players} deadline={deadline} winner={winners.has(mySeat.id)} setRef={setRef} phone={phone} />}
|
||||
{flies.map((f) => (
|
||||
<span key={f.id} className="sd-fly" aria-hidden style={{ '--sx': `${f.sx}px`, '--sy': `${f.sy}px`, '--dx': `${f.dx}px`, '--dy': `${f.dy}px`, '--d': `${f.d}ms` } as CSSProperties} />
|
||||
))}
|
||||
{banner && (
|
||||
<div key={banner.key} className="sd-banner anim-banner" aria-hidden>
|
||||
{banner.text}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{mySeat && v.handPhase === 'choose' && mySeat.chosen === false && <ChooseBox view={v} me={mySeat.id} act={act} pending={pending} />}
|
||||
{mySeat && v.handPhase === 'choose' && mySeat.chosen === true && <p className="small muted sd-help">골랐어요. 다른 사람이 고르기를 기다리는 중이에요.</p>}
|
||||
{mySeat && mySeat.inHand && v.handPhase === 'betting' && !mySeat.folded && <BetBar view={v} me={mySeat.id} act={act} pending={pending} players={players} />}
|
||||
{v.handPhase === 'handEnd' && <ResultPanel view={v} players={players} />}
|
||||
{mySeat && v.handPhase === 'handEnd' && mySeat.status === 'playing' && !mySeat.left && (
|
||||
<button type="button" className="btn btn-primary btn-block" disabled={mySeat.ready || pending} onClick={() => act({ type: 'ready' })}>
|
||||
{mySeat.ready ? '다른 사람을 기다리는 중…' : v.next === 'rematch' ? '재경기 시작' : '다음 판으로'}
|
||||
</button>
|
||||
)}
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -7,8 +7,8 @@ const users = usersOf(['A', 'B', 'C']);
|
||||
const view = (s: unknown, who: string | null) => GAMES.seotda!.view(s, who) as any;
|
||||
const nickOf = (id: string) => users[id]!.nickname;
|
||||
|
||||
test('섯다: 내 차례(버튼·족보) / 상대 차례 / 관전', () => {
|
||||
const { state } = setupGame('seotda', 3);
|
||||
test('섯다: 내 차례(버튼·족보) / 상대 차례 / 관전 (1장씩 받는 방)', () => {
|
||||
const { state } = setupGame('seotda', 3, { dealMode: 'twoRounds' });
|
||||
const turn = view(state, null).toAct as string;
|
||||
const other = ['A', 'B', 'C'].find((id) => id !== turn)!;
|
||||
|
||||
@@ -27,7 +27,7 @@ test('섯다: 내 차례(버튼·족보) / 상대 차례 / 관전', () => {
|
||||
|
||||
const spec = helpNow(view(state, null), null, users);
|
||||
expect(spec).toContain(`${nickOf(turn)}님 차례예요`);
|
||||
expect(spec).toContain('모인 칩');
|
||||
expect(spec).toContain('판돈은 3만원');
|
||||
expect(spec).not.toContain('내 족보');
|
||||
expect(spec).not.toContain('월 한 장');
|
||||
|
||||
@@ -37,11 +37,25 @@ test('섯다: 내 차례(버튼·족보) / 상대 차례 / 관전', () => {
|
||||
const t = helpNow(view(s2, next), next, users);
|
||||
expect(t).toContain('[콜]');
|
||||
expect(t).toContain('[따당]');
|
||||
expect(t).toContain('[콜]은 그만큼(10 칩) 맞추는');
|
||||
expect(t).toContain('[콜]은 그만큼(1만원) 맞추는');
|
||||
expect(t).toContain('숫자 키(콜 7');
|
||||
});
|
||||
|
||||
test('섯다: 한게임 기본(2장 한 번에), 베팅 규칙 111 안내', () => {
|
||||
const { state } = setupGame('seotda', 3);
|
||||
const turn = view(state, null).toAct as string;
|
||||
const t = helpNow(view(state, turn), turn, users);
|
||||
expect(t).toContain('2장을 받고 한 번만 베팅해요');
|
||||
expect(t).toContain('지금 내 족보:');
|
||||
const forced = setupGame('seotda', 3, { betRule: '111' }).state;
|
||||
const p = view(forced, null).toAct as string;
|
||||
const f = helpNow(view(forced, p), p, users);
|
||||
expect(f).toContain('누를 수 있는 버튼: [다이] [하프]');
|
||||
expect(f).toContain('베팅 규칙 111');
|
||||
});
|
||||
|
||||
test('섯다: 2장째를 받으면 지금 내 족보와 마지막 베팅, 족보 숨기기 옵션', () => {
|
||||
let { state } = setupGame('seotda', 2);
|
||||
let { state } = setupGame('seotda', 2, { dealMode: 'twoRounds' });
|
||||
for (let i = 0; i < 2; i++) state = applyAction('seotda', state, view(state, null).toAct, { type: 'check' });
|
||||
const v = view(state, null);
|
||||
expect(v.street).toBe(1);
|
||||
@@ -51,7 +65,7 @@ test('섯다: 2장째를 받으면 지금 내 족보와 마지막 베팅, 족보
|
||||
|
||||
const off = setupGame('seotda', 2, { hints: false }).state;
|
||||
const p = view(off, null).toAct as string;
|
||||
expect(helpNow(view(off, p), p, users)).toContain("'족보표'를 보고");
|
||||
expect(helpNow(view(off, p), p, users)).toContain("'족보 도우미'를 보고");
|
||||
});
|
||||
|
||||
test('섯다: 3장 섯다 고르기 단계', () => {
|
||||
@@ -61,7 +75,7 @@ test('섯다: 3장 섯다 고르기 단계', () => {
|
||||
const t = helpNow(view(state, 'A'), 'A', users);
|
||||
expect(t).toContain('2장을 눌러 고르면');
|
||||
expect(t).toContain('정하기');
|
||||
expect(t).toContain('[추천 조합]');
|
||||
expect(t).toContain('(추천)]이 가장 센 조합');
|
||||
expect(helpNow(view(state, null), null, users)).toContain('몰래 고르는 중');
|
||||
|
||||
const v = view(state, 'A');
|
||||
@@ -81,7 +95,7 @@ test('섯다: 모두 다이 → 판 결과와 [다음 판으로], 다이한 사
|
||||
expect(t).toContain('[다음 판으로]');
|
||||
});
|
||||
|
||||
test('섯다: 칩 다시 받기 / 구사 재경기 참가 / 재경기 표시', () => {
|
||||
test('섯다: 시작 금액 다시 받기 / 구사 재경기 참가 / 재경기 표시', () => {
|
||||
const { state } = setupGame('seotda', 3);
|
||||
const rebuy = structuredClone(state);
|
||||
rebuy.phase = 'rebuy';
|
||||
@@ -90,15 +104,16 @@ test('섯다: 칩 다시 받기 / 구사 재경기 참가 / 재경기 표시', (
|
||||
rebuy.seats.find((s: any) => s.id === 'B').status = 'busted';
|
||||
rebuy.seats.find((s: any) => s.id === 'B').stack = 0;
|
||||
const b = helpNow(view(rebuy, 'B'), 'B', users);
|
||||
expect(b).toContain('[칩 다시 받기]');
|
||||
expect(b).toContain('[다시 받기]');
|
||||
expect(b).toContain('100만원');
|
||||
expect(b).toContain('[그만하기]');
|
||||
expect(helpNow(view(rebuy, 'A'), 'A', users)).toContain('고양이님이 칩을 다시 받을지');
|
||||
expect(helpNow(view(rebuy, 'A'), 'A', users)).toContain('고양이님이 시작 금액을 다시 받을지');
|
||||
|
||||
const rejoin = structuredClone(state);
|
||||
rejoin.hand.phase = 'rejoin';
|
||||
rejoin.hand.rejoinPending = ['C'];
|
||||
rejoin.hand.rejoinCost = 50;
|
||||
expect(helpNow(view(rejoin, 'C'), 'C', users)).toContain('[50 칩 내고 참가]');
|
||||
rejoin.hand.rejoinCost = 15_000;
|
||||
expect(helpNow(view(rejoin, 'C'), 'C', users)).toContain('[1만 5,000원 내고 참가]');
|
||||
expect(helpNow(view(rejoin, 'A'), 'A', users)).toContain('다시 들어올지');
|
||||
|
||||
const re = structuredClone(state);
|
||||
@@ -112,6 +127,6 @@ test('섯다: 게임 끝', () => {
|
||||
const end = structuredClone(state);
|
||||
end.phase = 'finished';
|
||||
end.hand = null;
|
||||
end.final = { ranking: [['A'], ['B']], scores: { A: 10, B: -10 }, summary: '20판 끝. 1위 +10칩' };
|
||||
end.final = { ranking: [['A'], ['B']], scores: { A: 10_000, B: -10_000 }, summary: '20판 끝. 1위 +1만원' };
|
||||
expect(helpNow(view(end, 'A'), 'A', users)).toContain('게임이 끝났어요. 20판 끝');
|
||||
});
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
/** 섯다 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view (never other players' cards). */
|
||||
import type { BetType, SeotdaSeatView, SeotdaView } from '@bg/games/seotda';
|
||||
import { formatWon } from '@bg/games/seotda/money';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
|
||||
/** Same order and labels as the bet buttons in index.tsx. */
|
||||
const BET_ORDER: BetType[] = ['die', 'check', 'ping', 'call', 'ddadang', 'quarter', 'half', 'full'];
|
||||
/** Same order, labels and number keys as the bet buttons in board.tsx (한게임 섯다 배치). */
|
||||
const BET_ORDER: BetType[] = ['call', 'die', 'half', 'ping', 'check', 'ddadang', 'quarter', 'full'];
|
||||
const BET_KEY: Record<BetType, string> = { call: '7', die: '8', ping: '4', check: '5', ddadang: '1', half: '0', quarter: '2', full: '9' };
|
||||
const BET_KO: Record<BetType, string> = { check: '체크', ping: '삥', call: '콜', ddadang: '따당', quarter: '쿼터', half: '하프', full: '풀', die: '다이' };
|
||||
const RAISES: BetType[] = ['ping', 'ddadang', 'quarter', 'half', 'full'];
|
||||
const STRENGTH_KO = { high: '센 패', mid: '중간 패', low: '약한 패' } as const;
|
||||
const REMATCH_KO = { gusa: '구사', mungGusa: '멍텅구리구사', tie: '같은 족보(동점)' } as const;
|
||||
const REASON_KO = { gusa: '구사', mungGusa: '멍텅구리구사', tie: '동점' } as const;
|
||||
|
||||
const chips = (n: number) => `${Math.max(0, Math.round(n)).toLocaleString('ko-KR')} 칩`;
|
||||
const won = (n: number) => formatWon(Math.max(0, n));
|
||||
|
||||
function who(players: Record<string, PublicUser>, id: string): string {
|
||||
return `${players[id]?.nickname ?? '다른 사람'}님`;
|
||||
@@ -32,27 +34,27 @@ function roundText(v: SeotdaView): string {
|
||||
/** My current hand as the view gives it (hints option on). */
|
||||
function handLine(v: SeotdaView, seat: SeotdaSeatView): string {
|
||||
const h = v.myHand;
|
||||
if (!h) return seat.cards.length > 0 ? "이 방은 족보 이름을 따로 보여 주지 않아요. '족보표'를 보고 내 패를 맞춰 보세요." : '';
|
||||
if (!h) return seat.cards.length > 0 ? "이 방은 족보 이름을 따로 보여 주지 않아요. '족보 도우미'를 보고 내 패를 맞춰 보세요." : '';
|
||||
if (h.special) return h.hint;
|
||||
if (h.value === null) return `지금은 ${h.name}만 받았어요. ${h.hint}`;
|
||||
return `지금 내 족보: ${h.name}${h.strength ? `(${STRENGTH_KO[h.strength]})` : ''}. 족보표에 '내 패'로 표시돼요.`;
|
||||
return `지금 내 족보: ${h.name}${h.strength ? `(${STRENGTH_KO[h.strength]})` : ''}. 족보 도우미에 '내 패'로 표시돼요.`;
|
||||
}
|
||||
|
||||
function rematchLine(v: SeotdaView): string {
|
||||
if (v.rematchNo === 0 || !v.rematchReason) return '';
|
||||
return `재경기 ${v.rematchNo}회차(${REMATCH_KO[v.rematchReason]})예요. 모인 칩은 그대로 두고, 학교(기본 칩)는 다시 내지 않아요.`;
|
||||
return `재경기 ${v.rematchNo}회차(${REMATCH_KO[v.rematchReason]})예요. 판돈은 그대로 두고, 기본금은 다시 내지 않아요.`;
|
||||
}
|
||||
|
||||
function resultLine(v: SeotdaView, players: Record<string, PublicUser>): string {
|
||||
if (v.foldWin) return `모두 다이해서 ${who(players, v.foldWin.winner)}이 ${chips(v.foldWin.amount)}을 가져갔어요. 이때는 패를 공개하지 않아요.`;
|
||||
if (v.foldWin) return `모두 다이해서 ${who(players, v.foldWin.winner)}이 판돈 ${won(v.foldWin.amount)}을 가져갔어요. 이때는 패를 공개하지 않아요.`;
|
||||
if (!v.showdown) return '이번 판이 끝났어요.';
|
||||
return v.showdown.pots
|
||||
.map((p) => {
|
||||
const names = p.winners.map((id) => players[id]?.nickname ?? '다른 사람').join('·') + '님';
|
||||
const name = v.showdown!.hands.find((h) => h.id === p.winners[0])?.name ?? '';
|
||||
if (p.type === 'rematch') return `${REASON_KO[p.reason as keyof typeof REASON_KO] ?? '동점'} 재경기: ${names}이 다시 겨뤄요. 모인 칩은 그대로 남아요.`;
|
||||
if (p.type === 'split') return `${names}이 ${chips(p.amount)}을 나눠 가졌어요.`;
|
||||
return `${names}이 ${name ? `${name}(으)로 ` : ''}${chips(p.amount)}을 가져갔어요.`;
|
||||
if (p.type === 'rematch') return `${REASON_KO[p.reason as keyof typeof REASON_KO] ?? '동점'} 재경기: ${names}이 다시 겨뤄요. 판돈은 그대로 남아요.`;
|
||||
if (p.type === 'split') return `${names}이 ${won(p.amount)}을 나눠 가졌어요.`;
|
||||
return `${names}이 ${name ? `${name}(으)로 ` : ''}${won(p.amount)}을 가져갔어요.`;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
@@ -73,10 +75,10 @@ function waitingLine(v: SeotdaView, players: Record<string, PublicUser>): string
|
||||
function watching(v: SeotdaView, players: Record<string, PublicUser>, prefix = ''): string {
|
||||
if (v.phase === 'rebuy') {
|
||||
const ids = v.rebuy?.pending ?? [];
|
||||
const names = ids.length ? ids.map((id) => players[id]?.nickname ?? '다른 사람').join('·') + '님이' : '칩을 모두 잃은 사람이';
|
||||
return `${prefix}${names} 칩을 다시 받을지 고르는 중이에요.`;
|
||||
const names = ids.length ? ids.map((id) => players[id]?.nickname ?? '다른 사람').join('·') + '님이' : '원을 모두 잃은 사람이';
|
||||
return `${prefix}${names} 시작 금액을 다시 받을지 고르는 중이에요.`;
|
||||
}
|
||||
return [prefix + waitingLine(v, players), v.handPhase === 'betting' ? `모인 칩은 ${chips(v.pot)}이에요.` : '', rematchLine(v)].filter(Boolean).join('\n');
|
||||
return [prefix + waitingLine(v, players), v.handPhase === 'betting' ? `판돈은 ${won(v.pot)}이에요.` : '', rematchLine(v)].filter(Boolean).join('\n');
|
||||
}
|
||||
|
||||
function myBetting(v: SeotdaView, seat: SeotdaSeatView): string {
|
||||
@@ -85,13 +87,14 @@ function myBetting(v: SeotdaView, seat: SeotdaSeatView): string {
|
||||
const lines = [`내 차례예요. ${roundText(v)}`];
|
||||
const hand = handLine(v, seat);
|
||||
if (hand) lines.push(hand);
|
||||
lines.push(`누를 수 있는 버튼: ${buttons.map((t) => `[${BET_KO[t]}]`).join(' ')}. 버튼 아래 적힌 만큼 칩이 바로 나가요.`);
|
||||
lines.push(`누를 수 있는 버튼: ${buttons.map((t) => `[${BET_KO[t]}]`).join(' ')}. 버튼 아래 적힌 금액이 바로 판돈에 들어가요. PC에서는 버튼 왼쪽 위 숫자 키(${buttons.map((t) => `${BET_KO[t]} ${BET_KEY[t]}`).join(', ')})로도 걸 수 있어요.`);
|
||||
const tips: string[] = [];
|
||||
if (v.forcedHalf) tips.push(`이 방은 베팅 규칙 ${v.options.betRule}이라 첫 베팅에서 앞쪽 사람은 [하프]나 [다이]만 할 수 있어요.`);
|
||||
const call = legal.get('call');
|
||||
if (call) tips.push(`앞사람이 칩을 걸었어요. [콜]은 그만큼(${chips(call.amount)}) 맞추는 거예요.`);
|
||||
else if (legal.has('ping')) tips.push(`[체크]는 칩을 걸지 않고 넘기고, [삥]은 학교(기본 칩)만큼 ${chips(v.baseUnit)}을 걸어요.`);
|
||||
if (call) tips.push(`앞사람이 걸었어요. [콜]은 그만큼(${won(call.amount)}) 맞추는 거예요.`);
|
||||
else if (legal.has('ping')) tips.push(`[체크]는 걸지 않고 넘기고, [삥]은 기본금만큼 ${won(v.baseUnit)}을 걸어요.`);
|
||||
if (!buttons.some((t) => RAISES.includes(t)) && seat.lastAction) tips.push('이번 라운드에 이미 한 번 해서 더 올릴 수는 없어요(올리기는 한 라운드에 한 번).');
|
||||
if (v.legal.some((l) => l.allIn)) tips.push('칩이 모자라면 가진 칩을 다 내는 올인이 돼요.');
|
||||
if (v.legal.some((l) => l.allIn)) tips.push('가진 금액이 모자라면 가진 만큼 다 내는 올인이 돼요.');
|
||||
tips.push('패가 약하면 [다이]로 이번 판을 포기할 수 있어요.');
|
||||
lines.push(tips.join(' '));
|
||||
return lines.join('\n');
|
||||
@@ -108,7 +111,7 @@ export function helpNow(v: SeotdaView, me: string | null, players: Record<string
|
||||
if (!v.rebuy?.mine) return watching(v, players) + ' 잠시 기다려 주세요.';
|
||||
const left = v.rebuy.left !== null ? `(남은 횟수 ${v.rebuy.left}번)` : '';
|
||||
return [
|
||||
`칩을 모두 잃었어요. [칩 다시 받기]를 누르면 놀이용 칩 ${chips(v.options.startingChips)}을 다시 받고 계속해요${left}.`,
|
||||
`가진 원을 모두 잃었어요. [다시 받기]를 누르면 놀이용 시작 금액 ${won(v.options.startingChips)}을 다시 받고 계속해요${left}.`,
|
||||
'[그만하기]를 누르면 탈락하고 구경만 해요. 다시 받은 만큼 최종 점수에서 빠져요.',
|
||||
'시간 안에 고르지 않으면 그만하는 것으로 처리돼요.',
|
||||
].join('\n');
|
||||
@@ -122,27 +125,27 @@ export function helpNow(v: SeotdaView, me: string | null, players: Record<string
|
||||
if (seat.folded) return `이번 판은 다이했어요. 다음 판을 기다려 주세요. 내 패는 나만 볼 수 있어요.\n${waitingLine(v, players)}`;
|
||||
if (v.toAct === me) return [re, myBetting(v, seat)].filter(Boolean).join('\n');
|
||||
const hand = handLine(v, seat);
|
||||
if (seat.allIn) return ['올인했어요(가진 칩을 다 걸었어요). 더 걸지 않고 결과를 기다리면 돼요.', hand, re].filter(Boolean).join('\n');
|
||||
if (seat.allIn) return ['올인했어요(가진 금액을 다 걸었어요). 더 걸지 않고 결과를 기다리면 돼요.', hand, re].filter(Boolean).join('\n');
|
||||
return [`${waitingLine(v, players)} 내 차례가 올 때까지 기다려 주세요.`, hand, re].filter(Boolean).join('\n');
|
||||
}
|
||||
case 'choose': {
|
||||
if (seat.chosen === null) return seat.folded ? '이번 판은 다이했어요. 다음 판을 기다려 주세요.' : [notIn, watching(v, players)].join('\n');
|
||||
if (seat.chosen) {
|
||||
const name = v.myHand ? `(${v.myHand.name})` : '';
|
||||
return `쓸 카드 2장을 골랐어요${name}. 다른 사람이 다 고를 때까지 기다려 주세요. 다 고르면 마지막 베팅을 해요.`;
|
||||
return `쓸 패 2장을 골랐어요${name}. 다른 사람이 다 고를 때까지 기다려 주세요. 다 고르면 마지막 베팅을 해요.`;
|
||||
}
|
||||
const lines = ["3장 중 쓸 카드 2장을 눌러 고르면 아래 버튼이 '○○(으)로 정하기'로 바뀌어요. 그 버튼을 눌러 정해 주세요. 남는 1장은 아무에게도 보이지 않아요."];
|
||||
const lines = ["3장 중 쓸 패 2장을 눌러 고르면 아래 버튼이 '○○(으)로 정하기'로 바뀌어요. 그 버튼을 눌러 정해 주세요. 남는 1장은 아무에게도 보이지 않아요."];
|
||||
const best = v.options.hints ? v.myCombos?.find((c) => c.best) : undefined;
|
||||
if (best) lines.push(`[추천 조합]을 누르면 가장 센 조합(${best.name})이 골라져요.`);
|
||||
if (best) lines.push(`조합 버튼을 누르면 그 2장이 골라져요. [${best.name} (추천)]이 가장 센 조합이에요.`);
|
||||
lines.push('모두 동시에 몰래 고르고, 시간이 지나면 가장 센 조합으로 저절로 골라져요.');
|
||||
return lines.join('\n');
|
||||
}
|
||||
case 'rejoin': {
|
||||
if (!v.rejoin?.mine) return `${waitingLine(v, players)} 잠시 기다려 주세요.`;
|
||||
const cost = chips(v.rejoin.cost);
|
||||
const cost = won(v.rejoin.cost);
|
||||
return [
|
||||
`구사 재경기가 열려요. 다이했던 나도 모인 칩에 ${cost}을 더 내면 다시 들어갈 수 있어요.`,
|
||||
v.rejoin.canAfford ? `[${cost} 내고 참가] 또는 [참가 안 함]을 눌러 주세요.` : '칩이 모자라서 참가할 수 없어요. [참가 안 함]을 눌러 주세요.',
|
||||
`구사 재경기가 열려요. 다이했던 나도 판돈에 ${cost}을 더 내면 다시 들어갈 수 있어요.`,
|
||||
v.rejoin.canAfford ? `[${cost} 내고 참가] 또는 [참가 안 함]을 눌러 주세요.` : '보유 금액이 모자라서 참가할 수 없어요. [참가 안 함]을 눌러 주세요.',
|
||||
'시간이 지나면 참가하지 않는 것으로 처리돼요.',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
@@ -1,57 +1,20 @@
|
||||
/** 섯다 화면 (docs/games/seotda.md §9). Chips are room-only play points. */
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import type {
|
||||
BetType,
|
||||
CardSlot,
|
||||
PotOutcome,
|
||||
SeotdaCardView,
|
||||
SeotdaOptions,
|
||||
SeotdaSeatView,
|
||||
SeotdaView,
|
||||
SpecialKind,
|
||||
} from '@bg/games/seotda';
|
||||
/**
|
||||
* 섯다 (docs/games/seotda.md §9): 한게임 섯다처럼 원과 판돈으로. 판 화면은 board.tsx, 여기는 옆 패널·설정·규칙.
|
||||
* 원은 이 방 안에서만 쓰는 놀이용 숫자다(§12): 진짜 돈과 바꿀 수 없고 방이 끝나면 사라진다.
|
||||
*/
|
||||
import { useState } from 'react';
|
||||
import type { SeotdaOptions, SeotdaView, SpecialKind } from '@bg/games/seotda';
|
||||
import { formatWon, formatWonDelta, formatWonShort } from '@bg/games/seotda/money';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { HwatuCard, type HwatuInfo } from '../../components/cards/HwatuCard';
|
||||
import { Chips, PlayChipNotice, formatChips } from '../../components/cards/Chips';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { HWATU_CREDIT, HwatuCard, type HwatuInfo } from '../../components/cards/HwatuCard';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { BET_KO, SeotdaBoard, nick, resultLine, totalMsOf, userOf } from './board';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
|
||||
const BET_ORDER: BetType[] = ['die', 'check', 'ping', 'call', 'ddadang', 'quarter', 'half', 'full'];
|
||||
const BET_KO: Record<BetType, string> = { check: '체크', ping: '삥', call: '콜', ddadang: '따당', quarter: '쿼터', half: '하프', full: '풀', die: '다이' };
|
||||
const BET_HELP: Record<BetType, string> = {
|
||||
check: '칩을 걸지 않고 넘겨요',
|
||||
ping: '기본 칩만큼 걸어요',
|
||||
call: '앞사람만큼 맞춰요',
|
||||
ddadang: '앞사람이 건 만큼의 두 배',
|
||||
quarter: '모인 칩의 4분의 1만큼 더',
|
||||
half: '모인 칩의 절반만큼 더',
|
||||
full: '모인 칩만큼 더',
|
||||
die: '이번 판을 포기해요',
|
||||
};
|
||||
const STRENGTH_COLOR = { high: 'var(--success)', mid: 'var(--warning)', low: 'var(--text-sub)' } as const;
|
||||
const STRENGTH_KO = { high: '센 패', mid: '중간 패', low: '약한 패' } as const;
|
||||
const REMATCH_KO = { gusa: '구사', mungGusa: '멍텅구리구사', tie: '동점' } as const;
|
||||
const REASON_KO: Record<PotOutcome['reason'], string> = {
|
||||
normal: '',
|
||||
ttaengjabi: '땡잡이',
|
||||
amhaeng: '암행어사',
|
||||
gusa: '구사 재경기',
|
||||
mungGusa: '멍텅구리구사 재경기',
|
||||
tie: '동점',
|
||||
limit: '재경기 횟수 초과로 나눔',
|
||||
fold: '모두 다이',
|
||||
};
|
||||
|
||||
const nick = (players: Record<string, PublicUser>, id: string) => players[id]?.nickname ?? '알 수 없음';
|
||||
const userOf = (players: Record<string, PublicUser>, id: string): PublicUser =>
|
||||
players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' };
|
||||
const isCard = (c: CardSlot): c is SeotdaCardView => !('hidden' in c);
|
||||
|
||||
/** Illustration card for the rules / 족보표 (no rule code needed on the client). */
|
||||
/** Illustration card for the 족보표 (no rule code needed on the client). */
|
||||
function illus(month: number, special: boolean): HwatuInfo {
|
||||
const gwang = [1, 3, 8].includes(month);
|
||||
const kind: HwatuInfo['kind'] = special ? (gwang ? 'gwang' : 'yeol') : month === 8 ? 'pi' : 'tti';
|
||||
@@ -64,388 +27,17 @@ function illus(month: number, special: boolean): HwatuInfo {
|
||||
};
|
||||
}
|
||||
|
||||
function totalMsOf(v: SeotdaView): number {
|
||||
const o = v.options;
|
||||
if (v.phase === 'rebuy' || v.handPhase === 'rejoin') return o.decisionSeconds * 1000;
|
||||
if (v.handPhase === 'choose') return (o.turnSeconds + 10) * 1000;
|
||||
if (v.handPhase === 'handEnd') return 4000;
|
||||
const turn = v.seats.find((s) => s.id === v.toAct);
|
||||
return turn?.away ? 5000 : o.turnSeconds * 1000;
|
||||
}
|
||||
const PLAY_MONEY_NOTICE = '여기 나오는 원과 판돈은 이 방 안에서만 쓰는 놀이용 숫자예요. 진짜 돈과는 아무 상관이 없고, 바꾸거나 주고받을 수 없으며 방이 끝나면 사라져요.';
|
||||
|
||||
function specialFlash(v: SeotdaView): string | null {
|
||||
const pots = v.showdown?.pots ?? [];
|
||||
if (pots.some((p) => p.reason === 'ttaengjabi')) return '땡잡이!';
|
||||
if (pots.some((p) => p.reason === 'amhaeng')) return '암행어사 출두!';
|
||||
if (pots.some((p) => p.type === 'rematch' && p.reason === 'gusa')) return '구사 재경기';
|
||||
if (pots.some((p) => p.type === 'rematch' && p.reason === 'mungGusa')) return '멍텅구리구사 재경기';
|
||||
if (pots.some((p) => p.type === 'rematch')) return '동점 재경기';
|
||||
return null;
|
||||
}
|
||||
|
||||
const CSS = `
|
||||
.sd-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); }
|
||||
.sd-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: var(--seat-w, 168px); 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; }
|
||||
.sd-seat.turn { border-color: var(--focus); }
|
||||
.sd-seat.me { border-color: var(--primary); }
|
||||
.sd-seat.me.turn { border-color: var(--focus); }
|
||||
.sd-seat.out { opacity: 0.6; }
|
||||
.sd-center { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); text-align: center; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); max-width: 46%; }
|
||||
.sd-flash { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%); z-index: 3; font-size: 2.6rem; font-weight: 900; color: #fde047;
|
||||
text-shadow: 0 3px 8px rgba(0,0,0,.6); animation: sd-pop .35s ease-out; pointer-events: none; white-space: nowrap; }
|
||||
@keyframes sd-pop { from { transform: translate(-50%, -50%) scale(.5); opacity: 0 } to { transform: translate(-50%, -50%) scale(1); opacity: 1 } }
|
||||
.sd-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
|
||||
.sd-actions .btn { min-height: 64px; flex-direction: column; gap: 0; padding: 0 8px; line-height: 1.15; }
|
||||
.sd-actions .btn small { font-weight: 600; font-size: .85rem; opacity: .9; }
|
||||
.sd-mine { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; justify-content: center; }
|
||||
.sd-badge { display: inline-block; border-radius: 999px; padding: 0 8px; font-weight: 800; font-size: .78rem; }
|
||||
@media (max-width: 719px) {
|
||||
.sd-table { aspect-ratio: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; border-radius: 20px; border-width: 6px; }
|
||||
.sd-seat { position: static; transform: none; width: auto; }
|
||||
.sd-center { position: static; transform: none; grid-column: 1 / -1; order: -1; max-width: none; padding: 8px 0; }
|
||||
.sd-flash { position: fixed; top: 40%; }
|
||||
.sd-actions { grid-template-columns: repeat(2, 1fr); }
|
||||
}
|
||||
`;
|
||||
|
||||
// ---------------------------------------------------------------- board
|
||||
|
||||
function SeatBox({ seat, view: v, players, me, deadline, x, y }: { seat: SeotdaSeatView; view: SeotdaView; players: Record<string, PublicUser>; me: string | null; deadline: number | null; x: number; y: number }) {
|
||||
const u = userOf(players, seat.id);
|
||||
const out = seat.status === 'eliminated' || seat.folded || (!seat.inHand && v.handPhase !== null);
|
||||
const badges: [string, string][] = [];
|
||||
if (seat.left) badges.push(['나감', 'var(--danger)']);
|
||||
else if (seat.away) badges.push(['자리 비움', 'var(--warning)']);
|
||||
if (seat.status === 'eliminated') badges.push(['탈락', 'var(--text-sub)']);
|
||||
if (seat.status === 'busted') badges.push(['리바이 대기', 'var(--warning)']);
|
||||
if (seat.folded) badges.push(['다이', 'var(--danger)']);
|
||||
if (seat.allIn) badges.push(['올인', 'var(--primary)']);
|
||||
if (seat.chosen === true) badges.push(['고름', 'var(--success)']);
|
||||
if (seat.chosen === false) badges.push(['고르는 중', 'var(--text-sub)']);
|
||||
const timed = seat.isTurn || seat.chosen === false;
|
||||
return (
|
||||
<div
|
||||
className={`sd-seat${seat.isTurn ? ' turn' : ''}${seat.id === me ? ' me' : ''}${out ? ' out' : ''}`}
|
||||
style={{ '--x': `${x}%`, '--y': `${y}%` } as React.CSSProperties}
|
||||
aria-label={`${u.nickname} ${formatChips(seat.stack)}${seat.isDealer ? ', 선' : ''}${badges.length ? `, ${badges.map((b) => b[0]).join(', ')}` : ''}`}
|
||||
>
|
||||
<div className="row" style={{ gap: 5, flexWrap: 'nowrap' }}>
|
||||
<Avatar user={u} size={22} />
|
||||
<strong style={{ flex: 1, minWidth: 0, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
|
||||
{u.nickname}
|
||||
{seat.id === me && <span className="muted"> (나)</span>}
|
||||
</strong>
|
||||
{seat.isDealer && (
|
||||
<span className="sd-badge" style={{ background: '#facc15', color: '#422006' }} title="선(먼저 하는 사람)">
|
||||
선
|
||||
</span>
|
||||
)}
|
||||
{timed && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine={seat.id === me} size={28} />}
|
||||
</div>
|
||||
<div className="row" style={{ gap: 6, flexWrap: 'nowrap', alignItems: 'flex-start' }}>
|
||||
<div className="stack" style={{ gap: 2, flex: 1, minWidth: 0 }}>
|
||||
<Chips n={seat.stack} strong />
|
||||
{((seat.lastAction && !seat.folded) || seat.roundBet > 0) && (
|
||||
<span className="small" style={{ whiteSpace: 'nowrap' }} title="마지막 행동 · 이번 라운드에 건 칩">
|
||||
{seat.lastAction && !seat.folded && <span className="muted">{BET_KO[seat.lastAction.type]} </span>}
|
||||
{seat.roundBet > 0 && `+${seat.roundBet.toLocaleString('ko-KR')}`}
|
||||
</span>
|
||||
)}
|
||||
<div className="row" style={{ gap: 3 }}>
|
||||
{badges.map(([t, c]) => (
|
||||
<span key={t} className="sd-badge" style={{ background: c, color: '#fff' }}>
|
||||
{t}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{seat.cards.length > 0 && (
|
||||
<div style={{ display: 'flex', flex: 'none' }}>
|
||||
{seat.cards.map((c, i) => (
|
||||
<HwatuCard key={isCard(c) ? c.key : `h${i}`} card={isCard(c) ? c : null} size="sm" style={i > 0 ? { marginLeft: -14 } : undefined} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{seat.handName && <strong style={{ color: 'var(--primary)', textAlign: 'center' }}>{seat.handName}</strong>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function CenterInfo({ view: v, players }: { view: SeotdaView; players: Record<string, PublicUser> }) {
|
||||
const limit = v.options.endCondition === 'hands' ? `/${v.options.handLimit}` : '';
|
||||
// On the result screen the paid-out pots are no longer in v.pot (only a carried rematch pot is).
|
||||
const paid = v.handPhase === 'handEnd' ? (v.foldWin?.amount ?? (v.showdown?.pots ?? []).filter((p) => p.type !== 'rematch').reduce((a, p) => a + p.amount, 0)) : 0;
|
||||
return (
|
||||
<div className="sd-center">
|
||||
{v.rematchNo > 0 && v.rematchReason && (
|
||||
<div className="sd-badge" style={{ background: '#fde047', color: '#422006', fontSize: '1rem', padding: '2px 12px', marginBottom: 6 }}>
|
||||
재경기 {v.rematchNo}회차 · {REMATCH_KO[v.rematchReason]}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ fontSize: '0.95rem', opacity: 0.9 }}>모인 칩</div>
|
||||
<div style={{ fontSize: '2.2rem', fontWeight: 900, fontVariantNumeric: 'tabular-nums' }} aria-live="polite">
|
||||
{formatChips(v.pot + paid)}
|
||||
</div>
|
||||
{v.pots.length > 1 && (
|
||||
<div className="small" style={{ opacity: 0.9 }}>
|
||||
{v.pots.map((p, i) => (
|
||||
<div key={i}>
|
||||
{i === v.pots.length - 1 ? '메인' : `사이드 ${i + 1}`}: {formatChips(p.amount)} ({p.eligible.map((id) => nick(players, id)).join('·')})
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="small" style={{ opacity: 0.85, marginTop: 4 }}>
|
||||
{v.phase === 'finished' ? '게임 끝' : `${Math.max(1, v.handNo)}${limit}판`} · 학교 {formatChips(v.baseUnit)}
|
||||
{v.currentBet > 0 && v.handPhase === 'betting' ? ` · 이번 라운드 ${formatChips(v.currentBet)}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SeotdaBoard({ view: v, me, players, act, pending, deadline }: BoardProps<SeotdaView>) {
|
||||
const n = v.seats.length;
|
||||
const myIdx = Math.max(0, v.seats.findIndex((s) => s.id === me));
|
||||
const [flash, setFlash] = useState<string | null>(null);
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const prevToAct = useRef(v.toAct);
|
||||
const showKey = `${v.handNo}-${v.rematchNo}-${v.handPhase}`;
|
||||
|
||||
useEffect(() => {
|
||||
const f = v.handPhase === 'handEnd' ? specialFlash(v) : null;
|
||||
if (f) {
|
||||
setFlash(f);
|
||||
const t = setTimeout(() => setFlash(null), 1400);
|
||||
return () => clearTimeout(t);
|
||||
}
|
||||
return undefined;
|
||||
}, [showKey]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
if (v.toAct && v.toAct !== prevToAct.current) {
|
||||
if (v.toAct === me) {
|
||||
haptic(40);
|
||||
sounds.myTurn();
|
||||
setAnnounce('내 차례예요.');
|
||||
} else setAnnounce(`${nick(players, v.toAct)}님 차례예요.`);
|
||||
}
|
||||
prevToAct.current = v.toAct;
|
||||
}, [v.toAct]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
if (v.handPhase !== 'handEnd') return;
|
||||
if (v.foldWin) setAnnounce(`${nick(players, v.foldWin.winner)}님이 ${formatChips(v.foldWin.amount)}을 가져갔어요.`);
|
||||
else if (v.showdown) setAnnounce(resultLine(v, players));
|
||||
const won = v.foldWin?.winner === me || v.showdown?.pots.some((p) => p.type !== 'rematch' && p.winners.includes(me ?? ''));
|
||||
if (me && won) sounds.win();
|
||||
}, [showKey]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return (
|
||||
<div className="board-wrap stack" style={{ gap: 12 }}>
|
||||
<style>{CSS}</style>
|
||||
<div className="sd-table" role="region" aria-label="섯다 테이블" style={{ '--seat-w': v.options.cardMode === 'three' ? '196px' : n > 6 ? '150px' : '172px' } 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} view={v} players={players} me={me} deadline={deadline} x={50 + 40 * Math.cos(ang)} y={50 + 38 * Math.sin(ang)} />;
|
||||
})}
|
||||
<CenterInfo view={v} players={players} />
|
||||
{flash && <div className="sd-flash">{flash}</div>}
|
||||
</div>
|
||||
<MyArea view={v} me={me} players={players} act={act} pending={pending} />
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function resultLine(v: SeotdaView, players: Record<string, PublicUser>): string {
|
||||
if (v.foldWin) return `${nick(players, v.foldWin.winner)}님이 ${formatChips(v.foldWin.amount)}을 가져갔어요(모두 다이).`;
|
||||
if (!v.showdown) return '';
|
||||
return v.showdown.pots
|
||||
.map((p) => {
|
||||
const who = p.winners.map((id) => nick(players, id)).join('·');
|
||||
const name = v.showdown!.hands.find((h) => h.id === p.winners[0])?.name ?? '';
|
||||
if (p.type === 'rematch') return `${REASON_KO[p.reason]}: ${who}님이 다시 겨뤄요(${formatChips(p.amount)})`;
|
||||
if (p.type === 'split') return `${who}님이 ${formatChips(p.amount)}을 나눠 가졌어요${p.reason === 'limit' ? '(재경기 횟수 초과)' : ''}`;
|
||||
return `${who}님이 ${name}${p.reason === 'normal' ? '' : ' 발동'}(으)로 ${formatChips(p.amount)}을 가져갔어요`;
|
||||
})
|
||||
.join(' / ');
|
||||
}
|
||||
|
||||
/** My cards, hand name, 3장 choice and the action buttons. */
|
||||
function MyArea({ view: v, me, players, act, pending }: { view: SeotdaView; me: string | null; players: Record<string, PublicUser>; act: (a: unknown) => void; pending: boolean }) {
|
||||
const seat = v.seats.find((s) => s.id === me);
|
||||
const [pick, setPick] = useState<number[]>([]);
|
||||
const [hover, setHover] = useState<BetType | null>(null);
|
||||
useEffect(() => setPick([]), [v.handNo, v.rematchNo, v.handPhase]);
|
||||
if (!me || !seat) return v.handPhase === 'handEnd' ? <ResultPanel view={v} players={players} /> : null;
|
||||
const myCards = seat.cards.filter(isCard);
|
||||
const choosing = v.handPhase === 'choose' && seat.chosen === false;
|
||||
const preview = choosing && pick.length === 2 ? v.myCombos?.find((c) => c.cardIds.includes(pick[0]!) && c.cardIds.includes(pick[1]!)) : null;
|
||||
const myTurn = v.toAct === me && v.handPhase === 'betting';
|
||||
const legal = new Map(v.legal.map((l) => [l.type, l]));
|
||||
const hoverBet = hover ? legal.get(hover) : undefined;
|
||||
const toggle = (id: number) => setPick((p) => (p.includes(id) ? p.filter((x) => x !== id) : p.length >= 2 ? [p[1]!, id] : [...p, id]));
|
||||
const showHand = myCards.length > 0 && seat.inHand;
|
||||
return (
|
||||
<div className="stack" style={{ gap: 10 }}>
|
||||
{showHand && (
|
||||
<div className="card stack" style={{ gap: 10, padding: 12 }}>
|
||||
<div className="sd-mine">
|
||||
{myCards.map((c) => {
|
||||
const chosen = v.myChosen?.includes(c.id);
|
||||
return (
|
||||
<HwatuCard
|
||||
key={c.key}
|
||||
card={c}
|
||||
size="lg"
|
||||
selected={choosing && pick.includes(c.id)}
|
||||
highlight={!!chosen}
|
||||
dimmed={!!v.myChosen && !chosen}
|
||||
onClick={choosing ? () => toggle(c.id) : undefined}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{v.myHand && (
|
||||
<div className="stack" style={{ gap: 2, minWidth: 160, maxWidth: 320 }}>
|
||||
<span style={{ fontSize: '1.5rem', fontWeight: 900, color: v.myHand.strength ? STRENGTH_COLOR[v.myHand.strength] : undefined }}>
|
||||
지금: {v.myHand.name}
|
||||
{v.myHand.strength && <span className="small" style={{ marginLeft: 6 }}>({STRENGTH_KO[v.myHand.strength]})</span>}
|
||||
</span>
|
||||
<span className="small muted">{v.myHand.hint}</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{seat.folded && <p className="small muted" style={{ margin: 0, textAlign: 'center' }}>이번 판은 다이했어요. 내 패는 나만 볼 수 있어요.</p>}
|
||||
{choosing && (
|
||||
<div className="stack" style={{ gap: 8 }}>
|
||||
<p style={{ margin: 0, textAlign: 'center' }}>
|
||||
<strong>쓸 카드 2장을 골라 주세요.</strong> 남는 1장은 아무에게도 보이지 않아요.
|
||||
{preview && (
|
||||
<>
|
||||
{' '}
|
||||
고른 조합: <strong>{preview.name}</strong>
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
<div className="row" style={{ justifyContent: 'center' }}>
|
||||
{v.options.hints && v.myCombos && (
|
||||
<button type="button" className="btn btn-secondary" onClick={() => setPick([...v.myCombos!.find((c) => c.best)!.cardIds])}>
|
||||
추천 조합
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
disabled={pick.length !== 2 || pending}
|
||||
onClick={() => act({ type: 'choose', cardIds: [pick[0], pick[1]] })}
|
||||
>
|
||||
{preview ? `${preview.name}(으)로 정하기` : '두 장을 고르세요'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{v.handPhase === 'choose' && seat.chosen === true && <p className="small muted" style={{ margin: 0, textAlign: 'center' }}>골랐어요. 다른 사람을 기다리는 중이에요.</p>}
|
||||
</div>
|
||||
)}
|
||||
{seat.inHand && v.handPhase === 'betting' && !seat.folded && (
|
||||
<div className="stack" style={{ gap: 6 }}>
|
||||
<div className="sd-actions" role="group" aria-label="베팅">
|
||||
{BET_ORDER.filter((t) => t !== 'full' || v.options.maxRaise === 'full').map((t) => {
|
||||
const l = legal.get(t);
|
||||
const enabled = myTurn && !!l && !pending;
|
||||
const cls = t === 'die' ? 'btn-danger' : t === 'check' || t === 'call' ? 'btn-primary' : 'btn-soft';
|
||||
return (
|
||||
<button
|
||||
key={t}
|
||||
type="button"
|
||||
className={`btn ${cls}`}
|
||||
disabled={!enabled}
|
||||
title={BET_HELP[t]}
|
||||
onMouseEnter={() => setHover(t)}
|
||||
onMouseLeave={() => setHover(null)}
|
||||
onFocus={() => setHover(t)}
|
||||
onBlur={() => setHover(null)}
|
||||
onClick={() => act({ type: t })}
|
||||
>
|
||||
<span>{BET_KO[t]}</span>
|
||||
<small>{l && l.amount > 0 ? `${formatChips(l.amount)}${l.allIn ? ' 올인' : ''}` : t === 'die' ? '포기' : l ? '0 칩' : '-'}</small>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<p className="small muted" style={{ margin: 0, minHeight: '1.4em', textAlign: 'center' }}>
|
||||
{myTurn
|
||||
? hoverBet
|
||||
? `${BET_KO[hover!]}: ${BET_HELP[hover!]}. 내고 나면 내 칩 ${formatChips(seat.stack - hoverBet.amount)}, 모인 칩 ${formatChips(v.pot + hoverBet.amount)}`
|
||||
: '내 차례예요. 버튼에 적힌 칩이 바로 나가요.'
|
||||
: v.toAct
|
||||
? `${nick(players, v.toAct)}님 차례예요.`
|
||||
: ''}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{v.handPhase === 'handEnd' && <ResultPanel view={v} players={players} />}
|
||||
{v.handPhase === 'handEnd' && seat.status === 'playing' && !seat.left && (
|
||||
<button type="button" className="btn btn-primary btn-block" disabled={seat.ready || pending} onClick={() => act({ type: 'ready' })}>
|
||||
{seat.ready ? '다른 사람을 기다리는 중…' : v.next === 'rematch' ? '재경기 시작' : '다음 판으로'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ResultPanel({ view: v, players }: { view: SeotdaView; players: Record<string, PublicUser> }) {
|
||||
return (
|
||||
<div className="card stack" style={{ gap: 6, padding: 12 }} aria-live="polite">
|
||||
<strong>{v.next === 'rematch' ? '재경기가 결정됐어요' : '이번 판 결과'}</strong>
|
||||
{v.foldWin && (
|
||||
<span>
|
||||
{nick(players, v.foldWin.winner)}님이 {formatChips(v.foldWin.amount)}을 가져갔어요. 모두 다이해서 패는 공개하지 않아요.
|
||||
</span>
|
||||
)}
|
||||
{v.showdown?.pots.map((p, i) => {
|
||||
const who = p.winners.map((id) => nick(players, id)).join(' · ');
|
||||
const name = v.showdown!.hands.find((h) => h.id === p.winners[0])?.name;
|
||||
return (
|
||||
<span key={i}>
|
||||
{v.showdown!.pots.length > 1 ? `${i === v.showdown!.pots.length - 1 ? '메인' : '사이드'} ${formatChips(p.amount)}: ` : `${formatChips(p.amount)}: `}
|
||||
{p.type === 'win' && (
|
||||
<>
|
||||
<strong>{who}</strong> 승리 ({name}
|
||||
{p.reason === 'ttaengjabi' || p.reason === 'amhaeng' ? ' 발동' : ''})
|
||||
</>
|
||||
)}
|
||||
{p.type === 'split' && (
|
||||
<>
|
||||
<strong>{who}</strong> 나눠 가짐{p.reason === 'limit' ? ' (재경기 횟수 초과)' : ' (같은 족보)'}
|
||||
</>
|
||||
)}
|
||||
{p.type === 'rematch' && (
|
||||
<>
|
||||
<strong>{REASON_KO[p.reason]}</strong> — {who}님이 다시 겨뤄요. 칩은 그대로 남아요.
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- side
|
||||
// ---------------------------------------------------------------- 족보 도우미
|
||||
|
||||
interface JokboRow {
|
||||
name: string;
|
||||
cards: [number, boolean][];
|
||||
note: string;
|
||||
match: (value: number | null, special: SpecialKind | null) => boolean;
|
||||
/** 특수 족보 (numbered "특" like the 한게임 족보 list). */
|
||||
special?: boolean;
|
||||
}
|
||||
|
||||
function jokboRows(o: SeotdaOptions): JokboRow[] {
|
||||
@@ -458,7 +50,7 @@ function jokboRows(o: SeotdaOptions): JokboRow[] {
|
||||
{ name: '13광땡', cards: [[1, true], [3, true]], note: '', match: v(980) } as JokboRow,
|
||||
]
|
||||
: []),
|
||||
{ name: '장땡(10땡)', cards: [[10, true], [10, false]], note: '같은 월 두 장 중 최고', match: v(910) },
|
||||
{ name: '장땡(10땡)', cards: [[10, true], [10, false]], note: '같은 달 두 장 중 최고', match: v(910) },
|
||||
{ name: '9땡 ~ 삥땡(1땡)', cards: [[9, true], [9, false]], note: '숫자가 클수록 셈', match: v(901, 909) },
|
||||
{ name: '알리', cards: [[1, true], [2, false]], note: '1 + 2', match: v(806) },
|
||||
{ name: '독사', cards: [[1, true], [4, false]], note: '1 + 4', match: v(805) },
|
||||
@@ -466,7 +58,7 @@ function jokboRows(o: SeotdaOptions): JokboRow[] {
|
||||
{ name: '장삥', cards: [[1, true], [10, false]], note: '1 + 10', match: v(803) },
|
||||
{ name: '장사', cards: [[4, false], [10, false]], note: '4 + 10', match: v(802) },
|
||||
{ name: '세륙', cards: [[4, false], [6, false]], note: '4 + 6', match: v(801) },
|
||||
{ name: '갑오(9끗)', cards: [[2, false], [7, false]], note: '두 월을 더한 일의 자리 9', match: v(9) },
|
||||
{ name: '갑오(9끗)', cards: [[2, false], [7, false]], note: '두 달을 더한 일의 자리 9', match: v(9) },
|
||||
{ name: '8끗 ~ 1끗', cards: [[3, false], [5, false]], note: '일의 자리가 클수록 셈', match: v(1, 8) },
|
||||
{ name: '망통(0끗)', cards: [[2, false], [8, false]], note: '가장 약한 패', match: v(0) },
|
||||
];
|
||||
@@ -474,16 +66,17 @@ function jokboRows(o: SeotdaOptions): JokboRow[] {
|
||||
if (o.ttaengjabi !== 'off')
|
||||
rows.push({
|
||||
name: '땡잡이',
|
||||
special: true,
|
||||
cards: [[3, true], [7, true]],
|
||||
note: `${o.ttaengjabi === 'strict' ? '3월 광 + 7월 열끗' : '3월 + 7월 아무 패'}. 상대 최고가 1~9땡이면 이김, 아니면 망통`,
|
||||
note: `${o.ttaengjabi === 'strict' ? '3월 광 + 7월 열끗' : '3월 + 7월'}. 상대 최고가 1~9땡이면 이김, 아니면 망통`,
|
||||
match: sp('ttaengjabi'),
|
||||
});
|
||||
if (o.amhaeng) rows.push({ name: '암행어사', cards: [[4, true], [7, true]], note: '4·7월 열끗. 13·18광땡을 잡음, 아니면 1끗', match: sp('amhaeng') });
|
||||
if (o.amhaeng) rows.push({ name: '암행어사', special: true, cards: [[4, true], [7, true]], note: '4·7월 열끗. 13·18광땡을 잡음, 아니면 1끗', match: sp('amhaeng') });
|
||||
if (o.gusa) {
|
||||
rows.push({ name: '구사', cards: [[4, false], [9, true]], note: '4 + 9. 상대가 알리 이하면 재경기, 아니면 3끗', match: sp('gusa') });
|
||||
rows.push({ name: '구사', special: true, cards: [[4, false], [9, true]], note: '4 + 9. 상대가 알리 이하면 재경기, 아니면 3끗', match: sp('gusa') });
|
||||
if (o.mungGusa !== 'off') {
|
||||
const upTo = o.mungGusa === 'upTo9' ? '9땡' : o.mungGusa === 'upToJang' ? '장땡' : '8땡';
|
||||
rows.push({ name: '멍텅구리구사', cards: [[4, true], [9, true]], note: `4·9월 열끗. 상대가 ${upTo} 이하면 재경기`, match: sp('mungGusa') });
|
||||
rows.push({ name: '멍텅구리구사', special: true, cards: [[4, true], [9, true]], note: `4·9월 열끗. 상대가 ${upTo} 이하면 재경기`, match: sp('mungGusa') });
|
||||
}
|
||||
}
|
||||
return rows;
|
||||
@@ -492,20 +85,29 @@ function jokboRows(o: SeotdaOptions): JokboRow[] {
|
||||
function JokboTable({ options, mine }: { options: SeotdaOptions; mine?: SeotdaView['myHand'] }) {
|
||||
const rows = jokboRows(options);
|
||||
return (
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: '0.9rem' }}>
|
||||
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: '0.88rem' }}>
|
||||
<tbody>
|
||||
{rows.map((r) => {
|
||||
{rows.map((r, i) => {
|
||||
const hit = !!mine && options.hints && r.match(mine.value, mine.special);
|
||||
return (
|
||||
<tr key={r.name} style={{ background: hit ? 'var(--warning-soft)' : undefined, borderBottom: '1px solid var(--border)' }} aria-current={hit ? 'true' : undefined}>
|
||||
<td style={{ padding: '4px 2px', whiteSpace: 'nowrap' }}>
|
||||
{r.cards.map(([m, sp], i) => (
|
||||
<HwatuCard key={i} card={illus(m, sp)} size="sm" style={{ marginRight: 2 }} />
|
||||
<tr
|
||||
key={r.name}
|
||||
style={{ background: hit ? 'color-mix(in srgb, #7c3aed 22%, transparent)' : undefined, borderBottom: '1px solid var(--border)' }}
|
||||
aria-current={hit ? 'true' : undefined}
|
||||
>
|
||||
<td style={{ padding: '3px 4px', fontWeight: 800, color: 'var(--text-sub)', width: 28, textAlign: 'right', whiteSpace: 'nowrap' }}>{r.special ? '특' : i + 1}</td>
|
||||
<td style={{ padding: '3px 2px', whiteSpace: 'nowrap' }}>
|
||||
{r.cards.map(([m, sp], j) => (
|
||||
<HwatuCard key={j} card={illus(m, sp)} width={30} showMonth={false} style={{ marginRight: 2 }} />
|
||||
))}
|
||||
</td>
|
||||
<td style={{ padding: '4px 6px' }}>
|
||||
<td style={{ padding: '3px 6px' }}>
|
||||
<strong>{r.name}</strong>
|
||||
{hit && <span className="sd-badge" style={{ background: 'var(--warning)', color: '#fff', marginLeft: 4 }}>내 패</span>}
|
||||
{hit && (
|
||||
<span className="sd-tag" style={{ background: '#7c3aed', color: '#fff', marginLeft: 4, borderRadius: 999, padding: '0 7px', fontSize: '.74rem', fontWeight: 800 }}>
|
||||
내 패
|
||||
</span>
|
||||
)}
|
||||
{r.note && <div className="small muted">{r.note}</div>}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -516,13 +118,17 @@ function JokboTable({ options, mine }: { options: SeotdaOptions; mine?: SeotdaVi
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- side panel
|
||||
|
||||
function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps<SeotdaView>) {
|
||||
const [confirmQuit, setConfirmQuit] = useState(false);
|
||||
const ranked = [...v.seats].sort((a, b) => b.stack - a.stack);
|
||||
const log = v.betLog;
|
||||
return (
|
||||
<>
|
||||
<style>{CSS}</style>
|
||||
<PlayChipNotice />
|
||||
<p className="small" style={{ background: 'var(--surface-2)', borderRadius: 10, padding: '8px 12px', margin: 0 }}>
|
||||
{PLAY_MONEY_NOTICE}
|
||||
</p>
|
||||
<div className="card stack" style={{ gap: 6, padding: 12 }}>
|
||||
<div className="row" style={{ justifyContent: 'space-between' }}>
|
||||
<strong>
|
||||
@@ -532,9 +138,10 @@ function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
{v.phase !== 'finished' && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine={isMyTurn(v, me)} size={36} />}
|
||||
</div>
|
||||
<span className="small muted">
|
||||
학교 {formatChips(v.baseUnit)} · {v.options.cardMode === 'three' ? '3장 섯다' : '2장 섯다'} · {v.options.maxRaise === 'full' ? '풀까지' : '하프까지'}
|
||||
기본금 {formatWon(v.baseUnit)} · {v.options.cardMode === 'three' ? '3장 섯다' : '2장 섯다'} · {v.options.deck}장 ·{' '}
|
||||
{v.options.betRule === 'free' ? '일반 베팅' : `베팅 규칙 ${v.options.betRule}`}
|
||||
</span>
|
||||
<ol style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 4 }}>
|
||||
<ol style={{ listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: 4 }} aria-label="보유 금액 순위">
|
||||
{ranked.map((s) => (
|
||||
<li key={s.id} className="row" style={{ gap: 6, flexWrap: 'nowrap', opacity: s.status === 'eliminated' ? 0.55 : 1 }}>
|
||||
<Avatar user={userOf(players, s.id)} size={24} />
|
||||
@@ -544,7 +151,7 @@ function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
{s.rebuys > 0 ? ` · 리바이 ${s.rebuys}` : ''}
|
||||
{s.status === 'eliminated' ? ' · 탈락' : s.left ? ' · 나감' : s.away ? ' · 자리 비움' : ''}
|
||||
</span>
|
||||
<Chips n={s.stack} />
|
||||
<span style={{ fontVariantNumeric: 'tabular-nums', fontWeight: 800, whiteSpace: 'nowrap' }}>{formatWon(s.stack)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
@@ -555,16 +162,27 @@ function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
{v.result.ranking.map((g, i) => (
|
||||
<span key={i}>
|
||||
{v.result!.ranking.slice(0, i).reduce((a, x) => a + x.length, 1)}위 {g.map((id) => nick(players, id)).join(', ')}
|
||||
{v.options.endCondition === 'hands' || v.handsPlayed >= 300
|
||||
? ` (${(v.result!.scores[g[0]!] ?? 0) >= 0 ? '+' : ''}${(v.result!.scores[g[0]!] ?? 0).toLocaleString('ko-KR')} 칩)`
|
||||
: ''}
|
||||
{v.options.endCondition === 'hands' || v.handsPlayed >= 300 ? ` (${formatWonDelta(v.result!.scores[g[0]!] ?? 0)})` : ''}
|
||||
</span>
|
||||
))}
|
||||
<span className="small muted">점수 = 마지막 칩 − 시작 칩 × 리바이 횟수</span>
|
||||
<span className="small muted">점수 = 마지막 보유 금액 − 시작 금액 × 다시 받은 횟수</span>
|
||||
</div>
|
||||
)}
|
||||
{log.length > 0 && v.handPhase && v.handPhase !== 'handEnd' && (
|
||||
<details className="card" open style={{ padding: 12 }}>
|
||||
<summary style={{ cursor: 'pointer', fontWeight: 700 }}>이번 판 베팅</summary>
|
||||
<ol style={{ listStyle: 'none', margin: '6px 0 0', padding: 0, display: 'grid', gap: 2, maxHeight: 160, overflow: 'auto' }}>
|
||||
{log.map((e, i) => (
|
||||
<li key={i} className="small">
|
||||
{nick(players, e.p)} <strong>{BET_KO[e.t]}</strong>
|
||||
{e.amount > 0 ? ` ${formatWonShort(e.amount)}원` : ''}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</details>
|
||||
)}
|
||||
<details className="card wide-open" open style={{ padding: 12 }}>
|
||||
<summary style={{ cursor: 'pointer', fontWeight: 700 }}>족보표</summary>
|
||||
<summary style={{ cursor: 'pointer', fontWeight: 700 }}>족보 도우미</summary>
|
||||
<JokboTable options={v.options} mine={v.myHand} />
|
||||
</details>
|
||||
{v.history.length > 0 && (
|
||||
@@ -577,8 +195,8 @@ function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
{r.handNo}판{r.rematchNo ? `(재${r.rematchNo})` : ''}
|
||||
</span>{' '}
|
||||
{r.how === 'rematch'
|
||||
? `재경기로 넘어감 ${formatChips(r.amount)}`
|
||||
: `${r.winners.map((id) => nick(players, id)).join('·')} ${formatChips(r.amount)}${r.name ? ` · ${r.name}` : ''}${r.how !== 'normal' ? ` · ${REASON_KO[r.how]}` : ''}`}
|
||||
? `재경기로 넘어감 ${formatWon(r.amount)}`
|
||||
: `${r.winners.map((id) => nick(players, id)).join('·')} ${formatWon(r.amount)}${r.name ? ` · ${r.name}` : ''}${r.how === 'fold' ? ' · 모두 다이' : r.how === 'ttaengjabi' ? ' · 땡잡이' : r.how === 'amhaeng' ? ' · 암행어사' : r.how === 'limit' ? ' · 나눔' : r.how === 'tie' ? ' · 같은 족보 나눔' : ''}`}
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
@@ -587,12 +205,10 @@ function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
{v.rejoin?.mine && (
|
||||
<Sheet onClose={() => {}} label="재경기 참가">
|
||||
<h2>구사 재경기에 다시 들어갈까요?</h2>
|
||||
<p className="muted">
|
||||
{formatChips(v.rejoin.cost)}을 모인 칩에 더 내면 재경기에 참가할 수 있어요. 시간이 지나면 참가하지 않아요.
|
||||
</p>
|
||||
<p className="muted">판돈에 {formatWon(v.rejoin.cost)}을 더 내면 재경기에 참가할 수 있어요. 시간이 지나면 참가하지 않아요.</p>
|
||||
<div className="row">
|
||||
<button className="btn btn-primary" style={{ flex: 1 }} disabled={pending || !v.rejoin.canAfford} onClick={() => act({ type: 'rejoin', accept: true })}>
|
||||
{v.rejoin.canAfford ? `${formatChips(v.rejoin.cost)} 내고 참가` : '칩이 모자라요'}
|
||||
{v.rejoin.canAfford ? `${formatWon(v.rejoin.cost)} 내고 참가` : '보유 금액이 모자라요'}
|
||||
</button>
|
||||
<button className="btn btn-secondary" style={{ flex: 1 }} disabled={pending} onClick={() => act({ type: 'rejoin', accept: false })}>
|
||||
참가 안 함
|
||||
@@ -601,14 +217,14 @@ function SeotdaSide({ view: v, me, players, act, pending, deadline }: BoardProps
|
||||
</Sheet>
|
||||
)}
|
||||
{v.rebuy?.mine && !confirmQuit && (
|
||||
<Sheet onClose={() => {}} label="칩 다시 받기">
|
||||
<h2>칩을 모두 잃었어요</h2>
|
||||
<Sheet onClose={() => {}} label="시작 금액 다시 받기">
|
||||
<h2>가진 원을 모두 잃었어요</h2>
|
||||
<p className="muted">
|
||||
놀이용 칩 {formatChips(v.options.startingChips)}을 다시 받고 계속할 수 있어요{v.rebuy.left !== null ? ` (남은 횟수 ${v.rebuy.left}번)` : ''}. 점수에서는 다시 받은 만큼 빠져요.
|
||||
놀이용 시작 금액 {formatWon(v.options.startingChips)}을 다시 받고 계속할 수 있어요{v.rebuy.left !== null ? ` (남은 횟수 ${v.rebuy.left}번)` : ''}. 점수에서는 다시 받은 만큼 빠져요.
|
||||
</p>
|
||||
<div className="row">
|
||||
<button className="btn btn-primary" style={{ flex: 1 }} disabled={pending} onClick={() => act({ type: 'rebuy', accept: true })}>
|
||||
칩 다시 받기
|
||||
다시 받기
|
||||
</button>
|
||||
<button className="btn btn-danger" style={{ flex: 1 }} disabled={pending} onClick={() => setConfirmQuit(true)}>
|
||||
그만하기
|
||||
@@ -643,13 +259,13 @@ function isMyTurn(v: SeotdaView, me: string | null): boolean {
|
||||
|
||||
function statusText(v: SeotdaView, me: string | null, players: Record<string, PublicUser>): string {
|
||||
if (v.phase === 'finished') return v.result?.summary ?? '게임이 끝났어요';
|
||||
if (v.phase === 'rebuy') return v.rebuy?.mine ? '칩을 다시 받을지 골라 주세요' : '칩을 다시 받을지 기다리는 중이에요';
|
||||
if (v.phase === 'rebuy') return v.rebuy?.mine ? '시작 금액을 다시 받을지 골라 주세요' : '시작 금액을 다시 받을지 기다리는 중이에요';
|
||||
switch (v.handPhase) {
|
||||
case 'betting':
|
||||
if (v.toAct === me) return v.myHand && v.options.hints ? `내 차례예요 · 지금: ${v.myHand.name}` : '내 차례예요. 베팅해 주세요';
|
||||
return v.toAct ? `${nick(players, v.toAct)}님 차례예요` : '카드를 나눠 주는 중이에요';
|
||||
if (v.toAct === me) return v.myHand && v.options.hints ? `내 차례예요 · 내 패: ${v.myHand.name}` : '내 차례예요. 베팅해 주세요';
|
||||
return v.toAct ? `${nick(players, v.toAct)}님 차례예요` : '패를 나눠 주는 중이에요';
|
||||
case 'choose':
|
||||
return isMyTurn(v, me) ? '쓸 카드 2장을 골라 주세요' : '다른 사람이 카드를 고르는 중이에요';
|
||||
return isMyTurn(v, me) ? '쓸 패 2장을 골라 주세요' : '다른 사람이 패를 고르는 중이에요';
|
||||
case 'rejoin':
|
||||
return v.rejoin?.mine ? '구사 재경기에 참가할지 골라 주세요' : '다이한 사람이 재경기 참가를 고르는 중이에요';
|
||||
case 'handEnd':
|
||||
@@ -661,7 +277,7 @@ function statusText(v: SeotdaView, me: string | null, players: Record<string, Pu
|
||||
|
||||
// ---------------------------------------------------------------- options
|
||||
|
||||
function Seg<T extends string | number>({ value, options, onChange }: { value: T; options: [T, string][]; onChange: (v: T) => void }) {
|
||||
function Seg<T extends string | number | null>({ value, options, onChange }: { value: T; options: [T, string][]; onChange: (v: T) => void }) {
|
||||
return (
|
||||
<div className="segmented">
|
||||
{options.map(([k, l]) => (
|
||||
@@ -688,43 +304,63 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
|
||||
const tooBig = o.baseUnit * 20 > o.startingChips;
|
||||
return (
|
||||
<div className="stack" style={{ gap: 16 }}>
|
||||
<Field label="카드 수">
|
||||
<Seg value={o.cardMode} options={[['two', '2장 섯다'], ['three', '3장 섯다(최대 6명)']]} onChange={(cardMode) => set({ cardMode })} />
|
||||
<Field label="게임 방식">
|
||||
<Seg value={o.cardMode} options={[['two', '2장 섯다'], ['three', o.deck === 40 ? '3장 섯다' : '3장 섯다(최대 6명)']]} onChange={(cardMode) => set({ cardMode })} />
|
||||
</Field>
|
||||
{o.cardMode === 'two' && (
|
||||
<Field label="카드 나눠 주기">
|
||||
<Seg value={o.dealMode} options={[['twoRounds', '1장씩 두 번(베팅 2번)'], ['oneRound', '2장 한 번에(베팅 1번)']]} onChange={(dealMode) => set({ dealMode })} />
|
||||
<Field label="패 받기">
|
||||
<Seg value={o.dealMode} options={[['oneRound', '2장 한 번에(베팅 1번)'], ['twoRounds', '1장씩 두 번(베팅 2번)']]} onChange={(dealMode) => set({ dealMode })} />
|
||||
</Field>
|
||||
)}
|
||||
<Field label="시작 칩">
|
||||
<Seg value={o.startingChips} options={[[500, '500'], [1000, '1,000'], [2000, '2,000'], [5000, '5,000']]} onChange={(startingChips) => set({ startingChips })} />
|
||||
<Field label="화투 장수">
|
||||
<Seg value={o.deck} options={[[20, '20장(1~10월 2장씩)'], [40, '40장(1~10월 4장씩)']]} onChange={(deck) => set({ deck })} />
|
||||
</Field>
|
||||
<Field label="학교(기본 칩) = 삥">
|
||||
<Seg value={o.baseUnit} options={[[2, '2칩'], [10, '10칩'], [20, '20칩'], [50, '50칩']]} onChange={(baseUnit) => set({ baseUnit })} />
|
||||
{tooBig && <span className="field-error">학교는 시작 칩의 20분의 1 이하로 골라 주세요.</span>}
|
||||
<Field label="시작 금액">
|
||||
<Seg value={o.startingChips} options={[[500_000, '50만원'], [1_000_000, '100만원'], [2_000_000, '200만원'], [5_000_000, '500만원']]} onChange={(startingChips) => set({ startingChips })} />
|
||||
</Field>
|
||||
<Field label="기본금(판마다 내는 돈, 삥)">
|
||||
<Seg value={o.baseUnit} options={[[2_000, '2천원'], [10_000, '1만원'], [20_000, '2만원'], [50_000, '5만원']]} onChange={(baseUnit) => set({ baseUnit })} />
|
||||
{tooBig && <span className="field-error">기본금은 시작 금액의 20분의 1 이하로 골라 주세요.</span>}
|
||||
</Field>
|
||||
<Field label="베팅 규칙">
|
||||
<Seg
|
||||
value={o.betRule}
|
||||
options={[
|
||||
['free', '일반'],
|
||||
['111', '111'],
|
||||
['222', '222'],
|
||||
['333', '333'],
|
||||
['444', '444'],
|
||||
]}
|
||||
onChange={(betRule) => set({ betRule })}
|
||||
/>
|
||||
<span className="small muted">
|
||||
{o.betRule === 'free' ? '모두 마음대로 걸어요.' : `선부터 ${o.betRule[0]}명은 첫 베팅에서 하프나 다이만 할 수 있고, 그 뒤는 마음대로예요.`}
|
||||
</span>
|
||||
</Field>
|
||||
<Field label="끝내는 방식">
|
||||
<Seg value={o.endCondition} options={[['hands', '정해진 판 수'], ['lastStanding', '최후의 1인']]} onChange={(endCondition) => set({ endCondition })} />
|
||||
{o.endCondition === 'hands' && (
|
||||
<Seg value={o.handLimit} options={[[10, '10판'], [20, '20판'], [30, '30판'], [50, '50판']]} onChange={(handLimit) => set({ handLimit })} />
|
||||
)}
|
||||
{o.endCondition === 'hands' && <Seg value={o.handLimit} options={[[10, '10판'], [20, '20판'], [30, '30판'], [50, '50판']]} onChange={(handLimit) => set({ handLimit })} />}
|
||||
</Field>
|
||||
<Field label="행동 제한 시간">
|
||||
<Seg value={o.turnSeconds} options={[[15, '15초'], [20, '20초'], [30, '30초'], [60, '60초']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
<Seg value={o.turnSeconds} options={[[15, '15초'], [20, '20초'], [30, '30초'], [60, '60초'], [null, '무제한']]} onChange={(turnSeconds) => set({ turnSeconds })} />
|
||||
</Field>
|
||||
<button type="button" className="btn btn-ghost" onClick={() => setMore(!more)} aria-expanded={more}>
|
||||
{more ? '▲ 자세한 설정 닫기' : '▼ 자세한 설정'}
|
||||
</button>
|
||||
{more && (
|
||||
<>
|
||||
<Field label="최대 레이즈">
|
||||
<Seg value={o.maxRaise} options={[['half', '하프까지'], ['full', '풀까지']]} onChange={(maxRaise) => set({ maxRaise })} />
|
||||
<Field label="최대 베팅">
|
||||
<Seg value={o.maxRaise} options={[['half', '하프까지'], ['full', '풀(판돈만큼)까지']]} onChange={(maxRaise) => set({ maxRaise })} />
|
||||
</Field>
|
||||
<Field label="칩 다시 받기(리바이)">
|
||||
<Seg value={o.rebuy} options={[['off', '안 함(탈락)'], ['limited', '횟수 제한'], ['unlimited', '무제한']]} onChange={(rebuy) => set({ rebuy })} />
|
||||
<Field label="쿼터 버튼">
|
||||
<Seg value={o.quarter ? 'on' : 'off'} options={[['off', '안 씀'], ['on', '씀']]} onChange={(k) => set({ quarter: k === 'on' })} />
|
||||
</Field>
|
||||
<Field label="원을 다 잃으면(리바이)">
|
||||
<Seg value={o.rebuy} options={[['off', '탈락'], ['limited', '횟수 제한'], ['unlimited', '무제한']]} onChange={(rebuy) => set({ rebuy })} />
|
||||
{o.rebuy === 'limited' && <Seg value={o.rebuyLimit} options={[[1, '1번'], [2, '2번'], [3, '3번']]} onChange={(rebuyLimit) => set({ rebuyLimit })} />}
|
||||
</Field>
|
||||
<Field label="학교 올리기">
|
||||
<Field label="기본금 올리기">
|
||||
<Seg value={o.schoolUpEvery} options={[[0, '안 올림'], [5, '5판마다 2배'], [10, '10판마다 2배'], [15, '15판마다 2배']]} onChange={(schoolUpEvery) => set({ schoolUpEvery })} />
|
||||
</Field>
|
||||
<Field label="다음 판의 선">
|
||||
@@ -734,7 +370,7 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
|
||||
<Seg value={o.gwangTtaeng} options={[['all', '38·18·13광땡'], ['only38', '38광땡만']]} onChange={(gwangTtaeng) => set({ gwangTtaeng })} />
|
||||
</Field>
|
||||
<Field label="땡잡이(3·7)">
|
||||
<Seg value={o.ttaengjabi} options={[['strict', '3월 광 + 7월 열끗'], ['loose', '3월 + 7월 아무 패'], ['off', '없음']]} onChange={(ttaengjabi) => set({ ttaengjabi })} />
|
||||
<Seg value={o.ttaengjabi} options={[['loose', '3월 + 7월 아무 패'], ['strict', '3월 광 + 7월 열끗만'], ['off', '없음']]} onChange={(ttaengjabi) => set({ ttaengjabi })} />
|
||||
</Field>
|
||||
<Field label="특수패">
|
||||
<Seg value={o.amhaeng ? 'on' : 'off'} options={[['on', '암행어사 켜기'], ['off', '암행어사 끄기']]} onChange={(k) => set({ amhaeng: k === 'on' })} />
|
||||
@@ -743,10 +379,10 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
|
||||
{o.gusa && (
|
||||
<>
|
||||
<Field label="멍텅구리구사 재경기 범위">
|
||||
<Seg value={o.mungGusa} options={[['upTo8', '8땡까지'], ['upTo9', '9땡까지'], ['upToJang', '장땡까지'], ['off', '일반 구사로']]} onChange={(mungGusa) => set({ mungGusa })} />
|
||||
<Seg value={o.mungGusa} options={[['upTo9', '9땡까지'], ['upTo8', '8땡까지'], ['upToJang', '장땡까지'], ['off', '일반 구사로']]} onChange={(mungGusa) => set({ mungGusa })} />
|
||||
</Field>
|
||||
<Field label="구사 재경기 때 다이한 사람">
|
||||
<Seg value={o.rejoinCost} options={[['none', '참가 불가'], ['half', '모인 칩 절반 내고 참가'], ['full', '모인 칩만큼 내고 참가']]} onChange={(rejoinCost) => set({ rejoinCost })} />
|
||||
<Seg value={o.rejoinCost} options={[['none', '참가 불가'], ['half', '판돈 절반 내고 참가'], ['full', '판돈만큼 내고 참가']]} onChange={(rejoinCost) => set({ rejoinCost })} />
|
||||
</Field>
|
||||
</>
|
||||
)}
|
||||
@@ -759,7 +395,7 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
|
||||
<Field label="재참가·리바이 답 시간">
|
||||
<Seg value={o.decisionSeconds} options={[[10, '10초'], [15, '15초'], [30, '30초']]} onChange={(decisionSeconds) => set({ decisionSeconds })} />
|
||||
</Field>
|
||||
<Field label="도움 표시">
|
||||
<Field label="족보 도우미">
|
||||
<Seg value={o.hints ? 'on' : 'off'} options={[['on', '내 족보 이름 보여 주기'], ['off', '보여 주지 않기']]} onChange={(k) => set({ hints: k === 'on' })} />
|
||||
</Field>
|
||||
</>
|
||||
@@ -770,11 +406,13 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
|
||||
|
||||
function optionsSummary(o: SeotdaOptions): string {
|
||||
return [
|
||||
o.cardMode === 'three' ? '3장 섯다' : o.dealMode === 'twoRounds' ? '2장 섯다(1장씩 두 번)' : '2장 섯다(한 번에)',
|
||||
`시작 ${o.startingChips.toLocaleString('ko-KR')}칩`,
|
||||
`학교 ${o.baseUnit}칩`,
|
||||
o.cardMode === 'three' ? '3장 섯다' : o.dealMode === 'twoRounds' ? '2장 섯다(1장씩)' : '2장 섯다',
|
||||
`${o.deck}장`,
|
||||
`시작 ${formatWon(o.startingChips)}`,
|
||||
`기본금 ${formatWon(o.baseUnit)}`,
|
||||
o.betRule === 'free' ? '일반 베팅' : `베팅 ${o.betRule}`,
|
||||
o.endCondition === 'hands' ? `${o.handLimit}판` : '최후의 1인',
|
||||
`${o.turnSeconds}초`,
|
||||
o.turnSeconds === null ? '시간 무제한' : `${o.turnSeconds}초`,
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
@@ -783,39 +421,47 @@ function Rules({ options }: { options?: SeotdaOptions }) {
|
||||
return (
|
||||
<div className="stack">
|
||||
<p>
|
||||
화투 20장(1~10월 각 2장)으로 하는 족보 대결이에요. 각자 받은 <strong>2장의 조합(족보)</strong>이 가장 센 사람이 모인 칩을 가져가요. 칩은 이 방에서만 쓰는 놀이용 점수예요.
|
||||
화투 {o?.deck ?? 20}장({o?.deck === 40 ? '1~10월 4장씩' : '1~10월 2장씩'})으로 하는 족보 대결이에요. 각자 받은 <strong>2장의 조합(족보)</strong>이 가장 센 사람이 가운데{' '}
|
||||
<strong>판돈</strong>을 모두 가져가요. {PLAY_MONEY_NOTICE}
|
||||
</p>
|
||||
<p>
|
||||
<strong>진행</strong>: 판마다 모두 <strong>학교(기본 칩)</strong>를 내요. 선부터 카드를 받고 차례로 베팅해요.
|
||||
<strong>진행</strong>: 판마다 모두 <strong>기본금</strong>을 판돈에 내요. 선부터 패를 받고 차례로 베팅해요.
|
||||
{o?.cardMode === 'three'
|
||||
? ' 3장 섯다는 2장을 받고 베팅 → 1장을 더 받아 3장 중 쓸 2장을 동시에 몰래 고르고 → 마지막 베팅 후 공개해요. 버린 1장은 끝까지 아무도 못 봐요.'
|
||||
: o?.dealMode === 'oneRound'
|
||||
? ' 2장을 한 번에 받고 한 번 베팅한 뒤 공개해요.'
|
||||
: ' 1장 받고 베팅, 1장 더 받고 베팅한 뒤 남은 사람끼리 패를 공개해요.'}{' '}
|
||||
모두 다이하고 한 명만 남으면 그 사람이 패를 보여 주지 않고 가져가요.
|
||||
? ' 3장 섯다는 2장을 받고 베팅 → 1장을 더 받아 3장 중 쓸 2장을 몰래 고르고 → 마지막 베팅 후 공개해요. 버린 1장은 끝까지 아무도 못 봐요.'
|
||||
: o?.dealMode === 'twoRounds'
|
||||
? ' 1장 받고 베팅, 1장 더 받고 베팅한 뒤 남은 사람끼리 패를 공개해요.'
|
||||
: ' 2장을 한 번에 받고 한 번 베팅한 뒤 남은 사람끼리 패를 공개해요.'}{' '}
|
||||
모두 다이하고 한 명만 남으면 그 사람이 패를 보여 주지 않고 판돈을 가져가요.
|
||||
</p>
|
||||
<p>
|
||||
<strong>베팅</strong>: 체크(안 걸고 넘김), 삥(기본 칩만큼), 콜(앞사람만큼), 따당(앞사람이 건 만큼의 두 배), 쿼터·하프{o?.maxRaise === 'full' ? '·풀' : ''}(모인 칩의 4분의 1·절반
|
||||
{o?.maxRaise === 'full' ? '·전부' : ''}만큼 더), 다이(포기). 한 라운드에 올리기는 한 번뿐이고, 체크나 콜을 한 뒤에는 같은 라운드에서 올릴 수 없어요. 칩이 모자라면 가진 만큼 내고 올인해요.
|
||||
<strong>베팅</strong>(괄호는 숫자 키): 콜(7) 앞사람만큼, 다이(8) 포기, 삥(4) 기본금만큼, 체크(5) 안 걸고 넘김, 따당(1) 앞사람이 건 돈의 두 배, 하프(0) 맞춘 뒤 판돈의 절반을 더
|
||||
{o?.quarter ? ', 쿼터(2) 판돈의 4분의 1을 더' : ''}
|
||||
{o?.maxRaise === 'full' ? ', 풀(9) 판돈만큼 더' : ''}. 한 라운드에 올리기는 한 번뿐이고, 체크나 콜을 한 뒤에는 같은 라운드에서 올릴 수 없어요. 가진 금액이 모자라면 가진 만큼 내고 올인해요.
|
||||
{o && o.betRule !== 'free' ? ` 이 방은 베팅 규칙 ${o.betRule}: 선부터 ${o.betRule[0]}명은 첫 베팅에서 하프나 다이만 할 수 있어요.` : ''}
|
||||
</p>
|
||||
<p>
|
||||
<strong>끗</strong>: 두 장의 월을 더한 값의 일의 자리예요. 7 + 8 = 15 → 5끗, 9 + 10 = 19 → 9끗(갑오), 2 + 8 = 10 → 0끗(망통).
|
||||
<strong>끗</strong>: 두 장의 달을 더한 값의 일의 자리예요. 7 + 8 = 15 → 5끗, 9 + 10 = 19 → 9끗(갑오), 2 + 8 = 10 → 0끗(망통).
|
||||
</p>
|
||||
<JokboTable options={o ?? ({ gwangTtaeng: 'all', ttaengjabi: 'strict', amhaeng: true, gusa: true, mungGusa: 'upTo8', hints: false } as SeotdaOptions)} />
|
||||
<JokboTable options={o ?? ({ gwangTtaeng: 'all', ttaengjabi: 'loose', amhaeng: true, gusa: true, mungGusa: 'upTo9', hints: false } as SeotdaOptions)} />
|
||||
<p>
|
||||
<strong>재경기</strong>: 구사나 같은 족보{o?.tieRule === 'split' ? '(이 방은 동점이면 나눠 가져요)' : ''}로 재경기가 되면 모인 칩은 그대로 두고 남은 사람끼리 새로 카드를 받아요. 학교는 다시 내지 않아요.
|
||||
{o && o.rejoinCost !== 'none' ? ` 구사 재경기 때 다이한 사람은 모인 칩의 ${o.rejoinCost === 'half' ? '절반' : '전부'}만큼 내고 다시 들어올 수 있어요.` : ''} 한 판에서 재경기가{' '}
|
||||
<strong>재경기</strong>: 구사나 같은 족보{o?.tieRule === 'split' ? '(이 방은 같은 족보면 나눠 가져요)' : ''}로 재경기가 되면 판돈은 그대로 두고 남은 사람끼리 새로 패를 받아요. 기본금은 다시 내지 않아요.
|
||||
{o && o.rejoinCost !== 'none' ? ` 구사 재경기 때 다이한 사람은 판돈의 ${o.rejoinCost === 'half' ? '절반' : '전부'}만큼 내고 다시 들어올 수 있어요.` : ''} 한 판에서 재경기가{' '}
|
||||
{o?.maxRematches ?? 3}번을 넘으면 나눠 가져요.
|
||||
</p>
|
||||
<p>
|
||||
<strong>선</strong>: 선은 카드를 먼저 받고 먼저 베팅해요. {o?.dealerRule === 'rotate' ? '판마다 다음 사람에게 넘어가요.' : '이긴 사람이 다음 판의 선이 돼요.'}
|
||||
<strong>선</strong>: 선은 패를 먼저 받고 먼저 베팅해요. {o?.dealerRule === 'rotate' ? '판마다 다음 사람에게 넘어가요.' : '이긴 사람이 다음 판의 선이 돼요.'}
|
||||
</p>
|
||||
<p>
|
||||
<strong>칩이 떨어지면</strong>:{' '}
|
||||
{o?.rebuy === 'off' ? '탈락하고 구경해요.' : '칩을 다시 받을지 고를 수 있어요. 다시 받은 만큼 최종 점수에서 빠져요.'}{' '}
|
||||
{o?.endCondition === 'lastStanding' ? '칩을 가진 사람이 한 명 남으면 끝나요.' : `정해진 판 수가 끝나면 (마지막 칩 − 시작 칩 × 다시 받은 횟수)로 순위를 정해요.`}
|
||||
<strong>원을 모두 잃으면</strong>:{' '}
|
||||
{o?.rebuy === 'off' ? '탈락하고 구경해요.' : '시작 금액을 다시 받을지 고를 수 있어요. 다시 받은 만큼 최종 점수에서 빠져요.'}{' '}
|
||||
{o?.endCondition === 'lastStanding' ? '원이 남은 사람이 한 명이 되면 끝나요.' : '정해진 판 수가 끝나면 (마지막 보유 금액 − 시작 금액 × 다시 받은 횟수)로 순위를 정해요.'}
|
||||
</p>
|
||||
<p>시간 안에 고르지 않으면 걸린 칩이 없을 때는 체크, 있을 때는 다이로 처리돼요. 두 번 연속 시간을 넘기면 '자리 비움'이 되고 제한 시간이 5초로 줄어요.</p>
|
||||
<p>
|
||||
{o?.turnSeconds === null
|
||||
? '이 방은 행동 시간이 무제한이에요.'
|
||||
: "시간 안에 고르지 않으면 앞사람이 건 금액이 없을 때는 체크, 있을 때는 다이로 처리돼요. 두 번 연속 시간을 넘기면 '자리 비움'이 되고 제한 시간이 5초로 줄어요."}
|
||||
</p>
|
||||
<p className="small muted">{HWATU_CREDIT}</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ const btn = (bg: string): CSSProperties => ({
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
minWidth: 74,
|
||||
minWidth: 0,
|
||||
height: 40,
|
||||
borderRadius: 10,
|
||||
background: bg,
|
||||
@@ -47,11 +47,13 @@ const btn = (bg: string): CSSProperties => ({
|
||||
|
||||
function Buttons() {
|
||||
return (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 8, width: 170 }} aria-hidden>
|
||||
<span style={btn('#dc2626')}>다이</span>
|
||||
<span style={btn('#2563eb')}>체크</span>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 6, width: 240 }} aria-hidden>
|
||||
<span style={btn('#2563eb')}>콜</span>
|
||||
<span style={btn('#7c3aed')}>하프</span>
|
||||
<span style={btn('#b91c1c')}>다이</span>
|
||||
<span style={btn('#ea580c')}>하프</span>
|
||||
<span style={btn('#0f766e')}>삥</span>
|
||||
<span style={btn('#15803d')}>체크</span>
|
||||
<span style={btn('#7c3aed')}>따당</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -67,13 +69,13 @@ export const quickStart: QuickCard[] = [
|
||||
),
|
||||
alt: '3월 광과 8월 광 화투 두 장이 놓여 있고 38광땡이라고 적혀 있어요',
|
||||
title: '2장 조합이 센 사람이 이겨요',
|
||||
text: '화투 2장의 조합(족보)을 겨뤄요. 가장 센 족보를 가진 사람이 가운데 모인 칩을 모두 가져가요.',
|
||||
text: '화투 2장의 조합(족보)을 겨뤄요. 가장 센 족보를 가진 사람이 가운데 판돈을 모두 가져가요. 원은 이 방에서만 쓰는 놀이용 숫자예요.',
|
||||
},
|
||||
{
|
||||
pic: <Buttons />,
|
||||
alt: '다이, 체크, 콜, 하프라고 적힌 버튼 네 개가 있어요',
|
||||
title: '차례가 오면 칩을 걸어요',
|
||||
text: '[체크]·[콜]·[하프] 같은 버튼으로 칩을 걸고, 패가 약하면 [다이]로 이번 판을 포기해요. 다른 사람이 다 다이하면 내가 가져가요.',
|
||||
alt: '콜, 다이, 하프, 삥, 체크, 따당이라고 적힌 버튼 여섯 개가 있어요',
|
||||
title: '차례가 오면 걸어요',
|
||||
text: '[체크]·[삥]·[콜]·[하프]·[따당] 버튼(PC는 숫자 키도)으로 걸고, 패가 약하면 [다이]로 이번 판을 포기해요. 다른 사람이 다 다이하면 내가 가져가요.',
|
||||
},
|
||||
{
|
||||
pic: (
|
||||
@@ -87,6 +89,6 @@ export const quickStart: QuickCard[] = [
|
||||
),
|
||||
alt: '장땡, 알리, 8끗 순서로 화투 두 장씩 놓여 있고 사이에 큰 쪽 표시가 있어요',
|
||||
title: '땡 > 알리 > 끗 순서예요',
|
||||
text: "광땡 > 땡(같은 달 2장) > 알리·독사 등 > 끗(두 달을 더한 일의 자리) 순으로 세요. 화면의 '족보표'를 보면 쉬워요.",
|
||||
text: "광땡 > 땡(같은 달 2장) > 알리·독사 등 > 끗(두 달을 더한 일의 자리) 순으로 세요. 화면의 '족보 도우미'를 보면 쉬워요.",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
/**
|
||||
* Guard (docs/04 §6, reviewer request): betting-game UI text must never look like real money.
|
||||
* Scans the betting games' screens and shared chip/card components for currency-like wording.
|
||||
*
|
||||
* Exception (2026-10-13, user request "한게임 섯다처럼 원과 판돈으로"): 섯다 shows its room-only play money in "원" and
|
||||
* calls the pot "판돈", like 한게임 섯다. Only those two are allowed there; currency symbols, 현금·머니·골드, "돈을/돈이/돈은"
|
||||
* and transaction words (충전·환전·결제 …) stay forbidden in 섯다 too.
|
||||
*/
|
||||
import { expect, test } from 'bun:test';
|
||||
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const ROOTS = ['games/poker', 'games/seotda', 'games/gostop', 'games/marble', 'games/las-vegas', 'components/cards'].map((p) => join(import.meta.dir, p));
|
||||
const SEOTDA = join(import.meta.dir, 'games/seotda');
|
||||
const FORBIDDEN: [RegExp, string][] = [
|
||||
[/₩|\$\s?\d|\d\s?\$/, '통화 기호'],
|
||||
[/\d[\d,]*\s*(만\s*)?원(?![가-힣])/, '"원" 단위'],
|
||||
@@ -30,10 +35,25 @@ function visibleText(src: string): string {
|
||||
test('no currency-like wording in betting game UI', () => {
|
||||
const problems: string[] = [];
|
||||
for (const f of ROOTS.flatMap(files)) {
|
||||
const seotda = f.startsWith(SEOTDA);
|
||||
const text = visibleText(readFileSync(f, 'utf8'));
|
||||
text.split('\n').forEach((line, i) => {
|
||||
for (const [re, why] of FORBIDDEN) if (re.test(line)) problems.push(`${f.split('/src/')[1]}:${i + 1} ${why}: ${line.trim().slice(0, 80)}`);
|
||||
// 섯다: "판돈" is the game's word for the pot; the other 돈 words are still checked.
|
||||
const checked = seotda ? line.replace(/판돈/g, '') : line;
|
||||
for (const [re, why] of FORBIDDEN) {
|
||||
if (seotda && why === '"원" 단위') continue;
|
||||
if (re.test(checked)) problems.push(`${f.split('/src/')[1]}:${i + 1} ${why}: ${line.trim().slice(0, 80)}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
expect(problems).toEqual([]);
|
||||
});
|
||||
|
||||
test('섯다 exception is narrow: 원 and 판돈 only', () => {
|
||||
const lines = ['판돈 1만원', '판돈은 그대로', '10만원 충전', '₩1000', '게임머니', '돈을 걸어요', '현금'];
|
||||
const bad = lines.filter((line) => {
|
||||
const checked = line.replace(/판돈/g, '');
|
||||
return FORBIDDEN.some(([re, why]) => why !== '"원" 단위' && re.test(checked));
|
||||
});
|
||||
expect(bad).toEqual(['10만원 충전', '₩1000', '게임머니', '돈을 걸어요', '현금']);
|
||||
});
|
||||
|
||||