섯다: 3장 섯다 방의 재경기(구사·멍텅구리구사·같은 족보)는 2장 섯다로(2장 한 번에, 공개패 없이 베팅 1번)
hand.three를 (재)경기마다 두고 view.threeCard로 알림. 값이 없는 예전 상태는 방의 cardMode를 따름. 컴퓨터 판단·도움말·규칙 화면·문서도 맞춤, 엔진 테스트 2개 추가. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,7 @@ const sigmoid = (x: number) => 1 / (1 + Math.exp(-x));
|
||||
const myCardsOf = (v: SeotdaView, me: string): number[] =>
|
||||
(v.seats.find((s) => s.id === me)?.cards ?? []).flatMap((c) => ('id' in c ? [c.id] : []));
|
||||
|
||||
const finalSizeOf = (v: SeotdaView): 2 | 3 => (v.options.cardMode === 'three' ? 3 : 2);
|
||||
const finalSizeOf = (v: SeotdaView): 2 | 3 => (v.threeCard ? 3 : 2);
|
||||
|
||||
/** Opponents still in the hand, each with a range built from the public bets of this (re)match. */
|
||||
export function rangesOf(v: SeotdaView, me: string): { id: string; weight: RangeWeight }[] {
|
||||
@@ -51,7 +51,7 @@ export function rangesOf(v: SeotdaView, me: string): { id: string; weight: Range
|
||||
return { ...e, forced: isForced };
|
||||
});
|
||||
// Cards held when the bet was made: 2장 섯다 1장씩 → 1 card on street 0; 3장 섯다 → 2 of 3 on street 0.
|
||||
const partialStreet0 = v.options.cardMode === 'three' || v.options.dealMode === 'twoRounds';
|
||||
const partialStreet0 = finalSize === 3 || (v.options.cardMode === 'two' && v.options.dealMode === 'twoRounds');
|
||||
return live.map((s) => {
|
||||
const mine = entries.filter((e) => e.p === s.id && !e.forced);
|
||||
// 3장 섯다 공개패: every hand they may hold contains the card they showed.
|
||||
|
||||
@@ -227,6 +227,11 @@ export interface SeotdaHand {
|
||||
/** Pots carried from earlier matches of the same hand (eligibility fixed). */
|
||||
carried: PotState[];
|
||||
rematchReason: 'gusa' | 'mungGusa' | 'tie' | null;
|
||||
/**
|
||||
* This (re)match uses the 3장 섯다 flow. A 3장 섯다 room's rematch is played as 2장 섯다 (2장 한 번에, 베팅 1번,
|
||||
* 공개패 없음; 2026-10-17). Absent in hands started before that → the room's `cardMode`.
|
||||
*/
|
||||
three?: boolean;
|
||||
/** Upcoming rematch participants (handEnd → rejoin → rematch). */
|
||||
rematchSet: PlayerId[];
|
||||
rejoinPending: PlayerId[];
|
||||
@@ -340,6 +345,8 @@ export interface SeotdaView {
|
||||
handsPlayed: number;
|
||||
rematchNo: number;
|
||||
rematchReason: SeotdaHand['rematchReason'];
|
||||
/** This (re)match is played with 3장 섯다 rules (false for 2장 rooms and for a 3장 room's rematch). */
|
||||
threeCard: boolean;
|
||||
baseUnit: number;
|
||||
seats: SeotdaSeatView[];
|
||||
dealer: PlayerId | null;
|
||||
@@ -522,6 +529,7 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
betSeq: 0,
|
||||
carried: [],
|
||||
rematchReason: null,
|
||||
three: o.cardMode === 'three',
|
||||
rematchSet: [],
|
||||
rejoinPending: [],
|
||||
rejoinCost: 0,
|
||||
@@ -545,6 +553,9 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
/** 3장 섯다 (한게임): 2장을 받으면 먼저 1장을 골라 모두에게 보여 준 뒤 첫 베팅. */
|
||||
const opensFirst = (o: SeotdaOptions) => o.cardMode === 'three' && o.threeOpen;
|
||||
|
||||
/** The current (re)match follows the 3장 섯다 flow (a 3장 room's rematch is 2장 섯다). */
|
||||
const threeHand = (s: SeotdaState, h: SeotdaHand): boolean => h.three ?? s.options.cardMode === 'three';
|
||||
|
||||
/** 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]!;
|
||||
@@ -561,6 +572,8 @@ function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
h.order = order;
|
||||
h.phase = 'betting';
|
||||
h.street = 0;
|
||||
// 재경기는 2장 섯다로: 3장 섯다 방도 2장을 한 번에 받고 베팅 1번, 공개패·최종 선택 없음.
|
||||
h.three = false;
|
||||
h.deck = rng.shuffle(deckOf(s.options));
|
||||
h.cards = Object.fromEntries(order.map((id) => [id, []]));
|
||||
h.chosen = Object.fromEntries(order.map((id) => [id, null]));
|
||||
@@ -582,9 +595,8 @@ function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
for (const p of b.players) if (p.stack === 0) p.status = 'allIn';
|
||||
b.players.push({ id: CARRY, stack: 0, round: 0, total: carriedTotal(h), status: 'out', acted: true, raised: true, mayRaise: false });
|
||||
events.push({ type: 'handStart', handNo: h.handNo, rematchNo: h.rematchNo, dealer, ante: 0, reason: h.rematchReason });
|
||||
deal(h, order, firstDealCount(s.options), events);
|
||||
deal(h, order, s.options.cardMode === 'three' ? 2 : 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. */
|
||||
@@ -674,7 +686,7 @@ function settleShowdown(s: SeotdaState, events: GameEvent[]): void {
|
||||
const evals: Record<PlayerId, HandEval> = {};
|
||||
const hands: ShowdownHand[] = [];
|
||||
for (const id of live) {
|
||||
const pair = (o.cardMode === 'three' ? h.chosen[id] : h.cards[id]) as [number, number];
|
||||
const pair = (threeHand(s, h) ? h.chosen[id] : h.cards[id]) as [number, number];
|
||||
const e = evalSeotda(pair[0], pair[1], rules);
|
||||
evals[id] = e;
|
||||
hands.push({ id, cards: pair, name: e.name, baseName: e.baseName, value: e.value, special: e.special });
|
||||
@@ -937,7 +949,7 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
}
|
||||
// 3장 섯다(한게임): 2장 → 공개패 1장 → 1구 베팅 → 1장 더 → 2구 베팅 → 3장 중 2장 고르기 → 공개.
|
||||
// threePick=beforeBet: 1장 더 → 2장 고르기 → 마지막 베팅 → 공개.
|
||||
if (h.street === 0 && s.options.cardMode === 'three') {
|
||||
if (h.street === 0 && threeHand(s, h)) {
|
||||
deal(h, h.order.filter((id) => contendersOf(h).includes(id)), 1, events);
|
||||
if (s.options.threePick === 'beforeBet') h.phase = 'choose';
|
||||
else {
|
||||
@@ -947,11 +959,11 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (s.options.cardMode === 'three' && contendersOf(h).some((id) => !h.chosen[id])) {
|
||||
if (threeHand(s, h) && contendersOf(h).some((id) => !h.chosen[id])) {
|
||||
h.phase = 'choose';
|
||||
continue;
|
||||
}
|
||||
if (h.street === 0 && s.options.dealMode === 'twoRounds') {
|
||||
if (h.street === 0 && s.options.cardMode === 'two' && s.options.dealMode === 'twoRounds') {
|
||||
deal(h, h.order.filter((id) => contendersOf(h).includes(id)), 1, events);
|
||||
h.street = 1;
|
||||
h.lastAction = {};
|
||||
@@ -1353,7 +1365,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
// 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 chosen = h && threeHand(s, h) ? (h.chosen[x.id] ?? null) : null;
|
||||
const kept = chosen ? [...chosen] : cards;
|
||||
slots = kept.map((c) => (c === shown ? cardView(h!, c) : { hidden: true as const }));
|
||||
}
|
||||
@@ -1390,7 +1402,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
const myCards = h && me ? (h.cards[me] ?? []) : [];
|
||||
const myChosen = h && me ? (h.chosen[me] ?? null) : null;
|
||||
if (h && me && myCards.length) {
|
||||
if (o.cardMode === 'three' && myCards.length === 3) {
|
||||
if (threeHand(s, h) && myCards.length === 3) {
|
||||
const best = bestChoice(myCards, rules);
|
||||
myCombos = combos(myCards).map((c) => {
|
||||
const e = evalSeotda(c[0], c[1], rules);
|
||||
@@ -1421,6 +1433,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
handsPlayed: s.handsPlayed,
|
||||
rematchNo: h?.rematchNo ?? 0,
|
||||
rematchReason: h && h.rematchNo > 0 ? h.rematchReason : null,
|
||||
threeCard: h ? threeHand(s, h) : o.cardMode === 'three',
|
||||
baseUnit: s.baseUnit,
|
||||
seats,
|
||||
dealer: h?.dealer ?? null,
|
||||
|
||||
@@ -685,6 +685,48 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
|
||||
expect(c.handName).toBe('18광땡');
|
||||
});
|
||||
|
||||
test('3장 섯다 방의 재경기(구사)는 2장 섯다로: 2장 한 번에, 공개패 없이 베팅 1번 → 바로 공개', () => {
|
||||
let s = make({ cardMode: 'three' });
|
||||
s = rig(s, { A: [P(4), S(9)], B: [S(1), P(2)], C: [P(5), P(6)] }, [P(7), P(8)]);
|
||||
for (const [p, c] of [['A', S(9)], ['B', P(2)], ['C', P(5)]] as const) s = act(s, p, { type: 'open', cardId: c });
|
||||
s = act(s, 'A', { type: 'check' });
|
||||
s = act(s, 'B', { type: 'check' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
s = act(s, 'A', { type: 'check' });
|
||||
s = act(s, 'B', { type: 'check' });
|
||||
s = act(s, 'A', { type: 'choose', cardIds: [P(4), S(9)] });
|
||||
s = act(s, 'B', { type: 'choose', cardIds: [S(1), P(2)] });
|
||||
expect(s.hand!.showdown!.pots[0]).toMatchObject({ type: 'rematch', reason: 'gusa', winners: ['A', 'B'] });
|
||||
s = readyAll(s);
|
||||
const h = s.hand!;
|
||||
expect([h.rematchNo, h.phase, h.street, h.three]).toEqual([1, 'betting', 0, false]);
|
||||
expect([h.cards.A!.length, h.cards.B!.length]).toEqual([2, 2]);
|
||||
const v = seotda.view(s, 'A');
|
||||
expect(v.threeCard).toBe(false);
|
||||
expect(v.myCombos).toBeNull();
|
||||
expect(v.seats.every((x) => x.opening === null)).toBe(true);
|
||||
// Nothing is face up for the others (no 공개패).
|
||||
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, { hidden: true }]);
|
||||
s = rig(s, { A: [S(10), P(10)], B: [P(2), P(3)] }, [S(4)]);
|
||||
s = act(s, 'A', { type: 'ping' });
|
||||
s = act(s, 'B', { type: 'call' });
|
||||
// One betting round, no third card, no choosing: straight to the showdown.
|
||||
expect(s.hand!.phase).toBe('handEnd');
|
||||
expect(s.hand!.cards.A).toEqual([S(10), P(10)]);
|
||||
expect(s.hand!.showdown!.hands.find((x) => x.id === 'A')!.name).toBe('장땡');
|
||||
expect(s.hand!.showdown!.pots[0]).toMatchObject({ type: 'win', winners: ['A'] });
|
||||
// The next hand is 3장 섯다 again.
|
||||
s = readyAll(s);
|
||||
expect([s.hand!.rematchNo, s.hand!.phase, s.hand!.three]).toEqual([0, 'open', true]);
|
||||
expect(seotda.view(s, 'A').threeCard).toBe(true);
|
||||
});
|
||||
|
||||
test('이 변경 전에 시작한 3장 재경기(three 없음)는 예전처럼 3장 흐름을 이어 가요', () => {
|
||||
let s = make({ cardMode: 'three' });
|
||||
delete s.hand!.three;
|
||||
expect(seotda.view(s, 'A').threeCard).toBe(true);
|
||||
});
|
||||
|
||||
test('시간 무제한이면 공개패 고르기에도 마감이 없어요', () => {
|
||||
const s = make({ turnSeconds: null, cardMode: 'three' });
|
||||
expect(s.hand!.phase).toBe('open');
|
||||
|
||||
Reference in New Issue
Block a user