섯다: 3장 섯다를 한게임 방식으로 — 2장 받고 공개패 1장 고르기 → 1구 베팅 → 1장 더 → 2구 베팅 → 3장 중 2장 골라 승부

- 엔진: 공개패 단계(open)·액션, 공개패는 다른 사람 화면에 앞면, 최종 선택은 마지막 베팅 뒤(threePick=end), 옵션 threeOpen/threePick으로 예전 흐름 유지, 상태 v3(진행 중인 방은 예전 흐름)
- 컴퓨터: 광·4/7/9 열끗은 숨기고 평범한 패 공개, 상대 공개패를 패 범위에 반영
- 화면: 공개패 고르기 상자, 자리 표시·도움말·규칙·옵션
- 2장 섯다 기본(2장 한 번에)은 한게임 안내 그대로, 1장씩(전통)은 옵션
- E2E seotda3, 문서 §2·§5.2·§8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 22:22:06 +09:00
parent 9564e4604c
commit 1cf556b431
10 changed files with 333 additions and 41 deletions

View File

@@ -145,8 +145,14 @@ describe('seotda bot', () => {
expect(decide(s, 'A').type).toBe('half');
});
test('3장 섯다 공개패: 광은 숨기고 평범한 패를 보여 줘요', () => {
const s = rig(make({ cardMode: 'three' }), { A: [S(3), P(5)], B: [P(4), P(7)], C: [P(2), P(3)] });
expect(s.hand!.phase).toBe('open');
expect(decide(s, 'A')).toEqual({ type: 'open', cardId: P(5) });
});
test('3장 섯다: keeps the best pair of its three cards', () => {
let s = make({ cardMode: 'three' });
let s = make({ cardMode: 'three', threeOpen: false, threePick: 'beforeBet' });
s = rig(s, { A: [P(4), P(9)], B: [P(5), P(7)], C: [P(2), P(3)] }, [P(6), S(2), S(5)]);
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'check' });
expect(s.hand!.phase).toBe('choose');

View File

