섯다·포커: 다른 사람이 모두 죽고 혼자 남으면 카드를 공개할지 고르기(카드 공개/공개 안 함, 시간 초과·나감·기본은 공개 안 함, 공개하면 모두에게 패와 족보를 뒤집어 보여 주고 기록에 남김, 컴퓨터도 센 패면 가끔 공개)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,21 @@ describe('poker bot', () => {
|
||||
expect(decide(s, 'A', 0.9).type).toBe('nl.fold');
|
||||
});
|
||||
|
||||
test('everyone else folded: shows a monster now and then, never a weak hand', () => {
|
||||
const lone = (deck: string) => {
|
||||
let s = mk({ mode: 'holdem', baseUnit: 10 }, 3, deckOf(deck));
|
||||
s = act(s, 'C', { type: 'nl.fold' });
|
||||
s = act(s, 'A', { type: 'nl.fold' });
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
return s;
|
||||
};
|
||||
const weak = lone('7D 3S AS 2C 8H AH'); // B: 3♠ 8♥
|
||||
for (const r of [0.05, 0.5, 0.95]) expect(decide(weak, 'B', r)).toEqual({ type: 'reveal', show: false });
|
||||
const aces = lone('7D AS 9S 2C AH 9H'); // B: A♠ A♥
|
||||
expect(decide(aces, 'B', 0.1)).toEqual({ type: 'reveal', show: true });
|
||||
expect(decide(aces, 'B', 0.9)).toEqual({ type: 'reveal', show: false });
|
||||
});
|
||||
|
||||
test('7포커 초이스: keeps the pair and opens the other card', () => {
|
||||
// order A B C, four cards each round-robin → A: K♠ 2♣ 9♦ K♥.
|
||||
const s = mk({ mode: 'sevenPoker' }, 3, deckOf('KS 3C 4D 2C 5S 6H 9D 7C 8S KH TC JD'));
|
||||
|
||||
@@ -224,6 +224,8 @@ export const pokerBot: BotStrategy<PokerView, PokerAction> = ({ me, view, legal,
|
||||
return top;
|
||||
}
|
||||
const { s, low } = strength(view, seat);
|
||||
// Everyone else folded: usually keep the cards hidden; now and then show off a strong hand.
|
||||
if (t === 'reveal') return { type: 'reveal', show: s >= 0.8 && random() < 0.5 };
|
||||
if (t === 'declare') {
|
||||
const high = korStrength(bestKorean([...known(seat.hole), ...known(seat.up)]));
|
||||
const side = low?.made && high >= 0.84 && low.s >= 0.75 ? 'swing' : low?.made && low.s > high ? 'low' : 'high';
|
||||
|
||||
@@ -194,7 +194,7 @@ export function advance(s: PokerState, ctx: Ctx): void {
|
||||
const plan = planFor(s.options);
|
||||
for (let guard = 0; guard < 64; guard++) {
|
||||
const h = s.hand!;
|
||||
if (h.settled) return;
|
||||
if (h.settled || h.phase === 'reveal') return;
|
||||
if (handDecided(h.bet)) return settleFold(s, ctx);
|
||||
if (h.waiting) {
|
||||
if (!stepComplete(h, plan[h.step]!)) return;
|
||||
@@ -448,6 +448,29 @@ function settleFold(s: PokerState, ctx: Ctx): void {
|
||||
const h = s.hand!;
|
||||
h.bet = returnUncalled(h.bet).state;
|
||||
const cs = contenderIds(h);
|
||||
// One player left with hidden cards and someone still at the table: they decide whether to show the cards first
|
||||
// (인디언 shows every card at the end anyway).
|
||||
const watched = s.seats.some((x) => x.id !== cs[0] && x.status !== 'left' && x.status !== 'eliminated');
|
||||
if (cs.length === 1 && watched && s.options.mode !== 'indian' && h.players[cs[0]!]!.hole.length > 0) {
|
||||
h.phase = 'reveal';
|
||||
h.waiting = true;
|
||||
return;
|
||||
}
|
||||
payFold(s, ctx);
|
||||
}
|
||||
|
||||
/** The last player's answer in the reveal phase, then the payout. */
|
||||
export function decideReveal(s: PokerState, ctx: Ctx, show: boolean): void {
|
||||
const h = s.hand!;
|
||||
const w = contenderIds(h)[0]!;
|
||||
h.foldShown = show;
|
||||
log(s, w, show ? `패를 공개했어요 · ${evaluate(s.options, h.players[w]!, h.board).high.name}` : '패를 공개하지 않았어요');
|
||||
payFold(s, ctx);
|
||||
}
|
||||
|
||||
function payFold(s: PokerState, ctx: Ctx): void {
|
||||
const h = s.hand!;
|
||||
const cs = contenderIds(h);
|
||||
const total = potTotal(h.bet);
|
||||
const penalty = h.penalties.reduce((a, p) => a + p.amount, 0);
|
||||
h.potTotal = total + s.carryOver + penalty;
|
||||
@@ -725,6 +748,8 @@ export function waitingFor(s: PokerState): PlayerId[] {
|
||||
return cs.filter((id) => h.players[id]!.drawPending === null);
|
||||
case 'declare':
|
||||
return cs.filter((id) => !h.players[id]!.declare);
|
||||
case 'reveal':
|
||||
return cs;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -758,6 +783,10 @@ export function deadlineWindow(s: PokerState): number {
|
||||
if (isAway(h.order[h.bet.turn]!)) return o.awaySeconds * 1000;
|
||||
return o.turnSeconds === null ? 0 : o.turnSeconds * 1000;
|
||||
}
|
||||
case 'reveal':
|
||||
// Same clock as a betting turn of that player.
|
||||
if (waitingFor(s).every(isAway)) return o.awaySeconds * 1000;
|
||||
return o.turnSeconds === null ? 0 : o.turnSeconds * 1000;
|
||||
case 'choice':
|
||||
case 'draw':
|
||||
case 'declare':
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
chipsOnTable,
|
||||
closeHand,
|
||||
decideRebuy,
|
||||
decideReveal,
|
||||
deadlineSig,
|
||||
doBet,
|
||||
finishGame,
|
||||
@@ -194,6 +195,9 @@ function validate(s: PokerState, actor: PlayerId, a: PokerAction): Validation {
|
||||
if (h.phase !== 'declare' || !h.waiting) return fail('지금은 선언할 때가 아니에요.');
|
||||
if (!inPlay(h, actor)) return fail('이번 판에서 이미 다이했어요.');
|
||||
return hp.declare ? fail('이미 선언했어요.') : ok;
|
||||
case 'reveal':
|
||||
if (h.phase !== 'reveal' || !inPlay(h, actor)) return fail('지금은 카드 공개를 고를 때가 아니에요.');
|
||||
return ok;
|
||||
default:
|
||||
if (!isBetType(a.type)) return fail('알 수 없는 행동이에요.');
|
||||
return validateBetAction(s, actor, a as PokerClientAction & { type: BetActionType });
|
||||
@@ -210,6 +214,8 @@ function applyTimeout(s: PokerState, ctx: Ctx, actor: PlayerId): void {
|
||||
for (const id of h.order) h.players[id]!.ready = true;
|
||||
return closeHand(s, ctx);
|
||||
}
|
||||
// Not showing is the default answer, not a missed turn.
|
||||
if (h.phase === 'reveal') return decideReveal(s, ctx, false);
|
||||
seat.timeoutsInRow++;
|
||||
if (seat.timeoutsInRow === 2) log(s, actor, '시간 초과가 이어져 자리 비움으로 표시했어요');
|
||||
const hp = h.players[actor]!;
|
||||
@@ -236,7 +242,9 @@ function applyLeave(s: PokerState, ctx: Ctx, actor: PlayerId): void {
|
||||
if (s.phase === 'rebuy' && s.rebuyPending.includes(actor)) decideRebuy(s, ctx, actor, false);
|
||||
else if (s.phase === 'playing' && s.hand) {
|
||||
const h = s.hand;
|
||||
if (!h.settled) forceFold(s, ctx, actor);
|
||||
if (h.phase === 'reveal') {
|
||||
if (inPlay(h, actor)) decideReveal(s, ctx, false);
|
||||
} else if (!h.settled) forceFold(s, ctx, actor);
|
||||
else if (h.players[actor] && !h.players[actor]!.ready) {
|
||||
h.players[actor]!.ready = true;
|
||||
if (h.order.every((id) => h.players[id]!.ready)) closeHand(s, ctx);
|
||||
@@ -283,6 +291,9 @@ function apply(prev: PokerState, actor: PlayerId, a: PokerAction, { rng, now }:
|
||||
hp!.declare = a.side;
|
||||
advance(s, ctx);
|
||||
break;
|
||||
case 'reveal':
|
||||
decideReveal(s, ctx, a.show);
|
||||
break;
|
||||
default:
|
||||
doBet(s, ctx, actor, toBetAction(a));
|
||||
}
|
||||
@@ -315,6 +326,8 @@ function legalActions(s: PokerState, p: PlayerId): PokerAction[] {
|
||||
}
|
||||
case 'declare':
|
||||
return (['high', 'low', 'swing'] as Side[]).map((side) => ({ type: 'declare', side }));
|
||||
case 'reveal':
|
||||
return [{ type: 'reveal', show: true }, { type: 'reveal', show: false }];
|
||||
case 'betting': {
|
||||
const korean = s.betStyle === 'korean';
|
||||
const out: PokerAction[] = [];
|
||||
@@ -338,7 +351,8 @@ function secretsOf(s: PokerState, player: PlayerId): string[] {
|
||||
const h = s.hand;
|
||||
if (h) {
|
||||
const hp = h.players[player];
|
||||
const revealed = !!h.showdown?.some((e) => e.id === player) || (s.options.mode === 'indian' && h.settled);
|
||||
const revealed =
|
||||
!!h.showdown?.some((e) => e.id === player) || (s.options.mode === 'indian' && h.settled) || (!!h.foldShown && inPlay(h, player));
|
||||
if (hp) {
|
||||
if (!revealed) out.push(...hp.hole);
|
||||
if (hp.choice) out.push(...hp.choice);
|
||||
|
||||
@@ -508,6 +508,8 @@ describe('no-limit / pot-limit (§5.3)', () => {
|
||||
let s = mk({ mode: 'holdem' }, 3, { dealerSeat: 2 });
|
||||
s = act(s, 'C', { type: 'nl.fold' });
|
||||
s = act(s, 'A', { type: 'nl.fold' });
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
s = act(s, 'B', { type: 'reveal', show: false });
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect(s.hand!.foldWin).toBe(true);
|
||||
expect(s.hand!.showdown).toBeNull();
|
||||
@@ -598,6 +600,97 @@ describe('바둑이 / 5카드 드로우 (§5.4.5, §5.4.6)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------ fold win: show or keep the cards
|
||||
|
||||
describe('혼자 남으면 카드 공개를 골라요', () => {
|
||||
/** Hold'em, order A(SB) B(BB) C: C and A fold, B (9♠ 9♥) is the last one in. */
|
||||
const lone = () => {
|
||||
let s = mk({ mode: 'holdem' }, 3, { dealerSeat: 2, deck: deckOf('7D 9S AS 2C 9H AH') });
|
||||
s = act(s, 'C', { type: 'nl.fold' });
|
||||
s = act(s, 'A', { type: 'nl.fold' });
|
||||
return s;
|
||||
};
|
||||
|
||||
test('only the last player decides, on the betting clock; the pot waits until then', () => {
|
||||
const s = lone();
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
expect(poker.activePlayers(s)).toEqual(['B']);
|
||||
expect(poker.legalActions!(s, 'B')).toEqual([{ type: 'reveal', show: true }, { type: 'reveal', show: false }]);
|
||||
expect(poker.legalActions!(s, 'A')).toEqual([]);
|
||||
expect(reason(s, 'A', { type: 'reveal', show: true })).toBe('지금은 카드 공개를 고를 때가 아니에요.');
|
||||
expect(reason(s, 'A', { type: 'ready' })).toBe('아직 판이 끝나지 않았어요.');
|
||||
expect(reason(mk({ mode: 'holdem' }, 3), 'A', { type: 'reveal', show: true })).toBe('지금은 카드 공개를 고를 때가 아니에요.');
|
||||
expect([view(s, 'B').my.canReveal, view(s, 'A').my.canReveal]).toEqual([true, false]);
|
||||
expect(s.deadlineAt! - clock).toBe(s.options.turnSeconds! * 1000);
|
||||
expect(s.hand!.settled).toBe(false);
|
||||
expect(view(s, null).pot).toBe(10); // BB's uncalled 5 already back
|
||||
expect(chipsBalanced(s)).toBe(true);
|
||||
expect(view(s, 'A').seats[1]!.hole).toEqual([null, null]);
|
||||
});
|
||||
|
||||
test('show: everyone (spectators too) sees the cards and the hand; the log says so', () => {
|
||||
const s = act(lone(), 'B', { type: 'reveal', show: true });
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect([stack(s, 'A'), stack(s, 'B'), stack(s, 'C')]).toEqual([995, 1005, 1000]);
|
||||
const name = evaluate(s.options, s.hand!.players.B!, []).high.name;
|
||||
for (const v of ['A', 'C', null]) {
|
||||
expect(view(s, v).seats[1]!.hole).toEqual(['9S', '9H']);
|
||||
expect(view(s, v).foldShown).toEqual({ id: 'B', handName: name });
|
||||
expect(view(s, v).seats[0]!.hole).toEqual(v === 'A' ? ['7D', '2C'] : [null, null]);
|
||||
}
|
||||
expect(s.log.some((e) => e.by === 'B' && e.msg === `패를 공개했어요 · ${name}`)).toBe(true);
|
||||
expect(poker.secretsOf!(s, 'B')).not.toContain('9S');
|
||||
});
|
||||
|
||||
test('hide: nobody else sees the cards, as before', () => {
|
||||
const s = act(lone(), 'B', { type: 'reveal', show: false });
|
||||
expect(s.hand!.foldWin).toBe(true);
|
||||
expect(s.hand!.showdown).toBeNull();
|
||||
for (const v of ['A', 'C', null]) {
|
||||
expect(view(s, v).seats[1]!.hole).toEqual([null, null]);
|
||||
expect(view(s, v).foldShown).toBeNull();
|
||||
expect(JSON.stringify(view(s, v))).not.toContain('"9S"');
|
||||
}
|
||||
expect(s.log.some((e) => e.by === 'B' && e.msg === '패를 공개하지 않았어요')).toBe(true);
|
||||
expect(poker.secretsOf!(s, 'B')).toContain('9S');
|
||||
});
|
||||
|
||||
test('time runs out or the player leaves: cards stay hidden (not counted as a missed turn)', () => {
|
||||
const s = act(lone(), 'B', { type: 'timeout' });
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect(s.hand!.foldShown).toBe(false);
|
||||
expect(s.seats[1]!.timeoutsInRow).toBe(0);
|
||||
const t = act(lone(), 'B', { type: 'leave' });
|
||||
expect(t.hand!.phase).toBe('handEnd');
|
||||
expect(t.hand!.foldShown).toBe(false);
|
||||
expect(view(t, 'A').seats[1]!.hole).toEqual([null, null]);
|
||||
expect(chipsBalanced(t)).toBe(true);
|
||||
});
|
||||
|
||||
test('7포커: the hidden cards are shown, the 초이스 discard stays secret', () => {
|
||||
let s = mk({ mode: 'sevenPoker' }, 3, { dealerSeat: 2 });
|
||||
for (const p of [...view(s, null).waiting]) s = act(s, p, poker.legalActions!(s, p)[0]!);
|
||||
while (s.hand!.phase === 'betting') s = act(s, toAct(s)!, { type: 'k.die' });
|
||||
expect(s.hand!.phase).toBe('reveal');
|
||||
const w = poker.activePlayers(s)[0]!;
|
||||
s = act(s, w, { type: 'reveal', show: true });
|
||||
const other = ['A', 'B', 'C'].find((p) => p !== w)!;
|
||||
const seat = view(s, other).seats.find((x) => x.id === w)!;
|
||||
expect(seat.hole).toEqual(s.hand!.players[w]!.hole);
|
||||
expect(JSON.stringify(view(s, other))).not.toContain(`"${s.hand!.players[w]!.discarded}"`);
|
||||
expect(poker.secretsOf!(s, w)).toContain(s.hand!.players[w]!.discarded!);
|
||||
});
|
||||
|
||||
test('nobody asked when nobody else is at the table, or in 인디언 (every card is shown anyway)', () => {
|
||||
let s = mk({ mode: 'holdem' }, 2, { dealerSeat: 1 });
|
||||
s = act(s, 'B', { type: 'leave' });
|
||||
expect(s.phase).toBe('finished');
|
||||
let ind = mk({ mode: 'indian', indianCards: 2 }, 3, { dealerSeat: 2 });
|
||||
while (ind.hand!.phase === 'betting' && ind.hand!.no === 1) ind = act(ind, toAct(ind)!, { type: 'nl.fold' });
|
||||
expect(ind.hand!.phase).toBe('handEnd');
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------ indian
|
||||
|
||||
describe('인디언 포커 (§5.4.7)', () => {
|
||||
@@ -802,11 +895,13 @@ describe('between hands: rebuy, elimination, levels, dealer, end (§5.6, §5.7,
|
||||
expect(s.hand!.order).toEqual(['B', 'C', 'A']);
|
||||
s = act(s, 'A', { type: 'nl.fold' });
|
||||
s = act(s, 'B', { type: 'nl.fold' });
|
||||
s = act(s, 'C', { type: 'reveal', show: false });
|
||||
s = readyAll(s);
|
||||
expect(s.hand!.dealerSeat).toBe(1);
|
||||
let w = mk({ mode: 'holdem', dealerRule: 'winner' }, 3, { dealerSeat: 0 });
|
||||
w = act(w, 'A', { type: 'nl.fold' });
|
||||
w = act(w, 'B', { type: 'nl.fold' });
|
||||
w = act(w, 'C', { type: 'reveal', show: true });
|
||||
expect(w.lastWinner).toBe('C');
|
||||
w = readyAll(w);
|
||||
expect(w.hand!.dealerSeat).toBe(2);
|
||||
@@ -816,6 +911,7 @@ describe('between hands: rebuy, elimination, levels, dealer, end (§5.6, §5.7,
|
||||
let s = mk({ mode: 'holdem' }, 3, { dealerSeat: 0 });
|
||||
s = act(s, 'A', { type: 'nl.fold' });
|
||||
s = act(s, 'B', { type: 'nl.fold' });
|
||||
s = act(s, 'C', { type: 'timeout' });
|
||||
expect(view(s, 'A').my.canReady).toBe(true);
|
||||
s = act(s, 'A', { type: 'ready' });
|
||||
expect(reason(s, 'A', { type: 'ready' })).toBe('이미 준비했어요.');
|
||||
|
||||
@@ -6,7 +6,8 @@ import type { PokerMode, PokerOptions } from './options';
|
||||
|
||||
export type Side = 'high' | 'low' | 'swing';
|
||||
export type SeatStatus = 'playing' | 'busted' | 'eliminated' | 'left';
|
||||
export type HandPhase = 'deal' | 'choice' | 'betting' | 'draw' | 'declare' | 'handEnd';
|
||||
/** `reveal`: everyone else folded — the last player decides whether to show the cards before taking the pot. */
|
||||
export type HandPhase = 'deal' | 'choice' | 'betting' | 'draw' | 'declare' | 'reveal' | 'handEnd';
|
||||
|
||||
const card = z.string().min(2).max(2);
|
||||
|
||||
@@ -27,6 +28,7 @@ export const pokerActionSchema = z.discriminatedUnion('type', [
|
||||
z.object({ type: z.literal('nl.allIn') }),
|
||||
z.object({ type: z.literal('draw'), cardIds: z.array(card).max(5) }),
|
||||
z.object({ type: z.literal('declare'), side: z.enum(['high', 'low', 'swing']) }),
|
||||
z.object({ type: z.literal('reveal'), show: z.boolean() }),
|
||||
z.object({ type: z.literal('ready') }),
|
||||
z.object({ type: z.literal('rebuy'), accept: z.boolean() }),
|
||||
]);
|
||||
@@ -109,6 +111,8 @@ export interface HandState {
|
||||
/** Chips have been paid out (stacks are final for this hand). */
|
||||
settled: boolean;
|
||||
foldWin: boolean;
|
||||
/** Fold win: the last player showed the cards (absent before 2026-10-14 = not shown). */
|
||||
foldShown?: boolean;
|
||||
showdown: ShowdownEntry[] | null;
|
||||
awards: Award[] | null;
|
||||
winners: PlayerId[];
|
||||
@@ -254,6 +258,7 @@ export interface PokerView {
|
||||
drawMax: number;
|
||||
drawAceBonus: boolean;
|
||||
canDeclare: boolean;
|
||||
canReveal: boolean;
|
||||
canReady: boolean;
|
||||
canRebuy: boolean;
|
||||
rebuysLeft: number | null;
|
||||
@@ -262,6 +267,8 @@ export interface PokerView {
|
||||
awards: Award[] | null;
|
||||
winners: PlayerId[];
|
||||
foldWin: boolean;
|
||||
/** Fold win where the last player showed the cards: who, and the hand those cards make. */
|
||||
foldShown: { id: PlayerId; handName: string } | null;
|
||||
indianUsed: CardId[];
|
||||
log: LogEntry[];
|
||||
stats: PokerStats;
|
||||
|
||||
@@ -8,7 +8,8 @@ import { bestIntl, bestOmaha } from './eval/international';
|
||||
import { bestKorean } from './eval/korean';
|
||||
import { bestLow } from './eval/low';
|
||||
import { evalBadugi } from './eval/badugi';
|
||||
import { bossOf, idxOf, inPlay, rebuysLeft, seatOf, waitingFor } from './hand';
|
||||
import { bossOf, contenderIds, idxOf, inPlay, rebuysLeft, seatOf, waitingFor } from './hand';
|
||||
import { evaluate } from './showdown';
|
||||
import { isSeven, streetName } from './modes';
|
||||
import type { BetActionType, HandPlayer, LegalBetView, PokerState, PokerView, SeatView } from './types';
|
||||
|
||||
@@ -66,6 +67,14 @@ export function drawLimitFor(s: PokerState): { max: number; aceBonus: boolean }
|
||||
return s.options.drawLimit === 'three' ? { max: 3, aceBonus: true } : { max: 5, aceBonus: false };
|
||||
}
|
||||
|
||||
/** Fold win where the last player showed the cards: who, and their hand. */
|
||||
function foldShownOf(s: PokerState): PokerView['foldShown'] {
|
||||
const h = s.hand;
|
||||
if (!h?.foldShown) return null;
|
||||
const id = contenderIds(h)[0]!;
|
||||
return { id, handName: evaluate(s.options, h.players[id]!, h.board).high.name };
|
||||
}
|
||||
|
||||
export function buildView(s: PokerState, viewer: PlayerId | null): PokerView {
|
||||
const o = s.options;
|
||||
const h = s.hand;
|
||||
@@ -79,7 +88,7 @@ export function buildView(s: PokerState, viewer: PlayerId | null): PokerView {
|
||||
const hp = h?.players[seat.id];
|
||||
const bp = h && hp ? h.bet.players[idxOf(h, seat.id)] : undefined;
|
||||
const mine = viewer === seat.id;
|
||||
const shown = !!h && (mine || revealedIds.has(seat.id) || (o.mode === 'indian' && h.settled));
|
||||
const shown = !!h && (mine || revealedIds.has(seat.id) || (o.mode === 'indian' && h.settled) || (!!h.foldShown && inPlay(h, seat.id)));
|
||||
const v: SeatView = {
|
||||
id: seat.id,
|
||||
seat: i,
|
||||
@@ -190,6 +199,7 @@ export function buildView(s: PokerState, viewer: PlayerId | null): PokerView {
|
||||
drawMax: dl.max,
|
||||
drawAceBonus: dl.aceBonus,
|
||||
canDeclare: contesting && h!.phase === 'declare' && h!.waiting && !hp!.declare,
|
||||
canReveal: !!(h && h.phase === 'reveal' && viewer && inPlay(h, viewer) && me?.status !== 'left'),
|
||||
canReady: !!(s.phase === 'playing' && h?.phase === 'handEnd' && hp && !hp.ready && me?.status !== 'left'),
|
||||
canRebuy: s.phase === 'rebuy' && !!viewer && s.rebuyPending.includes(viewer),
|
||||
rebuysLeft: left,
|
||||
@@ -198,6 +208,7 @@ export function buildView(s: PokerState, viewer: PlayerId | null): PokerView {
|
||||
awards: h?.awards ? h.awards.map((a) => ({ ...a })) : null,
|
||||
winners: h ? [...h.winners] : [],
|
||||
foldWin: !!h?.foldWin,
|
||||
foldShown: foldShownOf(s),
|
||||
indianUsed: [...s.indianUsed],
|
||||
log: s.log.slice(-VIEW_LOG).map((e) => ({ ...e })),
|
||||
stats: structuredClone(s.stats),
|
||||
|
||||
@@ -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