섯다·포커: 다른 사람이 모두 죽고 혼자 남으면 카드를 공개할지 고르기(카드 공개/공개 안 함, 시간 초과·나감·기본은 공개 안 함, 공개하면 모두에게 패와 족보를 뒤집어 보여 주고 기록에 남김, 컴퓨터도 센 패면 가끔 공개)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -151,6 +151,22 @@ describe('seotda bot', () => {
|
||||
expect(decide(s, 'A')).toEqual({ type: 'open', cardId: P(5) });
|
||||
});
|
||||
|
||||
test('혼자 남으면: 약한 패는 공개하지 않고, 땡 이상은 가끔 공개해요', () => {
|
||||
const lone = (a: number[]) => {
|
||||
let s = rig(make(), { A: a, B: [P(5), P(6)], C: [P(2), P(7)] });
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
return s;
|
||||
};
|
||||
const weak = lone([P(2), P(3)]);
|
||||
for (const r of [0.05, 0.5, 0.95]) expect(decide(weak, 'A', r)).toEqual({ type: 'reveal', show: false });
|
||||
const strong = lone([S(3), S(8)]);
|
||||
expect(decide(strong, 'A', 0.1)).toEqual({ type: 'reveal', show: true });
|
||||
expect(decide(strong, 'A', 0.9)).toEqual({ type: 'reveal', show: false });
|
||||
});
|
||||
|
||||
test('3장 섯다: keeps the best pair of its three cards', () => {
|
||||
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)]);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
import type { BotStrategy } from '../bots/types';
|
||||
import { humanBest, pick, typeOf } from '../bots/policy';
|
||||
import type { HandRules } from './hands';
|
||||
import { bestChoice, evalSeotda, type HandRules } from './hands';
|
||||
import { deckOf, type BetType, type SeotdaAction, type SeotdaView } from './index';
|
||||
import { cardsKey, odds, strengthPercentile, type Odds, type RangeWeight } from './odds';
|
||||
|
||||
@@ -204,6 +204,13 @@ 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 'reveal': {
|
||||
// Everyone else died: usually keep the cards hidden; now and then show off a 땡 or better.
|
||||
const cards = myCardsOf(v, me);
|
||||
const pair = v.myChosen ?? (cards.length === 3 ? bestChoice(cards, rules) : cards.length === 2 ? (cards as [number, number]) : null);
|
||||
const strong = !!pair && evalSeotda(pair[0], pair[1], rules).value >= 901;
|
||||
return { type: 'reveal', show: strong && random() < 0.5 };
|
||||
}
|
||||
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');
|
||||
|
||||
@@ -130,7 +130,7 @@ export const seotdaOptionsSchema = z
|
||||
.meta({ title: '한 판의 재경기 최대 횟수(넘으면 나눠 가짐)', labels: { 1: '1번', 2: '2번', 3: '3번', 5: '5번' } }),
|
||||
decisionSeconds: lit(10, 15, 30)
|
||||
.default(15)
|
||||
.meta({ title: '재참가·리바이 답 시간', labels: { 10: '10초', 15: '15초', 30: '30초' } }),
|
||||
.meta({ title: '재참가·리바이·카드 공개 답 시간', labels: { 10: '10초', 15: '15초', 30: '30초' } }),
|
||||
})
|
||||
.superRefine((o, ctx) => {
|
||||
if (o.baseUnit * 20 > o.startingChips) {
|
||||
@@ -151,6 +151,7 @@ export const seotdaActionSchema = z.discriminatedUnion('type', [
|
||||
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('reveal'), show: z.boolean() }),
|
||||
z.object({ type: z.literal('ready') }),
|
||||
z.object({ type: z.literal('rebuy'), accept: z.boolean() }),
|
||||
]);
|
||||
@@ -204,8 +205,11 @@ export interface SeotdaHand {
|
||||
handNo: number;
|
||||
/** 0 = 본 판, 1.. = 재경기 차수. */
|
||||
rematchNo: number;
|
||||
/** `open`: 3장 섯다 공개패 고르기 (before the first bet). */
|
||||
phase: 'open' | 'betting' | 'choose' | 'rejoin' | 'handEnd';
|
||||
/**
|
||||
* `open`: 3장 섯다 공개패 고르기 (before the first bet). `reveal`: everyone else died — the last player decides whether
|
||||
* to show the cards before taking the pot.
|
||||
*/
|
||||
phase: 'open' | 'betting' | 'choose' | 'reveal' | 'rejoin' | 'handEnd';
|
||||
dealer: PlayerId;
|
||||
/** Participants of this (re)match, from the dealer clockwise. */
|
||||
order: PlayerId[];
|
||||
@@ -229,7 +233,8 @@ export interface SeotdaHand {
|
||||
rejoinCost: number;
|
||||
rejoined: PlayerId[];
|
||||
showdown: { hands: ShowdownHand[]; pots: PotOutcome[] } | null;
|
||||
foldWin: { winner: PlayerId; amount: number } | null;
|
||||
/** `shown`: the winner showed the cards (absent before 2026-10-14 = not shown). */
|
||||
foldWin: { winner: PlayerId; amount: number; shown?: boolean } | null;
|
||||
next: 'rematch' | 'nextHand' | null;
|
||||
ready: PlayerId[];
|
||||
lastAction: Record<PlayerId, { type: BetType; amount: number }>;
|
||||
@@ -253,6 +258,8 @@ export interface HandRecord {
|
||||
amount: number;
|
||||
name: string | null;
|
||||
how: PotOutcome['reason'] | 'rematch';
|
||||
/** Fold win: the winner showed the cards. */
|
||||
shown?: boolean;
|
||||
}
|
||||
|
||||
export interface SeotdaFinal {
|
||||
@@ -318,7 +325,7 @@ export interface SeotdaSeatView {
|
||||
isTurn: boolean;
|
||||
ready: boolean;
|
||||
lastAction: { type: BetType; amount: number } | null;
|
||||
/** Shown after showdown only. */
|
||||
/** Shown after showdown only (or when a fold winner showed the cards). */
|
||||
handName: string | null;
|
||||
/** Money won or lost in the finished hand (result screen only). */
|
||||
handDelta: number | null;
|
||||
@@ -353,6 +360,8 @@ export interface SeotdaView {
|
||||
myOpened: number | null;
|
||||
myDiscard: SeotdaCardView | null;
|
||||
rejoin: { pending: PlayerId[]; cost: number; mine: boolean; canAfford: boolean } | null;
|
||||
/** Everyone else died: `by` decides whether to show the cards. */
|
||||
reveal: { by: PlayerId; mine: boolean } | null;
|
||||
rebuy: { pending: PlayerId[]; mine: boolean; left: number | null } | null;
|
||||
showdown: { hands: (Omit<ShowdownHand, 'cards'> & { cards: SeotdaCardView[] })[]; pots: PotOutcome[] } | null;
|
||||
foldWin: SeotdaHand['foldWin'];
|
||||
@@ -627,7 +636,19 @@ function enterHandEnd(s: SeotdaState): void {
|
||||
h.ready = [];
|
||||
}
|
||||
|
||||
function settleFold(s: SeotdaState, events: GameEvent[]): void {
|
||||
/** Cards a fold winner shows: the chosen pair (3장 섯다, the discard stays secret), else every card in hand. */
|
||||
const foldCards = (h: SeotdaHand, id: PlayerId): number[] => h.chosen[id] ?? h.cards[id] ?? [];
|
||||
|
||||
/** 족보 of the cards a fold winner showed (best pair of three; none for a single card). */
|
||||
function foldHandName(h: SeotdaHand, id: PlayerId, rules: HandRules): string | null {
|
||||
const cs = foldCards(h, id);
|
||||
if (cs.length < 2) return null;
|
||||
const pair = cs.length === 2 ? (cs as [number, number]) : bestChoice(cs, rules);
|
||||
return evalSeotda(pair[0], pair[1], rules).name;
|
||||
}
|
||||
|
||||
/** `shown`: the winner chose to show the cards (reveal phase). */
|
||||
function settleFold(s: SeotdaState, events: GameEvent[], shown: boolean): void {
|
||||
const h = s.hand!;
|
||||
const winner = contendersOf(h)[0] ?? h.order[0]!;
|
||||
const amount = carriedTotal(h) + livePot(h);
|
||||
@@ -635,12 +656,13 @@ function settleFold(s: SeotdaState, events: GameEvent[]): void {
|
||||
clearBetting(s);
|
||||
pay(s, { [winner]: amount });
|
||||
syncBackStacks(s);
|
||||
h.foldWin = { winner, amount };
|
||||
h.foldWin = { winner, amount, shown };
|
||||
h.next = 'nextHand';
|
||||
s.lastWinner = winner;
|
||||
noteBiggest(s, h.handNo, amount, [winner]);
|
||||
pushHistory(s, { handNo: h.handNo, rematchNo: h.rematchNo, winners: [winner], amount, name: null, how: 'fold' });
|
||||
events.push({ type: 'foldWin', winner, amount });
|
||||
const name = shown ? foldHandName(h, winner, rulesOf(s.options)) : null;
|
||||
pushHistory(s, { handNo: h.handNo, rematchNo: h.rematchNo, winners: [winner], amount, name, how: 'fold', shown });
|
||||
events.push({ type: 'foldWin', winner, amount, shown });
|
||||
enterHandEnd(s);
|
||||
}
|
||||
|
||||
@@ -907,7 +929,10 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
h.betting = withoutCarry(b, (core) => returnUncalled(core).state);
|
||||
syncStacks(s);
|
||||
if (handDecided(h.betting)) {
|
||||
settleFold(s, events);
|
||||
// One player left and someone still at the table: they decide whether to show the cards first.
|
||||
const lone = contendersOf(h);
|
||||
if (lone.length === 1 && s.seats.some((x) => x.id !== lone[0] && !x.left && x.status !== 'eliminated')) h.phase = 'reveal';
|
||||
else settleFold(s, events, false);
|
||||
continue;
|
||||
}
|
||||
// 3장 섯다(한게임): 2장 → 공개패 1장 → 1구 베팅 → 1장 더 → 2구 베팅 → 3장 중 2장 고르기 → 공개.
|
||||
@@ -958,6 +983,13 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 'reveal': {
|
||||
if (seatOf(s, contendersOf(h)[0]!)!.left) {
|
||||
settleFold(s, events, false);
|
||||
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) {
|
||||
@@ -1025,6 +1057,7 @@ function refreshDeadline(s: SeotdaState, now: number): void {
|
||||
ms = o.turnSeconds === null ? null : seatOf(s, id)!.away ? AWAY_MS : o.turnSeconds * 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 === 'reveal') ms = seatOf(s, contendersOf(h)[0]!)!.away ? AWAY_MS : o.decisionSeconds * 1000;
|
||||
else if (h.phase === 'handEnd') ms = HAND_END_MS;
|
||||
}
|
||||
if (key !== s.waitKey) {
|
||||
@@ -1046,6 +1079,8 @@ function waiting(s: SeotdaState): PlayerId[] {
|
||||
return contendersOf(h).filter((id) => !h.chosen[id]);
|
||||
case 'open':
|
||||
return contendersOf(h).filter((id) => h.opened[id] === null);
|
||||
case 'reveal':
|
||||
return contendersOf(h);
|
||||
case 'rejoin':
|
||||
return [...h.rejoinPending];
|
||||
case 'handEnd':
|
||||
@@ -1215,6 +1250,10 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
if (!(h.cards[actor] ?? []).includes(a.cardId)) return fail('내 패 중에서 골라 주세요.');
|
||||
return ok;
|
||||
}
|
||||
case 'reveal': {
|
||||
if (h.phase !== 'reveal' || !contendersOf(h).includes(actor)) 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('보유 금액이 모자라 재참가할 수 없어요.');
|
||||
@@ -1247,6 +1286,9 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
case 'open':
|
||||
openFor(s, actor, a.cardId, events);
|
||||
break;
|
||||
case 'reveal':
|
||||
settleFold(s, events, a.show);
|
||||
break;
|
||||
case 'rejoin':
|
||||
decideRejoin(s, actor, a.accept, events);
|
||||
break;
|
||||
@@ -1278,6 +1320,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
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 === 'reveal') settleFold(s, events, false);
|
||||
else if (phase === 'rejoin') decideRejoin(s, actor, false, events);
|
||||
else if (phase === 'handEnd') h!.ready.push(actor);
|
||||
else decideRebuy(s, actor, false, events);
|
||||
@@ -1295,6 +1338,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
const rules = rulesOf(o);
|
||||
const b = h?.betting ?? null;
|
||||
const showdownIds = new Set(h?.showdown?.hands.map((x) => x.id) ?? []);
|
||||
const foldShown = h?.foldWin?.shown ? h.foldWin.winner : null;
|
||||
const seats: SeotdaSeatView[] = s.seats.map((x) => {
|
||||
const better = b?.players.find((p) => p.id === x.id) ?? null;
|
||||
const inHand = !!h && h.order.includes(x.id);
|
||||
@@ -1303,7 +1347,8 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
if (h && showdownIds.has(x.id)) {
|
||||
const pair = h.showdown!.hands.find((y) => y.id === x.id)!.cards;
|
||||
slots = pair.map((c) => cardView(h, c));
|
||||
} else if (h && x.id === viewer) slots = cards.map((c) => cardView(h, c));
|
||||
} else if (h && x.id === foldShown) slots = foldCards(h, x.id).map((c) => cardView(h, c));
|
||||
else if (h && x.id === viewer) slots = cards.map((c) => cardView(h, c));
|
||||
else {
|
||||
// 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).
|
||||
@@ -1331,7 +1376,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
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),
|
||||
lastAction: h?.lastAction[x.id] ?? null,
|
||||
handName: h?.showdown?.hands.find((y) => y.id === x.id)?.name ?? null,
|
||||
handName: h?.showdown?.hands.find((y) => y.id === x.id)?.name ?? (h && x.id === foldShown ? foldHandName(h, x.id, rules) : null),
|
||||
handDelta: h?.phase === 'handEnd' && h.next === 'nextHand' && inHand ? x.stack - x.stackAtHandStart : null,
|
||||
};
|
||||
});
|
||||
@@ -1396,6 +1441,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
h?.phase === 'rejoin'
|
||||
? { pending: h.rejoinPending, cost: h.rejoinCost, mine: !!me && h.rejoinPending.includes(me), canAfford: !!me && seatOf(s, me)!.stack >= h.rejoinCost }
|
||||
: null,
|
||||
reveal: h?.phase === 'reveal' ? { by: contendersOf(h)[0]!, mine: !!me && contendersOf(h)[0] === me } : null,
|
||||
rebuy:
|
||||
s.phase === 'rebuy'
|
||||
? {
|
||||
@@ -1458,6 +1504,8 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
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 'reveal':
|
||||
return contendersOf(h).includes(p) ? [{ type: 'reveal', show: true }, { type: 'reveal', show: false }] : [];
|
||||
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 }];
|
||||
@@ -1473,6 +1521,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
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);
|
||||
if (h.foldWin?.shown && h.foldWin.winner === player) for (const c of foldCards(h, player)) revealed.add(c);
|
||||
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)];
|
||||
|
||||
@@ -76,6 +76,11 @@ const reject = (s: SeotdaState, p: string, a: SeotdaAction) => {
|
||||
const v = seotda.validate(s, p, a);
|
||||
return v.ok ? null : v.reason;
|
||||
};
|
||||
/** Everyone dies until the hand ends; the last player keeps the cards hidden. */
|
||||
function foldOut(s: SeotdaState): SeotdaState {
|
||||
while (s.hand!.phase !== 'handEnd') s = act(s, seotda.activePlayers(s)[0]!, s.hand!.phase === 'reveal' ? { type: 'reveal', show: false } : { type: 'die' });
|
||||
return s;
|
||||
}
|
||||
function readyAll(s: SeotdaState): SeotdaState {
|
||||
for (const p of seotda.activePlayers(s)) s = act(s, p, { type: 'ready' });
|
||||
return s;
|
||||
@@ -291,12 +296,14 @@ describe('betting flow', () => {
|
||||
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.handName).toBe('장땡');
|
||||
});
|
||||
|
||||
test('fold to one: winner takes the pot (uncalled bet back), no cards revealed', () => {
|
||||
test('fold to one: winner keeps the cards hidden and takes the pot (uncalled bet back)', () => {
|
||||
let s = make({ dealMode: 'oneRound' });
|
||||
s = act(s, 'A', { type: 'half' }); // 15
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
expect(s.hand!.foldWin).toEqual({ winner: 'A', amount: 30 }); // A's uncalled 15 came back first
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
s = act(s, 'A', { type: 'reveal', show: false });
|
||||
expect(s.hand!.foldWin).toEqual({ winner: 'A', amount: 30, shown: false }); // A's uncalled 15 came back first
|
||||
expect(stack(s, 'A')).toBe(1020);
|
||||
expect(s.hand!.showdown).toBeNull();
|
||||
const bView = seotda.view(s, 'B');
|
||||
@@ -311,6 +318,7 @@ describe('betting flow', () => {
|
||||
let s = make({ dealMode: 'oneRound', dealerRule: 'rotate' });
|
||||
s = act(s, 'A', { type: 'die' });
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'reveal', show: false });
|
||||
s = readyAll(s);
|
||||
expect(s.hand!.dealer).toBe('B');
|
||||
});
|
||||
@@ -337,6 +345,103 @@ describe('betting flow', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('모두 다이하고 혼자 남으면 카드 공개를 골라요', () => {
|
||||
/** A 38광땡 bets 하프, B and C die: A decides. */
|
||||
function lone(opts: OldOpts = {}): SeotdaState {
|
||||
let s = make({ dealMode: 'oneRound', ...opts });
|
||||
s = rig(s, { A: [S(3), S(8)], B: [P(5), P(6)], C: [P(2), P(7)] });
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
return s;
|
||||
}
|
||||
const cardsOf = (s: SeotdaState, viewer: string | null, id = 'A') => seotda.view(s, viewer).seats.find((x) => x.id === id)!.cards;
|
||||
|
||||
test('only the last player decides; the pot waits until then', () => {
|
||||
const s = lone();
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
expect(seotda.activePlayers(s)).toEqual(['A']);
|
||||
expect(seotda.legalActions!(s, 'A')).toEqual([{ type: 'reveal', show: true }, { type: 'reveal', show: false }]);
|
||||
expect(seotda.legalActions!(s, 'B')).toEqual([]);
|
||||
expect(reject(s, 'B', { type: 'reveal', show: true })).toBe('지금은 카드 공개를 고를 때가 아니에요.');
|
||||
expect(reject(s, 'A', { type: 'ready' })).toBe('아직 판이 끝나지 않았어요.');
|
||||
expect(reject(make(), 'A', { type: 'reveal', show: true })).toBe('지금은 카드 공개를 고를 때가 아니에요.');
|
||||
expect(s.hand!.foldWin).toBeNull();
|
||||
expect(stack(s, 'A')).toBe(990); // uncalled 하프 back, pot not paid yet
|
||||
expect(chipsTotal(s)).toBe(total(s));
|
||||
const v = seotda.view(s, 'B');
|
||||
expect(v.reveal).toEqual({ by: 'A', mine: false });
|
||||
expect(seotda.view(s, 'A').reveal).toEqual({ by: 'A', mine: true });
|
||||
expect(v.pot).toBe(30);
|
||||
expect(cardsOf(s, 'B')).toEqual([{ hidden: true }, { hidden: true }]);
|
||||
});
|
||||
|
||||
test('show: everyone (spectators too) sees the cards and the 족보, and the record says so', () => {
|
||||
const r = actE(lone(), 'A', { type: 'reveal', show: true });
|
||||
const s = r.state;
|
||||
expect(r.events).toContainEqual({ type: 'foldWin', winner: 'A', amount: 30, shown: true });
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect(stack(s, 'A')).toBe(1020);
|
||||
for (const viewer of ['B', 'C', null]) {
|
||||
expect(cardsOf(s, viewer).map((c) => ('id' in c ? c.id : null))).toEqual([S(3), S(8)]);
|
||||
expect(seotda.view(s, viewer).seats.find((x) => x.id === 'A')!.handName).toBe('38광땡');
|
||||
}
|
||||
expect(cardsOf(s, 'C', 'B')).toEqual([{ hidden: true }, { hidden: true }]);
|
||||
expect(seotda.view(s, null).foldWin).toEqual({ winner: 'A', amount: 30, shown: true });
|
||||
expect(s.history.at(-1)).toMatchObject({ how: 'fold', shown: true, name: '38광땡' });
|
||||
expect(seotda.secretsOf!(s, 'A')).not.toContain(`h1r0c${S(3)}`);
|
||||
});
|
||||
|
||||
test('hide: nobody else sees the cards, as before', () => {
|
||||
const s = act(lone(), 'A', { type: 'reveal', show: false });
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect(s.hand!.foldWin).toEqual({ winner: 'A', amount: 30, shown: false });
|
||||
for (const viewer of ['B', 'C', null]) {
|
||||
expect(cardsOf(s, viewer)).toEqual([{ hidden: true }, { hidden: true }]);
|
||||
expect(seotda.view(s, viewer).seats.find((x) => x.id === 'A')!.handName).toBeNull();
|
||||
expect(JSON.stringify(seotda.view(s, viewer))).not.toContain(`h1r0c${S(3)}`);
|
||||
}
|
||||
expect(seotda.secretsOf!(s, 'A')).toContain(`h1r0c${S(3)}`);
|
||||
expect(s.history.at(-1)).toMatchObject({ how: 'fold', shown: false, name: null });
|
||||
});
|
||||
|
||||
test('time runs out (재참가·리바이·카드 공개 답 시간) or the player leaves: cards stay hidden', () => {
|
||||
let s = lone();
|
||||
expect(s.deadlineAt).toBe(clock + 15_000);
|
||||
expect(seotda.timeoutPlayers!(s)).toEqual(['A']);
|
||||
s = act(s, 'A', { type: 'timeout' });
|
||||
expect(s.hand!.foldWin!.shown).toBe(false);
|
||||
expect(s.seats[0]!.timeoutsInRow).toBe(0); // not a missed turn
|
||||
expect(cardsOf(s, 'B')).toEqual([{ hidden: true }, { hidden: true }]);
|
||||
const t = act(lone(), 'A', seotda.onLeave!(lone(), 'A')!);
|
||||
expect(t.hand!.phase).toBe('handEnd');
|
||||
expect(t.hand!.foldWin!.shown).toBe(false);
|
||||
});
|
||||
|
||||
test('3장 섯다 after choosing: the chosen pair is shown, the thrown card stays secret', () => {
|
||||
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)] }, [P(3), P(9), P(10)]);
|
||||
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'check' });
|
||||
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'timeout' }); // best pairs
|
||||
expect(s.hand!.chosen.A).toEqual([S(1), S(8)]);
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
s = act(s, 'A', { type: 'reveal', show: true });
|
||||
expect(cardsOf(s, 'B').map((c) => ('id' in c ? c.id : null))).toEqual([S(1), S(8)]);
|
||||
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.handName).toBe('18광땡');
|
||||
expect(JSON.stringify(seotda.view(s, 'B'))).not.toContain(`"id":${P(3)},`);
|
||||
expect(seotda.secretsOf!(s, 'A')).toContain(`h1r0c${P(3)}`);
|
||||
});
|
||||
|
||||
test('a saved fold win from before this choice (no `shown`) stays hidden', () => {
|
||||
const s = act(lone(), 'A', { type: 'reveal', show: true });
|
||||
delete s.hand!.foldWin!.shown;
|
||||
expect(cardsOf(s, 'B')).toEqual([{ hidden: true }, { hidden: true }]);
|
||||
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.handName).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('재경기', () => {
|
||||
test('구사 재경기: 모인 칩 유지, 학교 재징수 없음, 쇼다운 생존자만', () => {
|
||||
let s = make({ dealMode: 'oneRound' });
|
||||
@@ -569,8 +674,15 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
expect(s.hand!.chosen.A).toBeNull();
|
||||
s = act(s, 'A', { type: 'reveal', show: true });
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect(s.hand!.foldWin!.winner).toBe('A');
|
||||
// Not chosen yet: the three cards are shown, named by their best pair (1·8 광 → 18광땡).
|
||||
const c = seotda.view(s, 'C').seats.find((x) => x.id === 'A')!;
|
||||
expect(c.cards.map((x) => ('id' in x ? x.id : null))).toEqual([S(1), S(8), S(4)]);
|
||||
expect(c.handName).toBe('18광땡');
|
||||
});
|
||||
|
||||
test('시간 무제한이면 공개패 고르기에도 마감이 없어요', () => {
|
||||
@@ -593,6 +705,7 @@ describe('timeouts, away, leaving', () => {
|
||||
s = act(s, 'A', { type: 'timeout' }, 64_000);
|
||||
expect(s.hand!.lastAction.A!.type).toBe('die');
|
||||
expect(s.seats[0]!.away).toBe(true);
|
||||
s = act(s, 'B', { type: 'reveal', show: false }, 65_000);
|
||||
// Next hand (result screen times out): A is away → 5 s limit on A's turn; a real action clears it.
|
||||
for (const p of seotda.activePlayers(s)) s = act(s, p, { type: 'timeout' }, 70_000);
|
||||
const h = s.hand!;
|
||||
@@ -624,7 +737,7 @@ describe('timeouts, away, leaving', () => {
|
||||
expect(s.hand!.betting!.players.find((p) => p.id === 'B')!.status).toBe('folded');
|
||||
expect(seotda.activePlayers(s)).toEqual(['C']);
|
||||
s = act(s, 'C', { type: 'leave' });
|
||||
expect(s.hand!.foldWin!.winner).toBe('A');
|
||||
expect(s.hand!.foldWin).toEqual({ winner: 'A', amount: 30, shown: false }); // nobody left to show the cards to
|
||||
s = readyAll(s);
|
||||
expect(s.phase).toBe('finished');
|
||||
const r = seotda.result(s)!;
|
||||
@@ -637,7 +750,7 @@ describe('rebuy, elimination, scores', () => {
|
||||
/** Ends the current hand by folds, then sets stacks before the hand-end processing. */
|
||||
function toHandEnd(opts: OldOpts, players = ['A', 'B', 'C']): SeotdaState {
|
||||
let s = make({ dealMode: 'oneRound', ...opts }, players);
|
||||
while (s.hand!.phase !== 'handEnd') s = act(s, seotda.activePlayers(s)[0]!, { type: 'die' });
|
||||
s = foldOut(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -653,7 +766,7 @@ describe('rebuy, elimination, scores', () => {
|
||||
expect([s.phase, stack(s, 'B'), s.seats[1]!.rebuys]).toEqual(['playing', 990, 1]); // refilled, then paid the next 학교
|
||||
expect(chipsTotal(s)).toBe(total(s));
|
||||
// Last hand: no rebuy question, the game ends.
|
||||
while (s.hand!.phase !== 'handEnd') s = act(s, seotda.activePlayers(s)[0]!, { type: 'die' });
|
||||
s = foldOut(s);
|
||||
s.handsPlayed = 9;
|
||||
s = readyAll(s);
|
||||
expect(s.phase).toBe('finished');
|
||||
@@ -697,7 +810,7 @@ describe('rebuy, elimination, scores', () => {
|
||||
test('학교 doubles every N hands (capped at startingChips / 5)', () => {
|
||||
let s = make({ dealMode: 'oneRound', schoolUpEvery: 5, startingChips: 500, baseUnit: 20 });
|
||||
for (let i = 0; i < 10; i++) {
|
||||
while (s.hand!.phase !== 'handEnd') s = act(s, seotda.activePlayers(s)[0]!, { type: 'die' });
|
||||
s = foldOut(s);
|
||||
s = readyAll(s);
|
||||
}
|
||||
expect(s.baseUnit).toBe(80);
|
||||
@@ -783,8 +896,9 @@ describe('한게임 방식 (원 단위, 기본 설정)', () => {
|
||||
s = act(s, 'A', { type: 'half' }); // 1만 5천원
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
s = act(s, 'A', { type: 'reveal', show: false });
|
||||
const v = seotda.view(s, null);
|
||||
expect(v.foldWin).toEqual({ winner: 'A', amount: 30_000 });
|
||||
expect(v.foldWin).toEqual({ winner: 'A', amount: 30_000, shown: false });
|
||||
expect(v.seats.map((x) => x.handDelta)).toEqual([20_000, -10_000, -10_000]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user