@@ -54,12 +54,19 @@ export function rangesOf(v: SeotdaView, me: string): { id: string; weight: Range
const partialStreet0 = v.options.cardMode === 'three' || v.options.dealMode === 'twoRounds';
return live.map((s) => {
const mine = entries.filter((e) => e.p === s.id && !e.forced);
if (!mine.length) return { id: s.id, weight: () => 1 };
// 3장 섯다 공개패: every hand they may hold contains the card they showed.
const shown = s.cards.flatMap((c) => ('id' in c ? [c.id] : []));
const holds = (cards: number[]) => shown.every((c) => cards.includes(c));
if (!mine.length) return { id: s.id, weight: shown.length ? (cards: number[]) => (holds(cards) ? 1 : 0) : () => 1 };
const memo = new Map<number, number>();
const weight: RangeWeight = (cards) => {
const key = cardsKey(cards);
const hit = memo.get(key);
if (hit !== undefined) return hit;
if (!holds(cards)) {
memo.set(key, 0);
return 0;
}
const p = strengthPercentile(cards, rules, deck, finalSize);
let w = 1;
let raises = 0;
@@ -197,6 +204,19 @@ export const seotdaBot: BotStrategy<SeotdaView, SeotdaAction> = ({ me, view: v,
const join = (v.pot + r.cost) / k - r.cost > 0 && r.cost <= (mine?.stack ?? 0) / 3;
return legal.find((a) => a.type === 'rejoin' && a.accept === join) ?? first;
}
case 'open': {
// 3장 섯다 공개패: show the card that tells the others least — the one whose month leaves my best hands hidden.
const opens = legal.filter((a): a is Extract<SeotdaAction, { type: 'open' }> => a.type === 'open');
// A 광 or a 4·7·9 열끗 (special hands) tells most, then a high month: show the plainest card.
const tells = (c: number) => {
const card = (v.seats.find((x) => x.id === me)?.cards ?? []).find((x) => 'id' in x && x.id === c);
if (!card || !('id' in card)) return 0;
if (card.kind === 'gwang') return 3;
if (card.kind === 'yeol' && [4, 7, 9].includes(card.month)) return 2;
return card.month / 10;
};
return humanBest(opens, (a) => -tells(a.cardId), random, level, { small: 0.05, critical: 2 });
}
case 'choose': {
// 3장 섯다: keep the pair with the best share of the pot against what the others may hold (specials included).
const chooses = legal.filter((a): a is Extract<SeotdaAction, { type: 'choose' }> => a.type === 'choose');

View File

@@ -51,7 +51,17 @@ export const seotdaOptionsSchema = z
dealMode: z
.enum(['oneRound', 'twoRounds'])
.default('oneRound')
.meta({ title: '2장 섯다 패 받기', labels: { oneRound: '2장 한 번에 받고 베팅 1번', twoRounds: '1장씩 두 번 받고 베팅 2번' } }),
.meta({ title: '2장 섯다 패 받기', labels: { oneRound: '2장 한 번에 받고 베팅 1번(한게임)', twoRounds: '1장씩 두 번 받고 베팅 2번(전통)' } }),
threeOpen: z
.boolean()
.default(true)
.catch(true)
.meta({ title: '3장 섯다 공개패(2장 중 1장을 모두에게 보여 주기, 한게임)' }),
threePick: z
.enum(['end', 'beforeBet'])
.default('end')
.catch('end')
.meta({ title: '3장 섯다 최종 2장 고르기', labels: { end: '마지막 베팅 뒤(한게임)', beforeBet: '마지막 베팅 전' } }),
deck: lit(20, 40)
.default(20)
.catch(20)
@@ -139,6 +149,7 @@ export const seotdaActionSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('full') }),
z.object({ type: z.literal('die') }),
z.object({ type: z.literal('choose'), cardIds: z.tuple([z.number().int(), z.number().int()]) }),
z.object({ type: z.literal('open'), cardId: z.number().int() }),
z.object({ type: z.literal('rejoin'), accept: z.boolean() }),
z.object({ type: z.literal('ready') }),
z.object({ type: z.literal('rebuy'), accept: z.boolean() }),
@@ -193,7 +204,8 @@ export interface SeotdaHand {
handNo: number;
/** 0 = 본 판, 1.. = 재경기 차수. */
rematchNo: number;
phase: 'betting' | 'choose' | 'rejoin' | 'handEnd';
/** `open`: 3장 섯다 공개패 고르기 (before the first bet). */
phase: 'open' | 'betting' | 'choose' | 'rejoin' | 'handEnd';
dealer: PlayerId;
/** Participants of this (re)match, from the dealer clockwise. */
order: PlayerId[];
@@ -202,6 +214,8 @@ export interface SeotdaHand {
cards: Record<PlayerId, number[]>;
/** 3장 섯다: chosen pair (secret until showdown). */
chosen: Record<PlayerId, [number, number] | null>;
/** 3장 섯다 공개패: the card each player shows everyone (null = not yet). */
opened: Record<PlayerId, number | null>;
betting: BettingState | null;
street: 0 | 1;
/** Bet counter (deadline key). */
@@ -298,6 +312,8 @@ export interface SeotdaSeatView {
cards: CardSlot[];
/** 3장 섯다 choose phase: has chosen (null outside that phase). */
chosen: boolean | null;
/** 3장 섯다 공개패 phase: has picked the card to show (null outside that phase). */
opening: boolean | null;
isDealer: boolean;
isTurn: boolean;
ready: boolean;
@@ -333,6 +349,8 @@ export interface SeotdaView {
myHand: { name: string; value: number | null; special: SpecialKind | null; hint: string; strength: 'high' | 'mid' | 'low' | null } | null;
myCombos: { cardIds: [number, number]; name: string; value: number; best: boolean }[] | null;
myChosen: [number, number] | null;
/** 3장 섯다: the card I show everyone (공개패). */
myOpened: number | null;
myDiscard: SeotdaCardView | null;
rejoin: { pending: PlayerId[]; cost: number; mine: boolean; canAfford: boolean } | null;
rebuy: { pending: PlayerId[]; mine: boolean; left: number | null } | null;
@@ -489,6 +507,7 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
deck: rng.shuffle(deckOf(o)),
cards: Object.fromEntries(order.map((id) => [id, []])),
chosen: Object.fromEntries(order.map((id) => [id, null])),
opened: Object.fromEntries(order.map((id) => [id, null])),
betting: b,
street: 0,
betSeq: 0,
@@ -511,6 +530,15 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
events.push({ type: 'handStart', handNo: h.handNo, rematchNo: 0, dealer, ante: s.baseUnit });
deal(h, order, firstDealCount(o), events);
h.betting = startRound(b, 0);
if (opensFirst(o)) h.phase = 'open';
}
/** 3장 섯다 (한게임): 2장을 받으면 먼저 1장을 골라 모두에게 보여 준 뒤 첫 베팅. */
const opensFirst = (o: SeotdaOptions) => o.cardMode === 'three' && o.threeOpen;
/** Card shown when the player does not pick one (timeout, left, computer default): the lower month — the higher one stays hidden. */
export function autoOpen(cards: number[]): number {
return [...cards].sort((a, b) => HWATU[a]!.month - HWATU[b]!.month || a - b)[0]!;
}
function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
@@ -527,6 +555,7 @@ function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
h.deck = rng.shuffle(deckOf(s.options));
h.cards = Object.fromEntries(order.map((id) => [id, []]));
h.chosen = Object.fromEntries(order.map((id) => [id, null]));
h.opened = Object.fromEntries(order.map((id) => [id, null]));
h.showdown = null;
h.foldWin = null;
h.next = null;
@@ -546,6 +575,7 @@ function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
events.push({ type: 'handStart', handNo: h.handNo, rematchNo: h.rematchNo, dealer, ante: 0, reason: h.rematchReason });
deal(h, order, firstDealCount(s.options), events);
h.betting = startRound(b, 0);
if (opensFirst(s.options)) h.phase = 'open';
}
/** Pots of the current match: carried (re-filtered by who is still in) + this match's bets. */
@@ -838,6 +868,12 @@ function chooseFor(s: SeotdaState, id: PlayerId, pair: [number, number], events:
events.push({ type: 'chose', player: id });
}
function openFor(s: SeotdaState, id: PlayerId, card: number, events: GameEvent[]): void {
const h = s.hand!;
h.opened[id] = card;
events.push({ type: 'opened', player: id });
}
function requiredReady(s: SeotdaState): PlayerId[] {
return s.seats.filter((x) => x.status === 'playing' && !x.left).map((x) => x.id);
}
@@ -874,9 +910,19 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
settleFold(s, events);
continue;
}
// 3장 섯다: 2장 → 베팅 → 1장 더 → 3장 중 2장 몰래 고르기 → 마지막 베팅 → 공개.
// 3장 섯다(한게임): 2장 → 공개패 1장 → 1구 베팅 → 1장 더 → 2구 베팅 → 3장 중 2장 고르기 → 공개.
// threePick=beforeBet: 1장 더 → 2장 고르기 → 마지막 베팅 → 공개.
if (h.street === 0 && s.options.cardMode === 'three') {
deal(h, h.order.filter((id) => contendersOf(h).includes(id)), 1, events);
if (s.options.threePick === 'beforeBet') h.phase = 'choose';
else {
h.street = 1;
h.lastAction = {};
h.betting = startRound(h.betting, 0);
}
continue;
}
if (s.options.cardMode === 'three' && contendersOf(h).some((id) => !h.chosen[id])) {
h.phase = 'choose';
continue;
}
@@ -895,6 +941,8 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
for (const id of waiting) if (seatOf(s, id)!.left) chooseFor(s, id, bestChoice(h.cards[id]!, rulesOf(s.options)), events);
if (contendersOf(h).every((id) => h.chosen[id])) {
h.phase = 'betting';
// Chosen after the last bet (한게임): straight to the showdown (the betting round is already over).
if (h.street === 1) continue;
h.street = 1;
h.lastAction = {};
h.betting = startRound(h.betting!, 0);
@@ -902,6 +950,14 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
}
return;
}
case 'open': {
for (const id of contendersOf(h)) if (h.opened[id] === null && seatOf(s, id)!.left) openFor(s, id, autoOpen(h.cards[id]!), events);
if (contendersOf(h).every((id) => h.opened[id] !== null)) {
h.phase = 'betting';
continue;
}
return;
}
case 'rejoin': {
for (const id of [...h.rejoinPending]) if (seatOf(s, id)!.left) decideRejoin(s, id, false, events);
if (h.rejoinPending.length === 0) {
@@ -967,7 +1023,7 @@ function refreshDeadline(s: SeotdaState, now: number): void {
key += `|${id}|${h.betSeq}`;
// 시간 무제한 방에서도 자리 비움(연속 시간 초과)은 없으니 기다린다.
ms = o.turnSeconds === null ? null : seatOf(s, id)!.away ? AWAY_MS : o.turnSeconds * 1000;
} else if (h.phase === 'choose') ms = o.turnSeconds === null ? null : (o.turnSeconds + 10) * 1000;
} else if (h.phase === 'choose' || h.phase === 'open') ms = o.turnSeconds === null ? null : (o.turnSeconds + 10) * 1000;
else if (h.phase === 'rejoin') ms = o.decisionSeconds * 1000;
else if (h.phase === 'handEnd') ms = HAND_END_MS;
}
@@ -988,6 +1044,8 @@ function waiting(s: SeotdaState): PlayerId[] {
return h.betting?.turn != null ? [h.betting.players[h.betting.turn]!.id] : [];
case 'choose':
return contendersOf(h).filter((id) => !h.chosen[id]);
case 'open':
return contendersOf(h).filter((id) => h.opened[id] === null);
case 'rejoin':
return [...h.rejoinPending];
case 'handEnd':
@@ -1005,15 +1063,22 @@ function isBet(t: string): t is BetType {
*/
const MONEY_V1 = 1000;
function migrateSeotda(old: unknown, from: number): SeotdaState {
const s = structuredClone(old) as SeotdaState;
if (from >= 2) return s;
const o = s.options as SeotdaOptions & Record<string, unknown>;
s.options = { ...o, deck: 20, betRule: 'free', quarter: true } as SeotdaOptions;
if (s.hand) {
s.hand.forced = 0;
s.hand.log = [];
let s = structuredClone(old) as SeotdaState;
if (from < 2) {
const o = s.options as SeotdaOptions & Record<string, unknown>;
s.options = { ...o, deck: 20, betRule: 'free', quarter: true } as SeotdaOptions;
if (s.hand) {
s.hand.forced = 0;
s.hand.log = [];
}
s = scaleMoney(s, MONEY_V1);
}
return scaleMoney(s, MONEY_V1);
if (from < 3) {
// v2 → v3 (3장 섯다 공개패·최종 선택 시점): games in progress keep the old 3장 flow (no 공개패, choose before the last bet).
s.options = { ...s.options, threeOpen: false, threePick: 'beforeBet' };
if (s.hand) s.hand.opened = Object.fromEntries(s.hand.order.map((id) => [id, null]));
}
return s;
}
/** Multiplies every amount of a state by `k` (in place): options, stacks, pots, bets, history. Integers stay integers for k ≥ 1. */
@@ -1061,7 +1126,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
nameKo: '섯다',
minPlayers: 2,
maxPlayers: 10,
stateVersion: 2,
stateVersion: 3,
migrate: migrateSeotda,
defaultOptions: seotdaOptionsSchema.parse({}),
optionsSchema: seotdaOptionsSchema as unknown as z.ZodType<SeotdaOptions>,
@@ -1143,6 +1208,13 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
if (x === y || !mine.includes(x) || !mine.includes(y)) return fail('카드 두 장을 골라 주세요.');
return ok;
}
case 'open': {
if (h.phase !== 'open') return fail('지금은 공개할 패를 고를 때가 아니에요.');
if (!contendersOf(h).includes(actor)) return fail('이번 판에 남아 있지 않아요.');
if (h.opened[actor] !== null) return fail('이미 공개패를 골랐어요.');
if (!(h.cards[actor] ?? []).includes(a.cardId)) return fail('내 패 중에서 골라 주세요.');
return ok;
}
case 'rejoin': {
if (h.phase !== 'rejoin' || !h.rejoinPending.includes(actor)) return fail('재참가 대상이 아니에요.');
if (a.accept && st.stack < h.rejoinCost) return fail('보유 금액이 모자라 재참가할 수 없어요.');
@@ -1172,6 +1244,9 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
case 'choose':
chooseFor(s, actor, a.cardIds, events);
break;
case 'open':
openFor(s, actor, a.cardId, events);
break;
case 'rejoin':
decideRejoin(s, actor, a.accept, events);
break;
@@ -1188,7 +1263,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
break;
case 'timeout': {
const phase = s.phase === 'rebuy' ? 'rebuy' : h!.phase;
if (phase === 'betting' || phase === 'choose') {
if (phase === 'betting' || phase === 'choose' || phase === 'open') {
st.timeoutsInRow += 1;
if (st.timeoutsInRow >= 2 && !st.away) {
st.away = true;
@@ -1202,6 +1277,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
const t = toType(timeoutBet(b, idx).kind);
applyBetAction(s, actor, betsFor(s, h!, idx).some((l) => l.type === t) ? t : 'die', events);
} else if (phase === 'choose') chooseFor(s, actor, bestChoice(h!.cards[actor]!, rulesOf(s.options)), events);
else if (phase === 'open') openFor(s, actor, autoOpen(h!.cards[actor]!), events);
else if (phase === 'rejoin') decideRejoin(s, actor, false, events);
else if (phase === 'handEnd') h!.ready.push(actor);
else decideRebuy(s, actor, false, events);
@@ -1229,9 +1305,12 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
slots = pair.map((c) => cardView(h, c));
} else if (h && x.id === viewer) slots = cards.map((c) => cardView(h, c));
else {
// 3장 섯다 after choosing: others see two face-down cards (the discard stays secret).
const n = o.cardMode === 'three' && h?.chosen[x.id] ? 2 : cards.length;
slots = Array.from({ length: n }, () => ({ hidden: true as const }));
// 3장 섯다: the 공개패 is face up for everyone; after choosing, others see the two kept cards (the discard stays
// secret, so a 공개패 that was thrown away is no longer shown).
const shown = h?.opened[x.id] ?? null;
const chosen = o.cardMode === 'three' ? (h?.chosen[x.id] ?? null) : null;
const kept = chosen ? [...chosen] : cards;
slots = kept.map((c) => (c === shown ? cardView(h!, c) : { hidden: true as const }));
}
return {
id: x.id,
@@ -1247,6 +1326,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
matchBet: better?.total ?? 0,
cards: slots,
chosen: h?.phase === 'choose' && contendersOf(h).includes(x.id) ? !!h.chosen[x.id] : null,
opening: h?.phase === 'open' && contendersOf(h).includes(x.id) ? h.opened[x.id] !== null : null,
isDealer: h?.dealer === x.id,
isTurn: !!b && b.turn !== null && h?.phase === 'betting' && b.players[b.turn]!.id === x.id,
ready: !!h && h.phase === 'handEnd' && h.ready.includes(x.id),
@@ -1286,7 +1366,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
}
}
}
const pots: PotState[] = h ? (b && (h.phase === 'betting' || h.phase === 'choose') ? currentPots(h) : h.carried) : [];
const pots: PotState[] = h ? (b && (h.phase === 'betting' || h.phase === 'choose' || h.phase === 'open') ? currentPots(h) : h.carried) : [];
return {
options: o,
me,
@@ -1310,6 +1390,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
myHand,
myCombos,
myChosen,
myOpened: h && me ? (h.opened[me] ?? null) : null,
myDiscard,
rejoin:
h?.phase === 'rejoin'
@@ -1374,6 +1455,9 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
case 'choose':
if (!contendersOf(h).includes(p) || h.chosen[p]) return [];
return combos(h.cards[p]!).map((c) => ({ type: 'choose', cardIds: c }) as SeotdaAction);
case 'open':
if (!contendersOf(h).includes(p) || h.opened[p] !== null) return [];
return h.cards[p]!.map((c) => ({ type: 'open', cardId: c }) as SeotdaAction);
case 'rejoin':
if (!h.rejoinPending.includes(p)) return [];
return st.stack >= h.rejoinCost ? [{ type: 'rejoin', accept: true }, { type: 'rejoin', accept: false }] : [{ type: 'rejoin', accept: false }];
@@ -1387,6 +1471,8 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
const h = s.hand;
if (!h) return [];
const revealed = new Set(h.showdown?.hands.find((x) => x.id === player)?.cards ?? []);
const shown = h.opened?.[player];
if (shown !== null && shown !== undefined) revealed.add(shown);
const key = (c: number) => `h${h.handNo}r${h.rematchNo}c${c}`;
const own = (h.cards[player] ?? []).filter((c) => !revealed.has(c)).map(key);
return [...own, ...h.deck.map(key)];

View File

@@ -449,9 +449,9 @@ describe('재경기', () => {
});
});
describe('3장 섯다', () => {
describe('3장 섯다 (옵션: 공개패 없이, 마지막 베팅 전에 고르기)', () => {
function three() {
let s = make({ cardMode: 'three' });
let s = make({ cardMode: 'three', threeOpen: false, threePick: 'beforeBet' });
s = rig(s, { A: [S(1), S(8)], B: [P(5), P(6)], C: [P(2), P(7)] }, [S(4), P(9), P(10)]);
s = act(s, 'A', { type: 'check' });
s = act(s, 'B', { type: 'check' });
@@ -510,6 +510,76 @@ describe('3장 섯다', () => {
});
});
describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅 → 1장 더 → 2구 베팅 → 2장 고르기)', () => {
function opened() {
let s = make({ cardMode: 'three' });
s = rig(s, { A: [S(1), S(8)], B: [P(5), P(6)], C: [P(2), P(7)] }, [S(4), P(9), P(10)]);
return s;
}
test('2장을 받으면 먼저 모두 공개할 패 1장을 고르고, 고른 패는 모두에게 앞면으로 보여요', () => {
let s = opened();
expect(s.hand!.phase).toBe('open');
expect(s.hand!.cards.A).toHaveLength(2);
expect(seotda.activePlayers(s).sort()).toEqual(['A', 'B', 'C']);
expect(reject(s, 'A', { type: 'check' })).toBe('지금은 베팅 시간이 아니에요.');
expect(reject(s, 'A', { type: 'open', cardId: P(9) })).toBe('내 패 중에서 골라 주세요.');
s = act(s, 'A', { type: 'open', cardId: S(8) });
expect(reject(s, 'A', { type: 'open', cardId: S(1) })).toBe('이미 공개패를 골랐어요.');
const b = seotda.view(s, 'B');
expect(b.seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, expect.objectContaining({ id: S(8) })]);
expect(b.seats.find((x) => x.id === 'A')!.opening).toBe(true);
expect(b.seats.find((x) => x.id === 'C')!.opening).toBe(false);
expect(JSON.stringify(b)).not.toContain(`"id":${S(1)},`);
expect(seotda.secretsOf!(s, 'A')).not.toContain(`h1r0c${S(8)}`);
s = act(s, 'B', { type: 'open', cardId: P(6) });
s = act(s, 'C', { type: 'timeout' }); // 낮은 월(2월)을 보여 줘요
expect(s.hand!.opened.C).toBe(P(2));
expect(s.hand!.phase).toBe('betting');
expect(s.hand!.street).toBe(0);
expect(seotda.activePlayers(s)).toEqual(['A']);
});
test('1구 베팅 뒤 1장 더 받고 2구 베팅, 그다음 3장 중 2장을 골라 공개해요', () => {
let s = opened();
for (const [p, c] of [['A', S(8)], ['B', P(6)], ['C', P(7)]] as const) s = act(s, p, { type: 'open', cardId: c });
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'check' });
expect(s.hand!.phase).toBe('betting');
expect(s.hand!.street).toBe(1);
expect(s.hand!.cards.A).toEqual([S(1), S(8), S(4)]);
// The third card is hidden from the others; the 공개패 stays face up.
expect(seotda.view(s, 'C').seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, expect.objectContaining({ id: S(8) }), { hidden: true }]);
s = act(s, 'A', { type: 'half' });
s = act(s, 'B', { type: 'call' });
s = act(s, 'C', { type: 'die' });
expect(s.hand!.phase).toBe('choose');
expect(seotda.activePlayers(s).sort()).toEqual(['A', 'B']);
expect(seotda.view(s, 'A').myCombos!.find((c) => c.best)!.name).toBe('18광땡');
s = act(s, 'A', { type: 'choose', cardIds: [S(1), S(4)] }); // 공개패(8광)를 버리고 독사
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, { hidden: true }]);
s = act(s, 'B', { type: 'timeout' });
expect(s.hand!.phase).toBe('handEnd');
expect(s.hand!.showdown!.hands.find((x) => x.id === 'A')!.name).toBe('독사');
});
test('2구 베팅에서 한 사람만 남으면 고르기 없이 끝나요', () => {
let s = opened();
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'timeout' });
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'check' });
s = act(s, 'A', { type: 'half' });
s = act(s, 'B', { type: 'die' });
s = act(s, 'C', { type: 'die' });
expect(s.hand!.phase).toBe('handEnd');
expect(s.hand!.foldWin!.winner).toBe('A');
});
test('시간 무제한이면 공개패 고르기에도 마감이 없어요', () => {
const s = make({ turnSeconds: null, cardMode: 'three' });
expect(s.hand!.phase).toBe('open');
expect(s.deadlineAt).toBeNull();
});
});
describe('timeouts, away, leaving', () => {
test('timeout: check when nobody bet, otherwise die; two in a row → away with a 5 s limit', () => {
let s = make();
@@ -701,7 +771,7 @@ describe('한게임 방식 (원 단위, 기본 설정)', () => {
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'check' });
expect(s.hand!.phase).toBe('handEnd');
expect(s.deadlineAt).not.toBeNull();
const three = hg({ turnSeconds: null, cardMode: 'three' });
const three = hg({ turnSeconds: null, cardMode: 'three', threeOpen: false, threePick: 'beforeBet' });
let t = three;
for (const p of ['A', 'B', 'C']) t = act(t, p, { type: 'check' });
expect(t.hand!.phase).toBe('choose');
@@ -731,7 +801,8 @@ describe('한게임 방식 (원 단위, 기본 설정)', () => {
delete h.forced;
delete h.log;
const m = seotda.migrate!(v1, 1);
expect(seotda.stateVersion).toBe(2);
expect(seotda.stateVersion).toBe(3);
expect(m.options).toMatchObject({ threeOpen: false, threePick: 'beforeBet' });
expect([m.options.startingChips, m.options.baseUnit, m.baseUnit]).toEqual([1_000_000, 10_000, 10_000]);
expect(m.options).toMatchObject({ deck: 20, betRule: 'free', quarter: true });
expect(m.seats.map((x) => x.stack)).toEqual(s.seats.map((x) => x.stack * 1000));