3장 섯다: 공개패는 항상 맨 왼쪽, 고른 2장은 쇼다운 전까지 다른 사람 화면에 드러나지 않게

- 공개패를 내 패·다른 사람 자리·쇼다운 모든 화면에서 맨 왼쪽에 둠(openFirst)
- 고른 뒤에도 다른 사람 화면은 고르기 전과 같음(공개패 앞면 + 뒷면 2장). 예전엔 남긴 2장만 보여 공개패를 남겼는지/버렸는지 드러났음
- 테스트: 공개패 남김/버림 두 경우 다른 사람 화면이 같음, 쇼다운 공개패 왼쪽, E2E에서 오른쪽 패를 공개하면 왼쪽으로 이동

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-18 08:07:45 +09:00
parent 1bd69200fd
commit d40ba1e121
4 changed files with 67 additions and 20 deletions

View File

@@ -907,6 +907,11 @@ function applyBetAction(s: SeotdaState, id: PlayerId, t: BetType, events: GameEv
events.push({ type: 'bet', player: id, kind: t, amount: r.event.amount, allIn: r.event.allIn });
}
/** The 공개패 (if any of these) first, the rest in dealt order. */
function openFirst(cards: readonly number[], shown: number | null): number[] {
return shown !== null && cards.includes(shown) ? [shown, ...cards.filter((c) => c !== shown)] : [...cards];
}
function chooseFor(s: SeotdaState, id: PlayerId, pair: [number, number], events: GameEvent[]): void {
const h = s.hand!;
h.chosen[id] = [Math.min(...pair), Math.max(...pair)] as [number, number];
@@ -1366,20 +1371,19 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
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);
const cards = h && inHand ? (h.cards[x.id] ?? []) : [];
const shown = h?.opened[x.id] ?? null;
// 3장 섯다 공개패 always sits leftmost, in every view (사용자 요청 2026-10-18).
const cards = openFirst(h && inHand ? (h.cards[x.id] ?? []) : [], shown);
let slots: CardSlot[];
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 === foldShown) slots = foldCards(h, x.id).map((c) => cardView(h, c));
slots = openFirst(pair, shown).map((c) => cardView(h, c));
} else if (h && x.id === foldShown) slots = openFirst(foldCards(h, x.id), shown).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).
const shown = h?.opened[x.id] ?? 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 }));
// 3장 섯다: the 공개패 is face up for everyone, the rest face down. Choosing changes nothing here until the
// showdown: showing only the two kept cards would tell whether the 공개패 was kept (사용자 요청 2026-10-18).
slots = cards.map((c) => (c === shown ? cardView(h!, c) : { hidden: true as const }));
}
return {
id: x.id,
@@ -1492,7 +1496,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
}
: null,
showdown: h?.showdown
? { hands: h.showdown.hands.map((x) => ({ ...x, cards: x.cards.map((c) => cardView(h, c)) })), pots: h.showdown.pots }
? { hands: h.showdown.hands.map((x) => ({ ...x, cards: openFirst(x.cards, h.opened[x.id] ?? null).map((c) => cardView(h, c)) })), pots: h.showdown.pots }
: null,
foldWin: h?.foldWin ?? null,
next: h?.next ?? null,

View File

