/** * 티츄 card art (docs/games/tichu.md §3, §12): the 52 number cards reuse the shared PlayingCard (4-colour suits: * 옥 green ♣ · 칼 black ♠ · 탑 blue ◆ · 별 red ♥ — the names are the original's, the shapes are the site's), the four * special cards are our own simple SVG drawings. Size comes from the parent (`--cw` CSS variable, see `.tc-c`). */ import type { CSSProperties } from 'react'; import { PlayingCard } from '../../components/cards/PlayingCard'; import { cardName } from '@bg/games/tichu/combo'; const SUIT_MAP: Record = { j: 'C', s: 'S', b: 'D', t: 'H' }; const RANK_MAP: Record = { 10: 'T', 11: 'J', 12: 'Q', 13: 'K', 14: 'A' }; /** PlayingCard id ("TD", "AS") of a number card. */ export const stdId = (id: string): string => { const r = Number(id.slice(1)); return `${RANK_MAP[r] ?? String(r)}${SUIT_MAP[id[0]!] ?? 'S'}`; }; const SPECIAL: Record = { MJ: { name: '참새', corner: '1', bg: '#fef9c3', ink: '#a16207' }, DOG: { name: '개', corner: '개', bg: '#f5f5f4', ink: '#57534e' }, PH: { name: '봉황', corner: '봉', bg: '#ffedd5', ink: '#c2410c' }, DR: { name: '용', corner: '용', bg: '#dcfce7', ink: '#15803d' }, }; function SpecialPicture({ id, ink }: { id: string; ink: string }) { switch (id) { case 'MJ': // A small round sparrow. return ( ); case 'DOG': // A friendly dog face. return ( ); case 'PH': // A bird of flame: three feathers and a crest. return ( ); default: // A winding dragon with a pearl. return ( ); } } export function SpecialCard({ id }: { id: string }) { const s = SPECIAL[id]!; return ( 1 ? 22 : 30} fontWeight="800" fill={s.ink} fontFamily="Pretendard Variable, sans-serif"> {s.corner} {s.name} ); } /** One card face (or back with `id` null). Sized by the surrounding `.tc-c` box. */ export function CardFace({ id }: { id: string | null }) { if (id && SPECIAL[id]) return ; return ; } export interface TCardProps { id: string; selected?: boolean; dimmed?: boolean; highlight?: boolean; badge?: string; onClick?: () => void; label?: string; style?: CSSProperties; } /** A tappable (or still) card of the 티츄 deck. */ export function TCard({ id, selected, dimmed, highlight, badge, onClick, label, style }: TCardProps) { const cls = `tc-c${selected ? ' sel' : ''}${dimmed ? ' dim' : ''}${highlight ? ' hi' : ''}`; const aria = label ?? cardName(id); if (onClick) { return ( ); } return ( {badge && {badge}} ); }