섯다·포커: 다른 사람이 모두 죽고 혼자 남으면 카드를 공개할지 고르기(카드 공개/공개 안 함, 시간 초과·나감·기본은 공개 안 함, 공개하면 모두에게 패와 족보를 뒤집어 보여 주고 기록에 남김, 컴퓨터도 센 패면 가끔 공개)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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