@@ -578,7 +578,8 @@ describe('3장 섯다 (옵션: 공개패 없이, 마지막 베팅 전에 고르
expect(reject(s, 'A', { type: 'choose', cardIds: [S(1), S(8)] })).toBe('이미 골랐어요.');
const other = seotda.view(s, 'B');
expect(other.seats.find((x) => x.id === 'A')!.chosen).toBe(true);
expect(other.seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, { hidden: true }]);
// Still three face-down cards: the others can't tell which two A kept.
expect(other.seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, { hidden: true }, { hidden: true }]);
expect(JSON.stringify(other)).not.toContain('"id":0,');
expect(other.myChosen).toBeNull();
expect(seotda.view(s, 'A').myDiscard!.id).toBe(S(8));
@@ -632,7 +633,9 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
s = act(s, 'A', { type: 'open', cardId: S(8) });
expect(reject(s, 'A', { type: 'open', cardId: S(1) })).toBe('이미 공개패를 골랐어요.');
const b = seotda.view(s, 'B');
expect(b.seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, expect.objectContaining({ id: S(8) })]);
// The 공개패 goes to the left, for the others and for the owner.
expect(b.seats.find((x) => x.id === 'A')!.cards).toEqual([expect.objectContaining({ id: S(8) }), { hidden: true }]);
expect(seotda.view(s, 'A').seats.find((x) => x.id === 'A')!.cards.map((c) => ('id' in c ? c.id : null))).toEqual([S(8), S(1)]);
expect(b.seats.find((x) => x.id === 'A')!.opening).toBe(true);
expect(b.seats.find((x) => x.id === 'C')!.opening).toBe(false);
expect(JSON.stringify(b)).not.toContain(`"id":${S(1)},`);
@@ -657,15 +660,19 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
expect(s.hand!.street).toBe(1);
expect(s.hand!.cards.A).toEqual([S(1), S(8), S(4)]);
// The third card is hidden from the others; the 공개패 stays face up.
expect(seotda.view(s, 'C').seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, expect.objectContaining({ id: S(8) }), { hidden: true }]);
expect(seotda.view(s, 'C').seats.find((x) => x.id === 'A')!.cards).toEqual([expect.objectContaining({ id: S(8) }), { hidden: true }, { hidden: true }]);
expect(seotda.view(s, 'A').seats.find((x) => x.id === 'A')!.cards.map((c) => ('id' in c ? c.id : null))).toEqual([S(8), S(1), S(4)]);
s = act(s, 'A', { type: 'half' });
s = act(s, 'B', { type: 'call' });
s = act(s, 'C', { type: 'die' });
expect(s.hand!.phase).toBe('choose');
expect(seotda.activePlayers(s).sort()).toEqual(['A', 'B']);
expect(seotda.view(s, 'A').myCombos!.find((c) => c.best)!.name).toBe('18광땡');
const before = seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.cards;
s = act(s, 'A', { type: 'choose', cardIds: [S(1), S(4)] }); // 공개패(8광)를 버리고 독사
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.cards).toEqual([{ hidden: true }, { hidden: true }]);
// What A kept stays secret until the showdown: B still sees the 공개패 and two face-down cards, exactly as before.
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.cards).toEqual(before);
expect(seotda.view(s, 'B').seats.find((x) => x.id === 'A')!.chosen).toBe(true);
s = act(s, 'B', { type: 'timeout' });
expect(s.hand!.phase).toBe('handEnd');
expect(s.hand!.showdown!.hands.find((x) => x.id === 'A')!.name).toBe('독사');
@@ -1125,3 +1132,30 @@ describe('random playouts', () => {
}
}, 20_000);
});
describe('3장 섯다: 고른 2장은 공개 전까지 아무 단서도 없어요 (사용자 요청 2026-10-18)', () => {
test('공개패를 남기든 버리든 다른 사람 화면은 똑같고, 공개 때는 공개패가 왼쪽', () => {
const start = () => {
let s = make({ cardMode: 'three' });
s = rig(s, { A: [S(1), S(8)], B: [P(5), P(6)], C: [P(2), P(7)] }, [S(4), P(9), P(10)]);
for (const [p, c] of [['A', S(8)], ['B', P(6)], ['C', P(7)]] as const) s = act(s, p, { type: 'open', cardId: c });
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: p === 'A' ? 'half' : 'call' });
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: p === 'A' ? 'half' : 'call' });
expect(s.hand!.phase).toBe('choose');
return s;
};
const kept = act(start(), 'A', { type: 'choose', cardIds: [S(1), S(8)] }); // 공개패(8광) 남김
const thrown = act(start(), 'A', { type: 'choose', cardIds: [S(1), S(4)] }); // 공개패 버림
for (const viewer of ['B', 'C', null]) {
expect(seotda.view(kept, viewer).seats).toEqual(seotda.view(thrown, viewer).seats);
}
// Showdown: the kept 공개패 is on the left.
let s = kept;
s = act(s, 'B', { type: 'choose', cardIds: [P(5), P(6)] });
s = act(s, 'C', { type: 'choose', cardIds: [P(2), P(7)] });
expect(s.hand!.showdown).toBeTruthy();
const a = seotda.view(s, 'C').seats.find((x) => x.id === 'A')!;
expect(a.cards.map((c) => ('id' in c ? c.id : null))).toEqual([S(8), S(1)]);
expect(seotda.view(s, 'C').showdown!.hands.find((x) => x.id === 'A')!.cards.map((c) => c.id)).toEqual([S(8), S(1)]);
});
});