3장 섯다를 한게임처럼: 1구 선 하프·다이(1구 체크 없음), 예상족보, 패쪼기
- 엔진: 한게임 흐름(공개패 켬·마지막에 고르기)의 1구 첫 베팅(선)은 하프·다이만, 1구에는 체크 없음(시간 초과는 다이) - view.myReach: 다음 패로 만들 수 있는 족보(공개 정보만: 덱 구성 − 내 패 − 공개패) - 족보판 [예상족보 켬/끔]: 못 만드는 족보는 흐리게 - 패쪼기: 새로 받은 패는 뒷면, 밀어 올리면 아래부터 보이고 누르면 바로 뒤집힘, 6초 뒤 자동. 뒤집기 전에는 족보·조합을 숨김 - 도움말·규칙 화면·문서, 엔진 테스트 4개, e2e(1구 하프→콜, 패쪼기 드래그) 맞춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -362,6 +362,11 @@ export interface SeotdaView {
|
||||
betLog: BetLogEntry[];
|
||||
myHand: { name: string; value: number | null; special: SpecialKind | null; hint: string; strength: 'high' | 'mid' | 'low' | null } | null;
|
||||
myCombos: { cardIds: [number, number]; name: string; value: number; best: boolean }[] | null;
|
||||
/**
|
||||
* 예상족보 (hints on, still drawing): every 족보 my final hand can still become with the next card, from public
|
||||
* information only (deck composition minus my cards and the face-up 공개패). null when not drawing.
|
||||
*/
|
||||
myReach: { value: number; special: SpecialKind | null }[] | null;
|
||||
myChosen: [number, number] | null;
|
||||
/** 3장 섯다: the card I show everyone (공개패). */
|
||||
myOpened: number | null;
|
||||
@@ -420,6 +425,8 @@ function betsFor(s: SeotdaState, h: SeotdaHand, idx: number): { type: BetType; a
|
||||
if (!h.betting) return [];
|
||||
let out = legalBets(h.betting, idx).map((l) => ({ type: toType(l.kind), amount: l.amount, allIn: l.allIn }));
|
||||
if (!s.options.quarter) out = out.filter((l) => l.type !== 'quarter');
|
||||
// 한게임 3장 섯다 1구: 선은 하프·다이만(아래 forced), 선이 다이하면 다음 사람부터는 체크만 빼고 다 된다.
|
||||
if (hangameThree(s, h) && h.street === 0 && out.some((l) => l.type !== 'check' && l.type !== 'die')) out = out.filter((l) => l.type !== 'check');
|
||||
if (h.forced > 0 && h.street === 0 && out.length) {
|
||||
const half = out.find((l) => l.type === 'half') ?? out.find((l) => l.type === 'full' || l.type === 'ddadang' || l.type === 'quarter');
|
||||
const keep = half ?? out.find((l) => l.type === 'call' || l.type === 'check');
|
||||
@@ -539,7 +546,8 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
|
||||
next: null,
|
||||
ready: [],
|
||||
lastAction: {},
|
||||
forced: forcedCount(o),
|
||||
// 한게임 3장 섯다: 1구 첫 베팅(선)은 하프·다이만. 베팅 규칙 222~444면 그 규칙대로.
|
||||
forced: o.cardMode === 'three' && o.threeOpen && o.threePick === 'end' ? Math.max(1, forcedCount(o)) : forcedCount(o),
|
||||
log: [],
|
||||
};
|
||||
s.hand = h;
|
||||
@@ -556,6 +564,9 @@ 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';
|
||||
|
||||
/** 한게임 3장 섯다 흐름(공개패 켬, 마지막 베팅 뒤 고르기) — 1구 선 하프·다이, 1구 체크 없음. */
|
||||
const hangameThree = (s: SeotdaState, h: SeotdaHand): boolean => threeHand(s, h) && s.options.threeOpen && s.options.threePick === 'end';
|
||||
|
||||
/** 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]!;
|
||||
@@ -1236,7 +1247,8 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
const err = validateBet(h.betting, idx, { kind: toKind(a.type) } as BetAction);
|
||||
if (!err && betsFor(s, h, idx).some((l) => l.type === a.type)) return ok;
|
||||
if (!err && a.type === 'quarter' && !s.options.quarter) return fail('이 방은 쿼터 베팅을 쓰지 않아요.');
|
||||
if (!err) return fail(`베팅 규칙 ${s.options.betRule}: 지금은 하프 또는 다이만 할 수 있어요.`);
|
||||
if (!err && h.forced <= 0 && a.type === 'check') return fail('3장 섯다 1구에서는 체크를 할 수 없어요. 걸거나 다이해 주세요.');
|
||||
if (!err) return fail(s.options.betRule === 'free' ? '3장 섯다 1구에서 선은 하프 또는 다이만 할 수 있어요.' : `베팅 규칙 ${s.options.betRule}: 지금은 하프 또는 다이만 할 수 있어요.`);
|
||||
if (h.betting.turn === idx && ['ping', 'ddadang', 'quarter', 'half', 'full'].includes(a.type)) {
|
||||
if (a.type === 'full' && s.options.maxRaise === 'half') return fail('이 방은 하프까지만 올릴 수 있어요.');
|
||||
if (a.type === 'ping' && h.betting.opened) return fail('누가 이미 걸어서 삥을 할 수 없어요.');
|
||||
@@ -1398,6 +1410,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
h && b && myIdx >= 0 && h.phase === 'betting' && !seatOf(s, me!)!.left ? betsFor(s, h, myIdx) : [];
|
||||
let myHand: SeotdaView['myHand'] = null;
|
||||
let myCombos: SeotdaView['myCombos'] = null;
|
||||
let myReach: SeotdaView['myReach'] = null;
|
||||
let myDiscard: SeotdaCardView | null = null;
|
||||
const myCards = h && me ? (h.cards[me] ?? []) : [];
|
||||
const myChosen = h && me ? (h.chosen[me] ?? null) : null;
|
||||
@@ -1411,6 +1424,20 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
});
|
||||
if (myChosen) myDiscard = cardView(h, myCards.find((c) => !myChosen.includes(c))!);
|
||||
}
|
||||
const finalSize = threeHand(s, h) ? 3 : 2;
|
||||
if (o.hints && myCards.length < finalSize && !myChosen) {
|
||||
const seen = new Set([...myCards, ...Object.values(h.opened).filter((c): c is number => c !== null)]);
|
||||
const reach = new Map<string, { value: number; special: SpecialKind | null }>();
|
||||
for (const c of deckOf(o)) {
|
||||
if (seen.has(c)) continue;
|
||||
const next = [...myCards, c];
|
||||
for (const [a, b2] of next.length === 2 ? [next as [number, number]] : combos(next)) {
|
||||
const e = evalSeotda(a, b2, rules);
|
||||
reach.set(`${e.value}|${e.special}`, { value: e.value, special: e.special });
|
||||
}
|
||||
}
|
||||
myReach = [...reach.values()];
|
||||
}
|
||||
if (o.hints) {
|
||||
const pair = myChosen ?? (myCards.length === 2 ? (myCards as [number, number]) : myCards.length === 3 ? bestChoice(myCards, rules) : null);
|
||||
if (pair) {
|
||||
@@ -1447,6 +1474,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
|
||||
betLog: h?.log ?? [],
|
||||
myHand,
|
||||
myCombos,
|
||||
myReach,
|
||||
myChosen,
|
||||
myOpened: h && me ? (h.opened[me] ?? null) : null,
|
||||
myDiscard,
|
||||
|
||||
@@ -648,7 +648,11 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
|
||||
test('1구 베팅 뒤 1장 더 받고 2구 베팅, 그다음 3장 중 2장을 골라 공개해요', () => {
|
||||
let s = opened();
|
||||
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: 'check' });
|
||||
// 1구: 선(A)은 하프·다이만.
|
||||
expect(seotda.view(s, 'A').legal.map((l) => l.type).sort()).toEqual(['die', 'half']);
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'call' });
|
||||
s = act(s, 'C', { type: 'call' });
|
||||
expect(s.hand!.phase).toBe('betting');
|
||||
expect(s.hand!.street).toBe(1);
|
||||
expect(s.hand!.cards.A).toEqual([S(1), S(8), S(4)]);
|
||||
@@ -670,7 +674,9 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
|
||||
test('2구 베팅에서 한 사람만 남으면 고르기 없이 끝나요', () => {
|
||||
let s = opened();
|
||||
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'timeout' });
|
||||
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'check' });
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'call' });
|
||||
s = act(s, 'C', { type: 'call' });
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'die' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
@@ -689,8 +695,8 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 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, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'call' });
|
||||
s = act(s, 'C', { type: 'die' });
|
||||
s = act(s, 'A', { type: 'check' });
|
||||
s = act(s, 'B', { type: 'check' });
|
||||
@@ -721,6 +727,49 @@ describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅
|
||||
expect(seotda.view(s, 'A').threeCard).toBe(true);
|
||||
});
|
||||
|
||||
test('1구(한게임): 선은 하프·다이만, 선이 다이하면 다음 사람부터는 체크만 빼고 다 돼요. 2구에는 제한이 없어요', () => {
|
||||
let s = opened();
|
||||
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'timeout' });
|
||||
expect(seotda.view(s, 'A').forcedHalf).toBe(true);
|
||||
expect(reject(s, 'A', { type: 'check' })).not.toBeNull();
|
||||
expect(reject(s, 'A', { type: 'ping' })).not.toBeNull();
|
||||
s = act(s, 'A', { type: 'die' });
|
||||
const b = seotda.view(s, 'B').legal.map((l) => l.type);
|
||||
expect(b).not.toContain('check');
|
||||
expect(b).toEqual(expect.arrayContaining(['ping', 'half', 'die']));
|
||||
expect(reject(s, 'B', { type: 'check' })).toBe('3장 섯다 1구에서는 체크를 할 수 없어요. 걸거나 다이해 주세요.');
|
||||
// Time out with nothing bet: check is not allowed here, so it is a 다이.
|
||||
s = act(s, 'B', { type: 'timeout' });
|
||||
expect(s.hand!.lastAction.B!.type).toBe('die');
|
||||
});
|
||||
|
||||
test('예상족보: 다음 패로 만들 수 있는 족보만, 공개된 정보로만 계산해요', () => {
|
||||
let s = opened();
|
||||
const values = (v: { value: number; special: unknown }[] | null) => (v ?? []).filter((x) => !x.special).map((x) => x.value);
|
||||
const a = seotda.view(s, 'A');
|
||||
// 1광 + 8광: 18광땡은 늘 남고, 3월 광이 오면 38광땡.
|
||||
expect(values(a.myReach)).toEqual(expect.arrayContaining([990, 1000]));
|
||||
// B shows the 3월 광 → A can no longer make 38광땡.
|
||||
s.hand!.cards.B = [S(3), P(6)];
|
||||
s = act(s, 'B', { type: 'open', cardId: S(3) });
|
||||
expect(values(seotda.view(s, 'A').myReach)).not.toContain(1000);
|
||||
for (const p of ['A', 'C']) s = act(s, p, { type: 'timeout' });
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'call' });
|
||||
s = act(s, 'C', { type: 'call' });
|
||||
expect(seotda.view(s, 'A').myReach).toBeNull();
|
||||
});
|
||||
|
||||
test('2구는 체크부터 자유롭게', () => {
|
||||
let s = opened();
|
||||
for (const p of ['A', 'B', 'C']) s = act(s, p, { type: 'timeout' });
|
||||
s = act(s, 'A', { type: 'half' });
|
||||
s = act(s, 'B', { type: 'call' });
|
||||
s = act(s, 'C', { type: 'call' });
|
||||
expect(s.hand!.street).toBe(1);
|
||||
expect(seotda.view(s, 'A').legal.map((l) => l.type)).toContain('check');
|
||||
});
|
||||
|
||||
test('이 변경 전에 시작한 3장 재경기(three 없음)는 예전처럼 3장 흐름을 이어 가요', () => {
|
||||
let s = make({ cardMode: 'three' });
|
||||
delete s.hand!.three;
|
||||
|
||||
Reference in New Issue
Block a user