- packages/engine/betting: 한국식(체크·삥·콜·따당·쿼터·하프·풀·다이, 라운드당 1회·첫 행동에서만 레이즈),
노리밋·팟리밋(최소 레이즈, 불완전 올인 레이즈는 재오픈 안 함, BB 옵션), 앤티·블라인드, 올인,
받지 않은 베팅 반환, 사이드 팟 분할, 동점 분배(홀수 칩 순서), 시간 초과 자동 행동
- 테스트 24개: 포커·섯다 계획서 계산 예시, 행동별 상태 전이, 사이드 팟 예시, 무작위 베팅 1,500판
(칩 총량 보존·라운드 종료·라운드 끝 금액 일치·팟 합계=판 전체)
- packages/engine/cards: 트럼프 52+조커, 화투 48(+보너스)·섯다 20장 정의와 테스트
- 웹: 직접 그린 SVG 트럼프·화투 카드, 칩 표시("1,250 칩"), 놀이용 칩 안내문
- apps/web/src/no-money-wording.test.ts: 베팅 게임 화면에 통화 기호·"원"·판돈·충전·환전 등 금지
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
5.0 KiB
TypeScript
104 lines
5.0 KiB
TypeScript
/** Card definitions shared by card games (docs/09 §5). */
|
||
|
||
// ---------------------------------------------------------------- standard 52 (+ jokers)
|
||
|
||
export const SUITS = ['S', 'H', 'D', 'C'] as const; // ♠ ♥ ◆ ♣
|
||
export const RANKS = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'] as const;
|
||
export type Suit = (typeof SUITS)[number];
|
||
export type Rank = (typeof RANKS)[number];
|
||
/** e.g. "AS" (ace of spades), "TD" (ten of diamonds), "X1"/"X2" jokers. */
|
||
export type CardId = string;
|
||
|
||
export const SUIT_SYMBOL: Record<Suit, string> = { S: '♠', H: '♥', D: '◆', C: '♣' };
|
||
export const SUIT_KO: Record<Suit, string> = { S: '스페이드', H: '하트', D: '다이아', C: '클로버' };
|
||
export const RANK_LABEL: Record<Rank, string> = { '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', T: '10', J: 'J', Q: 'Q', K: 'K', A: 'A' };
|
||
|
||
export function standardDeck(jokers = 0): CardId[] {
|
||
const deck: CardId[] = [];
|
||
for (const s of SUITS) for (const r of RANKS) deck.push(`${r}${s}`);
|
||
for (let j = 1; j <= jokers; j++) deck.push(`X${j}`);
|
||
return deck;
|
||
}
|
||
|
||
export const isJoker = (c: CardId): boolean => c.startsWith('X');
|
||
export const rankOf = (c: CardId): Rank => c[0] as Rank;
|
||
export const suitOf = (c: CardId): Suit => c[1] as Suit;
|
||
/** 2..14 (ace high). */
|
||
export const rankValue = (c: CardId): number => RANKS.indexOf(rankOf(c)) + 2;
|
||
export const cardLabel = (c: CardId): string => (isJoker(c) ? '조커' : `${SUIT_SYMBOL[suitOf(c)]}${RANK_LABEL[rankOf(c)]}`);
|
||
|
||
// ---------------------------------------------------------------- hwatu 48 (+ bonus)
|
||
|
||
export type HwatuKind = 'gwang' | 'yeol' | 'tti' | 'pi' | 'ssangpi' | 'bonus';
|
||
export type TtiKind = 'hong' | 'cheong' | 'cho' | 'plain';
|
||
|
||
export interface HwatuCard {
|
||
id: number;
|
||
/** 1..12, 0 for bonus cards. */
|
||
month: number;
|
||
kind: HwatuKind;
|
||
tti?: TtiKind;
|
||
/** Special flags used by scoring: godori birds, 비광, 국진(9월 열끗) etc. */
|
||
tags: string[];
|
||
/** Korean display name, e.g. "1월 광(송학)". */
|
||
name: string;
|
||
/** Junk value (피 1, 쌍피 2, bonus 2/3). */
|
||
piValue: number;
|
||
}
|
||
|
||
const MONTH_NAME = ['', '송학', '매조', '벚꽃', '흑싸리', '난초', '모란', '홍싸리', '공산', '국화', '단풍', '오동', '비'];
|
||
|
||
/** id = (month-1)*4 + slot, matching docs/games/gostop.md §3.1. */
|
||
const TABLE: [HwatuKind, TtiKind | null, string[]][][] = [
|
||
/* 1 */ [['gwang', null, ['crane']], ['tti', 'hong', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 2 */ [['yeol', null, ['godori']], ['tti', 'hong', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 3 */ [['gwang', null, ['cherry']], ['tti', 'hong', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 4 */ [['yeol', null, ['godori']], ['tti', 'cho', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 5 */ [['yeol', null, []], ['tti', 'cho', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 6 */ [['yeol', null, []], ['tti', 'cheong', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 7 */ [['yeol', null, []], ['tti', 'cho', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 8 */ [['gwang', null, ['moon']], ['yeol', null, ['godori']], ['pi', null, []], ['pi', null, []]],
|
||
/* 9 */ [['yeol', null, ['gukjin']], ['tti', 'cheong', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 10 */ [['yeol', null, []], ['tti', 'cheong', []], ['pi', null, []], ['pi', null, []]],
|
||
/* 11 */ [['gwang', null, ['phoenix']], ['ssangpi', null, []], ['pi', null, []], ['pi', null, []]],
|
||
/* 12 */ [['gwang', null, ['rain']], ['yeol', null, ['swallow']], ['tti', 'plain', []], ['ssangpi', null, []]],
|
||
];
|
||
|
||
const KIND_KO: Record<HwatuKind, string> = { gwang: '광', yeol: '열끗', tti: '띠', pi: '피', ssangpi: '쌍피', bonus: '보너스' };
|
||
const TTI_KO: Record<TtiKind, string> = { hong: '홍단', cheong: '청단', cho: '초단', plain: '띠' };
|
||
|
||
export const HWATU: HwatuCard[] = TABLE.flatMap((cards, m) =>
|
||
cards.map(([kind, tti, tags], slot) => {
|
||
const month = m + 1;
|
||
const id = m * 4 + slot;
|
||
const label = kind === 'tti' ? TTI_KO[tti!] : month === 12 && kind === 'gwang' ? '비광' : KIND_KO[kind];
|
||
return {
|
||
id,
|
||
month,
|
||
kind,
|
||
...(tti ? { tti } : {}),
|
||
tags,
|
||
name: `${month}월 ${label}(${MONTH_NAME[month]})`,
|
||
piValue: kind === 'pi' ? 1 : kind === 'ssangpi' ? 2 : 0,
|
||
};
|
||
}),
|
||
);
|
||
|
||
/** Bonus cards: ids 48.. (2피 cards, then a 3피 card last). */
|
||
export function hwatuBonus(count: number): HwatuCard[] {
|
||
return Array.from({ length: count }, (_, i) => {
|
||
const three = i === count - 1 && count >= 3;
|
||
return { id: 48 + i, month: 0, kind: 'bonus' as const, tags: [], name: three ? '보너스 3피' : '보너스 2피', piValue: three ? 3 : 2 };
|
||
});
|
||
}
|
||
|
||
export const hwatu = (id: number): HwatuCard => {
|
||
const c = HWATU[id];
|
||
if (c) return c;
|
||
if (id >= 48) return hwatuBonus(id - 47).at(-1)!;
|
||
throw new Error(`unknown hwatu id ${id}`);
|
||
};
|
||
|
||
/** 섯다 20장: each month 1–10, its special card (slot 0) and the next card (slot 1) — docs/games/seotda.md §3. */
|
||
export const SEOTDA_DECK: number[] = Array.from({ length: 10 }, (_, m) => [m * 4, m * 4 + 1]).flat();
|