섯다: 3장 섯다를 한게임 방식으로 — 2장 받고 공개패 1장 고르기 → 1구 베팅 → 1장 더 → 2구 베팅 → 3장 중 2장 골라 승부

- 엔진: 공개패 단계(open)·액션, 공개패는 다른 사람 화면에 앞면, 최종 선택은 마지막 베팅 뒤(threePick=end), 옵션 threeOpen/threePick으로 예전 흐름 유지, 상태 v3(진행 중인 방은 예전 흐름)
- 컴퓨터: 광·4/7/9 열끗은 숨기고 평범한 패 공개, 상대 공개패를 패 범위에 반영
- 화면: 공개패 고르기 상자, 자리 표시·도움말·규칙·옵션
- 2장 섯다 기본(2장 한 번에)은 한게임 안내 그대로, 1장씩(전통)은 옵션
- E2E seotda3, 문서 §2·§5.2·§8

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 22:22:06 +09:00
parent 9564e4604c
commit 1cf556b431
10 changed files with 333 additions and 41 deletions

View File

@@ -59,7 +59,7 @@ export function totalMsOf(v: SeotdaView): number {
if (v.phase === 'rebuy' || v.handPhase === 'rejoin') return o.decisionSeconds * 1000; if (v.phase === 'rebuy' || v.handPhase === 'rejoin') return o.decisionSeconds * 1000;
if (v.handPhase === 'handEnd') return 5000; if (v.handPhase === 'handEnd') return 5000;
if (o.turnSeconds === null) return 0; if (o.turnSeconds === null) return 0;
if (v.handPhase === 'choose') return (o.turnSeconds + 10) * 1000; if (v.handPhase === 'choose' || v.handPhase === 'open') return (o.turnSeconds + 10) * 1000;
const turn = v.seats.find((s) => s.id === v.toAct); const turn = v.seats.find((s) => s.id === v.toAct);
return turn?.away ? 5000 : o.turnSeconds * 1000; return turn?.away ? 5000 : o.turnSeconds * 1000;
} }
@@ -225,7 +225,8 @@ function Seat({ seat, view: v, players, me, deadline, pos, cardW, winner, setRef
if (seat.allIn) tags.push(['올인', '#1d4ed8']); if (seat.allIn) tags.push(['올인', '#1d4ed8']);
if (seat.chosen === true) tags.push(['고름', '#15803d']); if (seat.chosen === true) tags.push(['고름', '#15803d']);
if (seat.chosen === false) tags.push(['고르는 중', '#475569']); if (seat.chosen === false) tags.push(['고르는 중', '#475569']);
const timed = seat.isTurn || seat.chosen === false; if (seat.opening === false) tags.push(['공개패 고르는 중', '#475569']);
const timed = seat.isTurn || seat.chosen === false || seat.opening === false;
const style = pos ? ({ '--x': `${pos.x}%`, '--y': `${pos.y}%` } as CSSProperties) : undefined; const style = pos ? ({ '--x': `${pos.x}%`, '--y': `${pos.y}%` } as CSSProperties) : undefined;
return ( return (
<div <div
@@ -295,7 +296,7 @@ function MySeat({ seat, view: v, players, deadline, winner, setRef, phone }: { s
card={c} card={c}
width={w} width={w}
className="anim-deal" className="anim-deal"
highlight={!!v.myChosen?.includes(c.id)} highlight={!!v.myChosen?.includes(c.id) || (!v.myChosen && v.myOpened === c.id)}
dimmed={(!!v.myChosen && !v.myChosen.includes(c.id)) || seat.folded} dimmed={(!!v.myChosen && !v.myChosen.includes(c.id)) || seat.folded}
style={{ ['--anim-delay' as string]: `${i * 110}ms`, ['--from-y' as string]: '-180px' }} style={{ ['--anim-delay' as string]: `${i * 110}ms`, ['--from-y' as string]: '-180px' }}
/> />
@@ -313,7 +314,7 @@ function MySeat({ seat, view: v, players, deadline, winner, setRef, phone }: { s
선 선
</span> </span>
)} )}
{(seat.isTurn || seat.chosen === false) && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine size={30} />} {(seat.isTurn || seat.chosen === false || seat.opening === false) && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine size={30} />}
</div> </div>
<span className="sd-money" style={{ fontSize: '1.05rem' }}> <span className="sd-money" style={{ fontSize: '1.05rem' }}>
{formatWon(seat.stack)} {formatWon(seat.stack)}
@@ -548,6 +549,30 @@ function BetBar({ view: v, me, act, pending, players }: { view: SeotdaView; me:
// ---------------------------------------------------------------- 3장 섯다 choice and result // ---------------------------------------------------------------- 3장 섯다 choice and result
/** 3장 섯다 (한게임): of the first two cards, pick the one everyone gets to see. */
function OpenBox({ view: v, me, act, pending }: { view: SeotdaView; me: string; act: (a: unknown) => void; pending: boolean }) {
const seat = v.seats.find((s) => s.id === me)!;
const [pick, setPick] = useState<number | null>(null);
useEffect(() => setPick(null), [v.handNo, v.rematchNo]);
const cards = seat.cards.filter(isCard);
const picked = cards.find((c) => c.id === pick);
return (
<div className="card stack" style={{ gap: 8, padding: 12 }} role="group" aria-label="공개패 고르기">
<p style={{ margin: 0, textAlign: 'center' }}>
<strong>모두에게 보여 줄 패 1장을 골라 주세요.</strong> 나머지 1장과 다음에 받을 1장은 나만 봐요.
</p>
<div className="row" style={{ justifyContent: 'center', gap: 10 }}>
{cards.map((c) => (
<HwatuCard key={c.key} card={c} size="lg" selected={pick === c.id} onClick={() => setPick(c.id)} />
))}
</div>
<button type="button" className="btn btn-primary" disabled={pick === null || pending} onClick={() => act({ type: 'open', cardId: pick })}>
{picked ? `${picked.month}월 패 공개하기` : '공개할 패를 눌러 고르세요'}
</button>
</div>
);
}
function ChooseBox({ view: v, me, act, pending }: { view: SeotdaView; me: string; act: (a: unknown) => void; pending: boolean }) { function ChooseBox({ view: v, me, act, pending }: { view: SeotdaView; me: string; act: (a: unknown) => void; pending: boolean }) {
const seat = v.seats.find((s) => s.id === me)!; const seat = v.seats.find((s) => s.id === me)!;
const [pick, setPick] = useState<number[]>([]); const [pick, setPick] = useState<number[]>([]);
@@ -707,6 +732,8 @@ export function SeotdaBoard({ view: v, me, players, act, pending, deadline }: Bo
</div> </div>
)} )}
</div> </div>
{mySeat && v.handPhase === 'open' && mySeat.opening === false && <OpenBox view={v} me={mySeat.id} act={act} pending={pending} />}
{mySeat && v.handPhase === 'open' && mySeat.opening === true && <p className="small muted sd-help">공개패를 골랐어요. 다른 사람을 기다리는 중이에요.</p>}
{mySeat && v.handPhase === 'choose' && mySeat.chosen === false && <ChooseBox view={v} me={mySeat.id} act={act} pending={pending} />} {mySeat && v.handPhase === 'choose' && mySeat.chosen === false && <ChooseBox view={v} me={mySeat.id} act={act} pending={pending} />}
{mySeat && v.handPhase === 'choose' && mySeat.chosen === true && <p className="small muted sd-help">골랐어요. 다른 사람이 고르기를 기다리는 중이에요.</p>} {mySeat && v.handPhase === 'choose' && mySeat.chosen === true && <p className="small muted sd-help">골랐어요. 다른 사람이 고르기를 기다리는 중이에요.</p>}
{mySeat && mySeat.inHand && v.handPhase === 'betting' && !mySeat.folded && <BetBar view={v} me={mySeat.id} act={act} pending={pending} players={players} />} {mySeat && mySeat.inHand && v.handPhase === 'betting' && !mySeat.folded && <BetBar view={v} me={mySeat.id} act={act} pending={pending} players={players} />}

View File

@@ -68,10 +68,17 @@ test('섯다: 2장째를 받으면 지금 내 족보와 마지막 베팅, 족보
expect(helpNow(view(off, p), p, users)).toContain("'족보 도우미'를 보고"); expect(helpNow(view(off, p), p, users)).toContain("'족보 도우미'를 보고");
}); });
test('섯다: 3장 섯다 고르기 단계', () => { test('섯다: 3장 섯다 공개패 → 베팅 2번 → 고르기 단계(한게임)', () => {
let { state } = setupGame('seotda', 3, { cardMode: 'three' }); let { state } = setupGame('seotda', 3, { cardMode: 'three' });
expect(view(state, null).handPhase).toBe('open');
expect(helpNow(view(state, 'A'), 'A', users)).toContain('공개하기');
expect(helpNow(view(state, null), null, users)).toContain('공개패');
for (const p of ['A', 'B', 'C']) state = applyAction('seotda', state, p, { type: 'open', cardId: view(state, p).seats.find((x) => x.id === p).cards[0].id });
expect(helpNow(view(state, null), null, users)).not.toContain('공개패를 고르는 중');
while (view(state, null).handPhase === 'betting') state = applyAction('seotda', state, view(state, null).toAct, { type: 'check' }); while (view(state, null).handPhase === 'betting') state = applyAction('seotda', state, view(state, null).toAct, { type: 'check' });
expect(view(state, null).handPhase).toBe('choose'); expect(view(state, null).handPhase).toBe('choose');
expect(view(state, null).street).toBe(1);
expect(helpNow(view(state, null), null, users)).toContain('패를 공개해요');
const t = helpNow(view(state, 'A'), 'A', users); const t = helpNow(view(state, 'A'), 'A', users);
expect(t).toContain('2장을 눌러 고르면'); expect(t).toContain('2장을 눌러 고르면');
expect(t).toContain('정하기'); expect(t).toContain('정하기');

View File

@@ -65,7 +65,8 @@ function waitingLine(v: SeotdaView, players: Record<string, PublicUser>): string
const round = oneRound ? '베팅' : v.street === 0 ? '첫 베팅' : '마지막 베팅'; const round = oneRound ? '베팅' : v.street === 0 ? '첫 베팅' : '마지막 베팅';
return v.toAct ? `${who(players, v.toAct)} 차례예요(${round}).` : '카드를 나눠 주는 중이에요.'; return v.toAct ? `${who(players, v.toAct)} 차례예요(${round}).` : '카드를 나눠 주는 중이에요.';
} }
if (v.handPhase === 'choose') return '모두 3장 중 쓸 2장을 몰래 고르는 중이에요. 다 고르면 마지막 베팅을 해요.'; if (v.handPhase === 'choose') return `모두 3장 중 쓸 2장을 몰래 고르는 중이에요. 다 고르면 ${v.street === 1 && v.options.threePick === 'end' ? '패를 공개해요' : '마지막 베팅을 해요'}.`;
if (v.handPhase === 'open') return '모두 받은 2장 중 모두에게 보여 줄 패 1장(공개패)을 고르는 중이에요. 다 고르면 첫 베팅을 해요.';
if (v.handPhase === 'rejoin') return '구사 재경기 전에, 다이했던 사람이 다시 들어올지 고르는 중이에요.'; if (v.handPhase === 'rejoin') return '구사 재경기 전에, 다이했던 사람이 다시 들어올지 고르는 중이에요.';
if (v.handPhase === 'handEnd') return resultLine(v, players); if (v.handPhase === 'handEnd') return resultLine(v, players);
return '잠시만 기다려 주세요.'; return '잠시만 기다려 주세요.';
@@ -132,7 +133,7 @@ export function helpNow(v: SeotdaView, me: string | null, players: Record<string
if (seat.chosen === null) return seat.folded ? '이번 판은 다이했어요. 다음 판을 기다려 주세요.' : [notIn, watching(v, players)].join('\n'); if (seat.chosen === null) return seat.folded ? '이번 판은 다이했어요. 다음 판을 기다려 주세요.' : [notIn, watching(v, players)].join('\n');
if (seat.chosen) { if (seat.chosen) {
const name = v.myHand ? `(${v.myHand.name})` : ''; const name = v.myHand ? `(${v.myHand.name})` : '';
return `쓸 패 2장을 골랐어요${name}. 다른 사람이 다 고를 때까지 기다려 주세요. 다 고르면 마지막 베팅을 해요.`; return `쓸 패 2장을 골랐어요${name}. 다른 사람이 다 고를 때까지 기다려 주세요. 다 고르면 ${v.options.threePick === 'end' ? '패를 공개해요' : '마지막 베팅을 해요'}.`;
} }
const lines = ["3장 중 쓸 패 2장을 눌러 고르면 아래 버튼이 '○○(으)로 정하기'로 바뀌어요. 그 버튼을 눌러 정해 주세요. 남는 1장은 아무에게도 보이지 않아요."]; const lines = ["3장 중 쓸 패 2장을 눌러 고르면 아래 버튼이 '○○(으)로 정하기'로 바뀌어요. 그 버튼을 눌러 정해 주세요. 남는 1장은 아무에게도 보이지 않아요."];
const best = v.options.hints ? v.myCombos?.find((c) => c.best) : undefined; const best = v.options.hints ? v.myCombos?.find((c) => c.best) : undefined;
@@ -140,6 +141,15 @@ export function helpNow(v: SeotdaView, me: string | null, players: Record<string
lines.push('모두 동시에 몰래 고르고, 시간이 지나면 가장 센 조합으로 저절로 골라져요.'); lines.push('모두 동시에 몰래 고르고, 시간이 지나면 가장 센 조합으로 저절로 골라져요.');
return lines.join('\n'); return lines.join('\n');
} }
case 'open': {
if (seat.opening === null) return seat.folded ? '이번 판은 다이했어요. 다음 판을 기다려 주세요.' : [notIn, watching(v, players)].join('\n');
if (seat.opening) return '공개패를 골랐어요. 다른 사람이 다 고르면 첫 베팅을 해요.';
return [
'받은 2장 중 모두에게 보여 줄 패 1장을 눌러 고르고 [○월 패 공개하기]를 눌러 주세요.',
'센 패(광, 같은 월)는 숨기고 평범한 패를 보여 주면 상대가 내 패를 짐작하기 어려워요.',
'시간이 지나면 낮은 월의 패가 저절로 공개돼요.',
].join('\n');
}
case 'rejoin': { case 'rejoin': {
if (!v.rejoin?.mine) return `${waitingLine(v, players)} 잠시 기다려 주세요.`; if (!v.rejoin?.mine) return `${waitingLine(v, players)} 잠시 기다려 주세요.`;
const cost = won(v.rejoin.cost); const cost = won(v.rejoin.cost);

View File

@@ -253,6 +253,7 @@ function isMyTurn(v: SeotdaView, me: string | null): boolean {
if (v.phase === 'rebuy') return !!v.rebuy?.mine; if (v.phase === 'rebuy') return !!v.rebuy?.mine;
if (v.handPhase === 'betting') return v.toAct === me; if (v.handPhase === 'betting') return v.toAct === me;
if (v.handPhase === 'choose') return v.seats.find((s) => s.id === me)?.chosen === false; if (v.handPhase === 'choose') return v.seats.find((s) => s.id === me)?.chosen === false;
if (v.handPhase === 'open') return v.seats.find((s) => s.id === me)?.opening === false;
if (v.handPhase === 'rejoin') return !!v.rejoin?.mine; if (v.handPhase === 'rejoin') return !!v.rejoin?.mine;
return false; return false;
} }
@@ -266,6 +267,8 @@ function statusText(v: SeotdaView, me: string | null, players: Record<string, Pu
return v.toAct ? `${nick(players, v.toAct)}님 차례예요` : '패를 나눠 주는 중이에요'; return v.toAct ? `${nick(players, v.toAct)}님 차례예요` : '패를 나눠 주는 중이에요';
case 'choose': case 'choose':
return isMyTurn(v, me) ? '쓸 패 2장을 골라 주세요' : '다른 사람이 패를 고르는 중이에요'; return isMyTurn(v, me) ? '쓸 패 2장을 골라 주세요' : '다른 사람이 패를 고르는 중이에요';
case 'open':
return isMyTurn(v, me) ? '모두에게 보여 줄 패 1장을 골라 주세요' : '다른 사람이 공개할 패를 고르는 중이에요';
case 'rejoin': case 'rejoin':
return v.rejoin?.mine ? '구사 재경기에 참가할지 골라 주세요' : '다이한 사람이 재경기 참가를 고르는 중이에요'; return v.rejoin?.mine ? '구사 재경기에 참가할지 골라 주세요' : '다이한 사람이 재경기 참가를 고르는 중이에요';
case 'handEnd': case 'handEnd':
@@ -309,9 +312,19 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
</Field> </Field>
{o.cardMode === 'two' && ( {o.cardMode === 'two' && (
<Field label="패 받기"> <Field label="패 받기">
<Seg value={o.dealMode} options={[['oneRound', '2장 한 번에(베팅 1번)'], ['twoRounds', '1장씩 두 번(베팅 2번)']]} onChange={(dealMode) => set({ dealMode })} /> <Seg value={o.dealMode} options={[['oneRound', '2장 한 번에(한게임)'], ['twoRounds', '1장씩 두 번(전통)']]} onChange={(dealMode) => set({ dealMode })} />
</Field> </Field>
)} )}
{o.cardMode === 'three' && (
<>
<Field label="공개패">
<Seg value={o.threeOpen ? 'on' : 'off'} options={[['on', '2장 중 1장 보여 주기(한게임)'], ['off', '안 보여 줌']]} onChange={(k) => set({ threeOpen: k === 'on' })} />
</Field>
<Field label="최종 2장 고르기">
<Seg value={o.threePick} options={[['end', '마지막 베팅 뒤(한게임)'], ['beforeBet', '마지막 베팅 전']]} onChange={(threePick) => set({ threePick })} />
</Field>
</>
)}
<Field label="화투 장수"> <Field label="화투 장수">
<Seg value={o.deck} options={[[20, '20장(1~10월 2장씩)'], [40, '40장(1~10월 4장씩)']]} onChange={(deck) => set({ deck })} /> <Seg value={o.deck} options={[[20, '20장(1~10월 2장씩)'], [40, '40장(1~10월 4장씩)']]} onChange={(deck) => set({ deck })} />
</Field> </Field>
@@ -406,7 +419,11 @@ function Options({ value: o, onChange }: OptionsProps<SeotdaOptions>) {
function optionsSummary(o: SeotdaOptions): string { function optionsSummary(o: SeotdaOptions): string {
return [ return [
o.cardMode === 'three' ? '3장 섯다' : o.dealMode === 'twoRounds' ? '2장 섯다(1장씩)' : '2장 섯다', o.cardMode === 'three'
? `3장 섯다${o.threeOpen ? '(공개패' : '(공개패 없음'}·${o.threePick === 'end' ? '마지막에 2장 고르기)' : '베팅 전 2장 고르기)'}`
: o.dealMode === 'twoRounds'
? '2장 섯다(1장씩)'
: '2장 섯다',
`${o.deck}장`, `${o.deck}장`,
`시작 ${formatWon(o.startingChips)}`, `시작 ${formatWon(o.startingChips)}`,
`기본금 ${formatWon(o.baseUnit)}`, `기본금 ${formatWon(o.baseUnit)}`,
@@ -427,7 +444,9 @@ function Rules({ options }: { options?: SeotdaOptions }) {
<p> <p>
<strong>진행</strong>: 판마다 모두 <strong>기본금</strong>을 판돈에 내요. 선부터 패를 받고 차례로 베팅해요. <strong>진행</strong>: 판마다 모두 <strong>기본금</strong>을 판돈에 내요. 선부터 패를 받고 차례로 베팅해요.
{o?.cardMode === 'three' {o?.cardMode === 'three'
? ' 3장 섯다는 2장을 받고 베팅 → 1장을 더 받아 3장 중 쓸 2장을 몰래 고르고 → 마지막 베팅 후 공개해요. 버린 1장은 끝까지 아무도 못 봐요.' ? o.threeOpen && o.threePick === 'end'
? ' 3장 섯다(한게임)는 2장을 받아 그중 1장을 골라 모두에게 보여 주고(공개패) → 첫 베팅 → 1장을 더 받아 → 마지막 베팅 → 3장 중 쓸 2장을 골라 공개해요. 버린 1장은 공개패가 아니면 끝까지 아무도 못 봐요.'
: ` 3장 섯다는 2장을 받고${o.threeOpen ? ' 1장을 골라 모두에게 보여 준 뒤' : ''} 베팅 → 1장을 더 받아 ${o.threePick === 'end' ? '마지막 베팅 → 3장 중 쓸 2장을 골라 공개해요' : '3장 중 쓸 2장을 몰래 고르고 → 마지막 베팅 후 공개해요'}. 버린 1장은 끝까지 아무도 못 봐요.`
: o?.dealMode === 'twoRounds' : o?.dealMode === 'twoRounds'
? ' 1장 받고 베팅, 1장 더 받고 베팅한 뒤 남은 사람끼리 패를 공개해요.' ? ' 1장 받고 베팅, 1장 더 받고 베팅한 뒤 남은 사람끼리 패를 공개해요.'
: ' 2장을 한 번에 받고 한 번 베팅한 뒤 남은 사람끼리 패를 공개해요.'}{' '} : ' 2장을 한 번에 받고 한 번 베팅한 뒤 남은 사람끼리 패를 공개해요.'}{' '}

View File

@@ -16,7 +16,9 @@
| 옵션 키 | 설명 | 선택지 | 기본값 | | 옵션 키 | 설명 | 선택지 | 기본값 |
|---|---|---|---| |---|---|---|---|
| `cardMode` | 게임 방식: 2장 섯다 / 3장 섯다(3장 받아 2장 선택) | `two` / `three` | `two` | | `cardMode` | 게임 방식: 2장 섯다 / 3장 섯다(3장 받아 2장 선택) | `two` / `three` | `two` |
| `dealMode` | 2장 섯다 패 받기 | `oneRound`(2장 한 번에 받고 베팅 1회, 한게임 2장 섯다) / `twoRounds`(1장 받고 베팅, 1장 더 받고 베팅) | `oneRound` | | `dealMode` | 2장 섯다 패 받기 | `oneRound`(2장 한 번에 받고 베팅 1회, 한게임 2장 섯다) / `twoRounds`(1장 받고 베팅, 1장 더 받고 베팅, 전통 규칙) | `oneRound` |
| `threeOpen` | 3장 섯다 공개패: 처음 2장 중 1장을 골라 모두에게 보여 줌 | 켬(한게임) / 끔 | 켬 |
| `threePick` | 3장 섯다 최종 2장 고르는 때 | `end`(마지막 베팅 뒤, 한게임) / `beforeBet`(3번째 패를 받자마자, 마지막 베팅 전) | `end` |
| `deck` | 화투 장수 | `20`(1~10월 광·열끗과 띠, 8월은 기러기) / `40`(1~10월 4장 모두, 피 포함) | `20` | | `deck` | 화투 장수 | `20`(1~10월 광·열끗과 띠, 8월은 기러기) / `40`(1~10월 4장 모두, 피 포함) | `20` |
| `startingChips` | 시작 금액(원) | 50만 / 100만 / 200만 / 500만 | 100만원 | | `startingChips` | 시작 금액(원) | 50만 / 100만 / 200만 / 500만 | 100만원 |
| `baseUnit` | 기본금 = 판마다 모두 내는 돈 = 삥 금액(원) | 2,000 / 1만 / 2만 / 5만 | 1만원 | | `baseUnit` | 기본금 = 판마다 모두 내는 돈 = 삥 금액(원) | 2,000 / 1만 / 2만 / 5만 | 1만원 |
@@ -92,11 +94,18 @@
### 5.2 3장 섯다 (`cardMode=three`) ### 5.2 3장 섯다 (`cardMode=three`)
1. 기본금 → 2장씩 나눠 줌(비공개) → 1차 베팅. 기본(한게임 3장 섯다, 2026-10-13 인터넷 규칙 다시 확인):
2. 남은 사람에게 1장 더(비공개, 손에 3장). 1. 기본금 → 2장씩 나눠 줌(비공개).
3. 선택 단계(동시 진행): 각자 3장 중 2장을 고른다. 고르지 않은 1장은 뒷면으로 버리며 끝까지 아무에게도 공개하지 않는다. 2. 공개패 고르기(동시 진행, `threeOpen`): 각자 2장 중 1장을 골라 모두에게 앞면으로 보여 준다. 시간이 지나면(또는 나간 사람은) 낮은 월의 패가 공개된다.
4. 2차 베팅 → 쇼다운(고른 2장으로 판정). 3. 1구 베팅(선부터).
- 선택은 2차 베팅 전에 확정되므로 마지막 베팅은 확정된 패로 한다. 4. 남은 사람에게 1장 더(비공개, 손에 3장).
5. 2구 베팅.
6. 2명 이상 남으면 최종 패 고르기(동시 진행): 각자 3장 중 2장을 고른다. 시간이 지나면 가장 센 조합. 2구 베팅에서 한 사람만 남으면 고르지 않고 끝난다.
7. 쇼다운(고른 2장으로 판정). 버린 1장은 공개패가 아니면 끝까지 아무에게도 보이지 않는다(공개패를 버리면 다른 사람 화면에서 그 패가 빠진다).
옵션: `threeOpen=끔`이면 2단계가 없다. `threePick=beforeBet`이면 4단계 직후에 2장을 고르고(뒷면 2장만 남김) 그다음 마지막 베팅 → 쇼다운(2026-10-13 이전의 3장 섯다 흐름). 진행 중이던 방(상태 버전 2)은 버전 3으로 옮길 때 예전 흐름(공개패 없음, 베팅 전 고르기)을 그대로 쓴다.
근거: 한게임 섯다 안내 "3장 섯다: 2장을 먼저 받고 베팅 한 후 패 1장을 더 받고 베팅을 한 번 더 하는 게임방식", "2장 섯다: 전통적인 섯다 방식으로 화투패 2장을 모두 받은 다음 베팅하여 승부"(hangame-images.toastoven.net/hangame/pc/gostop/introduce/html/gssudda/guide_gssudda01_02.html). 한게임 앱 안내(블루스택 공략): "패를 2장 받고, 2장의 패 중 모두에게 공개할 패를 1장 선택 → 1구 베팅 → 추가 패 → 3장의 패 중 최종 패 선택". 나무위키 '섰다': 인터넷 3장 섯다(한게임/피망)는 2장 받고 1장 공개 → 첫 베팅 → 1장 더 → 두 번째 베팅 → 가장 좋은 2장으로 승부.
### 5.3 선(先) ### 5.3 선(先)
@@ -346,7 +355,8 @@ type SpecialKind = 'ttaengjabi' | 'amhaeng' | 'gusa' | 'mungGusa';
interface SeotdaHand { interface SeotdaHand {
handNo: number; // 재경기는 같은 handNo handNo: number; // 재경기는 같은 handNo
rematchNo: number; // 0 = 본 판, 1..3 = 재경기 차수 rematchNo: number; // 0 = 본 판, 1..3 = 재경기 차수
phase: 'dealing' | 'betting' | 'choose' | 'rejoin' | 'showdown' | 'handEnd'; phase: 'dealing' | 'open' | 'betting' | 'choose' | 'rejoin' | 'showdown' | 'handEnd';
opened: Record<PlayerId, number | null>; // 3장 섯다 공개패
dealerSeat: number; // 선 dealerSeat: number; // 선
deck: HwatuCard[]; // 남은 덱(비공개) deck: HwatuCard[]; // 남은 덱(비공개)
players: Record<PlayerId, RoundPlayer>; // 이번 (재)경기 참가자 players: Record<PlayerId, RoundPlayer>; // 이번 (재)경기 참가자
@@ -388,6 +398,7 @@ interface SeotdaState {
| `quarter` / `half` | - | 내 차례 | 레이즈 가능, 낼 금액 > `toCall` | | `quarter` / `half` | - | 내 차례 | 레이즈 가능, 낼 금액 > `toCall` |
| `full` | - | 내 차례 | 위 + `maxRaise=full` | | `full` | - | 내 차례 | 위 + `maxRaise=full` |
| `die` | - | 내 차례 | 항상 | | `die` | - | 내 차례 | 항상 |
| `open` | `{ cardId: number }` | `phase=open`(3장 섯다 공개패), 남은 참가자(동시) | 내 손패 2장 중 하나, 아직 미공개. 시간 초과·나감 = 낮은 월 |
| `choose` | `{ cardIds: [number, number] }` | `phase=choose`(3장 섯다), 남은 참가자(동시, 올인 포함) | 두 id가 내 손패에 있고 서로 다름, 아직 미선택 | | `choose` | `{ cardIds: [number, number] }` | `phase=choose`(3장 섯다), 남은 참가자(동시, 올인 포함) | 두 id가 내 손패에 있고 서로 다름, 아직 미선택 |
| `rejoin` | `{ accept: boolean }` | `phase=rejoin`, `rejoinPending`에 있는 사람 | `accept=true`면 스택 ≥ 재참가 비용 | | `rejoin` | `{ accept: boolean }` | `phase=rejoin`, `rejoinPending`에 있는 사람 | `accept=true`면 스택 ≥ 재참가 비용 |
| `ready` | - | `phase=handEnd` | 미준비 | | `ready` | - | `phase=handEnd` | 미준비 |

View File

@@ -1519,6 +1519,41 @@ const PLANS: Record<string, Plan> = {
await pages[1]!.screenshot({ path: join(SHOTS, 'seotda-result-phone.png'), fullPage: true }); await pages[1]!.screenshot({ path: join(SHOTS, 'seotda-result-phone.png'), fullPage: true });
}, },
}, },
seotda3: {
// 3장 섯다 (한게임): 2장 → 각자 공개패 1장 고르기(다른 사람 화면에 앞면) → 1구 베팅 → 1장 더 → 2구 베팅 →
// 3장 중 2장 고르기 → 공개. Everyone opens, checks/calls through both rounds and picks the recommended pair.
game: 'seotda',
players: 3,
lobby: async (host) => {
await host.getByRole('button', { name: /^3장 섯다/ }).first().click();
},
drive: async (pages) => {
for (const p of pages) {
const box = p.getByRole('group', { name: '공개패 고르기' });
await box.waitFor({ timeout: 10_000 });
await box.locator('button, [role="button"]').first().click();
await p.getByRole('button', { name: /패 공개하기$/ }).click();
}
// The others now see one face-up card of each player.
await pages[0]!.waitForFunction(() => document.querySelectorAll('.sd-seat .sd-cards img, .sd-seat .sd-cards svg').length > 0, null, { timeout: 5000 }).catch(() => {});
await pages[0]!.screenshot({ path: join(SHOTS, 'seotda3-open-pc.png') });
for (let n = 0; n < 40 && !(await pages[0]!.getByRole('button', { name: /정하기$|두 장을 고르세요/ }).count()) && !(await pages[0]!.getByText('이번 판 결과').count()); n++) {
// Nobody raises, so every action is a 체크 (콜 stays disabled and would hide it from pressActions).
await pressActions(pages, /^체크/, 1).catch(() => {});
}
await pages[0]!.screenshot({ path: join(SHOTS, 'seotda3-choose-pc.png') });
if (await pages[0]!.getByText('자리 비움').count()) throw new Error('someone timed out (the plan should act for everybody)');
for (const p of pages) {
const rec = p.getByRole('button', { name: /\(추천\)$/ });
if (await rec.count()) {
await rec.first().click();
await p.getByRole('button', { name: /정하기$/ }).click();
}
}
await finishHand(pages);
await pages[1]!.screenshot({ path: join(SHOTS, 'seotda3-result-phone.png'), fullPage: true });
},
},
poker: { poker: {
// 3 players, default 7포커: 초이스 (discard 1st card, open 2nd), then everyone checks 4 streets → showdown. // 3 players, default 7포커: 초이스 (discard 1st card, open 2nd), then everyone checks 4 streets → showdown.
players: 3, players: 3,

View File

@@ -145,8 +145,14 @@ describe('seotda bot', () => {
expect(decide(s, 'A').type).toBe('half'); expect(decide(s, 'A').type).toBe('half');
}); });
test('3장 섯다 공개패: 광은 숨기고 평범한 패를 보여 줘요', () => {
const s = rig(make({ cardMode: 'three' }), { A: [S(3), P(5)], B: [P(4), P(7)], C: [P(2), P(3)] });
expect(s.hand!.phase).toBe('open');
expect(decide(s, 'A')).toEqual({ type: 'open', cardId: P(5) });
});
test('3장 섯다: keeps the best pair of its three cards', () => { test('3장 섯다: keeps the best pair of its three cards', () => {
let s = make({ cardMode: 'three' }); 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)]); s = rig(s, { A: [P(4), P(9)], B: [P(5), P(7)], C: [P(2), P(3)] }, [P(6), S(2), S(5)]);
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: 'check' });
expect(s.hand!.phase).toBe('choose'); expect(s.hand!.phase).toBe('choose');

View File

@@ -54,12 +54,19 @@ export function rangesOf(v: SeotdaView, me: string): { id: string; weight: Range
const partialStreet0 = v.options.cardMode === 'three' || v.options.dealMode === 'twoRounds'; const partialStreet0 = v.options.cardMode === 'three' || v.options.dealMode === 'twoRounds';
return live.map((s) => { return live.map((s) => {
const mine = entries.filter((e) => e.p === s.id && !e.forced); const mine = entries.filter((e) => e.p === s.id && !e.forced);
if (!mine.length) return { id: s.id, weight: () => 1 }; // 3장 섯다 공개패: every hand they may hold contains the card they showed.
const shown = s.cards.flatMap((c) => ('id' in c ? [c.id] : []));
const holds = (cards: number[]) => shown.every((c) => cards.includes(c));
if (!mine.length) return { id: s.id, weight: shown.length ? (cards: number[]) => (holds(cards) ? 1 : 0) : () => 1 };
const memo = new Map<number, number>(); const memo = new Map<number, number>();
const weight: RangeWeight = (cards) => { const weight: RangeWeight = (cards) => {
const key = cardsKey(cards); const key = cardsKey(cards);
const hit = memo.get(key); const hit = memo.get(key);
if (hit !== undefined) return hit; if (hit !== undefined) return hit;
if (!holds(cards)) {
memo.set(key, 0);
return 0;
}
const p = strengthPercentile(cards, rules, deck, finalSize); const p = strengthPercentile(cards, rules, deck, finalSize);
let w = 1; let w = 1;
let raises = 0; let raises = 0;
@@ -197,6 +204,19 @@ 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; 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; return legal.find((a) => a.type === 'rejoin' && a.accept === join) ?? first;
} }
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');
// A 광 or a 4·7·9 열끗 (special hands) tells most, then a high month: show the plainest card.
const tells = (c: number) => {
const card = (v.seats.find((x) => x.id === me)?.cards ?? []).find((x) => 'id' in x && x.id === c);
if (!card || !('id' in card)) return 0;
if (card.kind === 'gwang') return 3;
if (card.kind === 'yeol' && [4, 7, 9].includes(card.month)) return 2;
return card.month / 10;
};
return humanBest(opens, (a) => -tells(a.cardId), random, level, { small: 0.05, critical: 2 });
}
case 'choose': { case 'choose': {
// 3장 섯다: keep the pair with the best share of the pot against what the others may hold (specials included). // 3장 섯다: keep the pair with the best share of the pot against what the others may hold (specials included).
const chooses = legal.filter((a): a is Extract<SeotdaAction, { type: 'choose' }> => a.type === 'choose'); const chooses = legal.filter((a): a is Extract<SeotdaAction, { type: 'choose' }> => a.type === 'choose');

View File

@@ -51,7 +51,17 @@ export const seotdaOptionsSchema = z
dealMode: z dealMode: z
.enum(['oneRound', 'twoRounds']) .enum(['oneRound', 'twoRounds'])
.default('oneRound') .default('oneRound')
.meta({ title: '2장 섯다 패 받기', labels: { oneRound: '2장 한 번에 받고 베팅 1번', twoRounds: '1장씩 두 번 받고 베팅 2번' } }), .meta({ title: '2장 섯다 패 받기', labels: { oneRound: '2장 한 번에 받고 베팅 1번(한게임)', twoRounds: '1장씩 두 번 받고 베팅 2번(전통)' } }),
threeOpen: z
.boolean()
.default(true)
.catch(true)
.meta({ title: '3장 섯다 공개패(2장 중 1장을 모두에게 보여 주기, 한게임)' }),
threePick: z
.enum(['end', 'beforeBet'])
.default('end')
.catch('end')
.meta({ title: '3장 섯다 최종 2장 고르기', labels: { end: '마지막 베팅 뒤(한게임)', beforeBet: '마지막 베팅 전' } }),
deck: lit(20, 40) deck: lit(20, 40)
.default(20) .default(20)
.catch(20) .catch(20)
@@ -139,6 +149,7 @@ export const seotdaActionSchema = z.discriminatedUnion('type', [
z.object({ type: z.literal('full') }), z.object({ type: z.literal('full') }),
z.object({ type: z.literal('die') }), z.object({ type: z.literal('die') }),
z.object({ type: z.literal('choose'), cardIds: z.tuple([z.number().int(), z.number().int()]) }), 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('rejoin'), accept: z.boolean() }),
z.object({ type: z.literal('ready') }), z.object({ type: z.literal('ready') }),
z.object({ type: z.literal('rebuy'), accept: z.boolean() }), z.object({ type: z.literal('rebuy'), accept: z.boolean() }),
@@ -193,7 +204,8 @@ export interface SeotdaHand {
handNo: number; handNo: number;
/** 0 = 본 판, 1.. = 재경기 차수. */ /** 0 = 본 판, 1.. = 재경기 차수. */
rematchNo: number; rematchNo: number;
phase: 'betting' | 'choose' | 'rejoin' | 'handEnd'; /** `open`: 3장 섯다 공개패 고르기 (before the first bet). */
phase: 'open' | 'betting' | 'choose' | 'rejoin' | 'handEnd';
dealer: PlayerId; dealer: PlayerId;
/** Participants of this (re)match, from the dealer clockwise. */ /** Participants of this (re)match, from the dealer clockwise. */
order: PlayerId[]; order: PlayerId[];
@@ -202,6 +214,8 @@ export interface SeotdaHand {
cards: Record<PlayerId, number[]>; cards: Record<PlayerId, number[]>;
/** 3장 섯다: chosen pair (secret until showdown). */ /** 3장 섯다: chosen pair (secret until showdown). */
chosen: Record<PlayerId, [number, number] | null>; chosen: Record<PlayerId, [number, number] | null>;
/** 3장 섯다 공개패: the card each player shows everyone (null = not yet). */
opened: Record<PlayerId, number | null>;
betting: BettingState | null; betting: BettingState | null;
street: 0 | 1; street: 0 | 1;
/** Bet counter (deadline key). */ /** Bet counter (deadline key). */
@@ -298,6 +312,8 @@ export interface SeotdaSeatView {
cards: CardSlot[]; cards: CardSlot[];
/** 3장 섯다 choose phase: has chosen (null outside that phase). */ /** 3장 섯다 choose phase: has chosen (null outside that phase). */
chosen: boolean | null; chosen: boolean | null;
/** 3장 섯다 공개패 phase: has picked the card to show (null outside that phase). */
opening: boolean | null;
isDealer: boolean; isDealer: boolean;
isTurn: boolean; isTurn: boolean;
ready: boolean; ready: boolean;
@@ -333,6 +349,8 @@ export interface SeotdaView {
myHand: { name: string; value: number | null; special: SpecialKind | null; hint: string; strength: 'high' | 'mid' | 'low' | null } | null; 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; myCombos: { cardIds: [number, number]; name: string; value: number; best: boolean }[] | null;
myChosen: [number, number] | null; myChosen: [number, number] | null;
/** 3장 섯다: the card I show everyone (공개패). */
myOpened: number | null;
myDiscard: SeotdaCardView | null; myDiscard: SeotdaCardView | null;
rejoin: { pending: PlayerId[]; cost: number; mine: boolean; canAfford: boolean } | null; rejoin: { pending: PlayerId[]; cost: number; mine: boolean; canAfford: boolean } | null;
rebuy: { pending: PlayerId[]; mine: boolean; left: number | null } | null; rebuy: { pending: PlayerId[]; mine: boolean; left: number | null } | null;
@@ -489,6 +507,7 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
deck: rng.shuffle(deckOf(o)), deck: rng.shuffle(deckOf(o)),
cards: Object.fromEntries(order.map((id) => [id, []])), cards: Object.fromEntries(order.map((id) => [id, []])),
chosen: Object.fromEntries(order.map((id) => [id, null])), chosen: Object.fromEntries(order.map((id) => [id, null])),
opened: Object.fromEntries(order.map((id) => [id, null])),
betting: b, betting: b,
street: 0, street: 0,
betSeq: 0, betSeq: 0,
@@ -511,6 +530,15 @@ function startHand(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
events.push({ type: 'handStart', handNo: h.handNo, rematchNo: 0, dealer, ante: s.baseUnit }); events.push({ type: 'handStart', handNo: h.handNo, rematchNo: 0, dealer, ante: s.baseUnit });
deal(h, order, firstDealCount(o), events); deal(h, order, firstDealCount(o), events);
h.betting = startRound(b, 0); h.betting = startRound(b, 0);
if (opensFirst(o)) h.phase = 'open';
}
/** 3장 섯다 (한게임): 2장을 받으면 먼저 1장을 골라 모두에게 보여 준 뒤 첫 베팅. */
const opensFirst = (o: SeotdaOptions) => o.cardMode === 'three' && o.threeOpen;
/** 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]!;
} }
function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void { function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
@@ -527,6 +555,7 @@ function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
h.deck = rng.shuffle(deckOf(s.options)); h.deck = rng.shuffle(deckOf(s.options));
h.cards = Object.fromEntries(order.map((id) => [id, []])); h.cards = Object.fromEntries(order.map((id) => [id, []]));
h.chosen = Object.fromEntries(order.map((id) => [id, null])); h.chosen = Object.fromEntries(order.map((id) => [id, null]));
h.opened = Object.fromEntries(order.map((id) => [id, null]));
h.showdown = null; h.showdown = null;
h.foldWin = null; h.foldWin = null;
h.next = null; h.next = null;
@@ -546,6 +575,7 @@ function startRematch(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
events.push({ type: 'handStart', handNo: h.handNo, rematchNo: h.rematchNo, dealer, ante: 0, reason: h.rematchReason }); 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, firstDealCount(s.options), events);
h.betting = startRound(b, 0); 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. */ /** Pots of the current match: carried (re-filtered by who is still in) + this match's bets. */
@@ -838,6 +868,12 @@ function chooseFor(s: SeotdaState, id: PlayerId, pair: [number, number], events:
events.push({ type: 'chose', player: id }); events.push({ type: 'chose', player: id });
} }
function openFor(s: SeotdaState, id: PlayerId, card: number, events: GameEvent[]): void {
const h = s.hand!;
h.opened[id] = card;
events.push({ type: 'opened', player: id });
}
function requiredReady(s: SeotdaState): PlayerId[] { function requiredReady(s: SeotdaState): PlayerId[] {
return s.seats.filter((x) => x.status === 'playing' && !x.left).map((x) => x.id); return s.seats.filter((x) => x.status === 'playing' && !x.left).map((x) => x.id);
} }
@@ -874,9 +910,19 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
settleFold(s, events); settleFold(s, events);
continue; continue;
} }
// 3장 섯다: 2장 → 베팅 → 1장 더 → 3장 중 2장 몰래 고르기 → 마지막 베팅 → 공개. // 3장 섯다(한게임): 2장 → 공개패 1장 → 1구 베팅 → 1장 더 → 2구 베팅 → 3장 중 2장 고르기 → 공개.
// threePick=beforeBet: 1장 더 → 2장 고르기 → 마지막 베팅 → 공개.
if (h.street === 0 && s.options.cardMode === 'three') { if (h.street === 0 && s.options.cardMode === 'three') {
deal(h, h.order.filter((id) => contendersOf(h).includes(id)), 1, events); deal(h, h.order.filter((id) => contendersOf(h).includes(id)), 1, events);
if (s.options.threePick === 'beforeBet') h.phase = 'choose';
else {
h.street = 1;
h.lastAction = {};
h.betting = startRound(h.betting, 0);
}
continue;
}
if (s.options.cardMode === 'three' && contendersOf(h).some((id) => !h.chosen[id])) {
h.phase = 'choose'; h.phase = 'choose';
continue; continue;
} }
@@ -895,6 +941,8 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
for (const id of waiting) if (seatOf(s, id)!.left) chooseFor(s, id, bestChoice(h.cards[id]!, rulesOf(s.options)), events); for (const id of waiting) if (seatOf(s, id)!.left) chooseFor(s, id, bestChoice(h.cards[id]!, rulesOf(s.options)), events);
if (contendersOf(h).every((id) => h.chosen[id])) { if (contendersOf(h).every((id) => h.chosen[id])) {
h.phase = 'betting'; h.phase = 'betting';
// Chosen after the last bet (한게임): straight to the showdown (the betting round is already over).
if (h.street === 1) continue;
h.street = 1; h.street = 1;
h.lastAction = {}; h.lastAction = {};
h.betting = startRound(h.betting!, 0); h.betting = startRound(h.betting!, 0);
@@ -902,6 +950,14 @@ function progress(s: SeotdaState, rng: Rng, events: GameEvent[]): void {
} }
return; return;
} }
case 'open': {
for (const id of contendersOf(h)) if (h.opened[id] === null && seatOf(s, id)!.left) openFor(s, id, autoOpen(h.cards[id]!), events);
if (contendersOf(h).every((id) => h.opened[id] !== null)) {
h.phase = 'betting';
continue;
}
return;
}
case 'rejoin': { case 'rejoin': {
for (const id of [...h.rejoinPending]) if (seatOf(s, id)!.left) decideRejoin(s, id, false, events); for (const id of [...h.rejoinPending]) if (seatOf(s, id)!.left) decideRejoin(s, id, false, events);
if (h.rejoinPending.length === 0) { if (h.rejoinPending.length === 0) {
@@ -967,7 +1023,7 @@ function refreshDeadline(s: SeotdaState, now: number): void {
key += `|${id}|${h.betSeq}`; key += `|${id}|${h.betSeq}`;
// 시간 무제한 방에서도 자리 비움(연속 시간 초과)은 없으니 기다린다. // 시간 무제한 방에서도 자리 비움(연속 시간 초과)은 없으니 기다린다.
ms = o.turnSeconds === null ? null : seatOf(s, id)!.away ? AWAY_MS : o.turnSeconds * 1000; ms = o.turnSeconds === null ? null : seatOf(s, id)!.away ? AWAY_MS : o.turnSeconds * 1000;
} else if (h.phase === 'choose') ms = o.turnSeconds === null ? null : (o.turnSeconds + 10) * 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 === 'rejoin') ms = o.decisionSeconds * 1000;
else if (h.phase === 'handEnd') ms = HAND_END_MS; else if (h.phase === 'handEnd') ms = HAND_END_MS;
} }
@@ -988,6 +1044,8 @@ function waiting(s: SeotdaState): PlayerId[] {
return h.betting?.turn != null ? [h.betting.players[h.betting.turn]!.id] : []; return h.betting?.turn != null ? [h.betting.players[h.betting.turn]!.id] : [];
case 'choose': case 'choose':
return contendersOf(h).filter((id) => !h.chosen[id]); return contendersOf(h).filter((id) => !h.chosen[id]);
case 'open':
return contendersOf(h).filter((id) => h.opened[id] === null);
case 'rejoin': case 'rejoin':
return [...h.rejoinPending]; return [...h.rejoinPending];
case 'handEnd': case 'handEnd':
@@ -1005,15 +1063,22 @@ function isBet(t: string): t is BetType {
*/ */
const MONEY_V1 = 1000; const MONEY_V1 = 1000;
function migrateSeotda(old: unknown, from: number): SeotdaState { function migrateSeotda(old: unknown, from: number): SeotdaState {
const s = structuredClone(old) as SeotdaState; let s = structuredClone(old) as SeotdaState;
if (from >= 2) return s; if (from < 2) {
const o = s.options as SeotdaOptions & Record<string, unknown>; const o = s.options as SeotdaOptions & Record<string, unknown>;
s.options = { ...o, deck: 20, betRule: 'free', quarter: true } as SeotdaOptions; s.options = { ...o, deck: 20, betRule: 'free', quarter: true } as SeotdaOptions;
if (s.hand) { if (s.hand) {
s.hand.forced = 0; s.hand.forced = 0;
s.hand.log = []; s.hand.log = [];
}
s = scaleMoney(s, MONEY_V1);
} }
return scaleMoney(s, MONEY_V1); if (from < 3) {
// v2 → v3 (3장 섯다 공개패·최종 선택 시점): games in progress keep the old 3장 flow (no 공개패, choose before the last bet).
s.options = { ...s.options, threeOpen: false, threePick: 'beforeBet' };
if (s.hand) s.hand.opened = Object.fromEntries(s.hand.order.map((id) => [id, null]));
}
return s;
} }
/** Multiplies every amount of a state by `k` (in place): options, stacks, pots, bets, history. Integers stay integers for k ≥ 1. */ /** Multiplies every amount of a state by `k` (in place): options, stacks, pots, bets, history. Integers stay integers for k ≥ 1. */
@@ -1061,7 +1126,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
nameKo: '섯다', nameKo: '섯다',
minPlayers: 2, minPlayers: 2,
maxPlayers: 10, maxPlayers: 10,
stateVersion: 2, stateVersion: 3,
migrate: migrateSeotda, migrate: migrateSeotda,
defaultOptions: seotdaOptionsSchema.parse({}), defaultOptions: seotdaOptionsSchema.parse({}),
optionsSchema: seotdaOptionsSchema as unknown as z.ZodType<SeotdaOptions>, optionsSchema: seotdaOptionsSchema as unknown as z.ZodType<SeotdaOptions>,
@@ -1143,6 +1208,13 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
if (x === y || !mine.includes(x) || !mine.includes(y)) return fail('카드 두 장을 골라 주세요.'); if (x === y || !mine.includes(x) || !mine.includes(y)) return fail('카드 두 장을 골라 주세요.');
return ok; return ok;
} }
case 'open': {
if (h.phase !== 'open') return fail('지금은 공개할 패를 고를 때가 아니에요.');
if (!contendersOf(h).includes(actor)) return fail('이번 판에 남아 있지 않아요.');
if (h.opened[actor] !== null) return fail('이미 공개패를 골랐어요.');
if (!(h.cards[actor] ?? []).includes(a.cardId)) return fail('내 패 중에서 골라 주세요.');
return ok;
}
case 'rejoin': { case 'rejoin': {
if (h.phase !== 'rejoin' || !h.rejoinPending.includes(actor)) return fail('재참가 대상이 아니에요.'); if (h.phase !== 'rejoin' || !h.rejoinPending.includes(actor)) return fail('재참가 대상이 아니에요.');
if (a.accept && st.stack < h.rejoinCost) return fail('보유 금액이 모자라 재참가할 수 없어요.'); if (a.accept && st.stack < h.rejoinCost) return fail('보유 금액이 모자라 재참가할 수 없어요.');
@@ -1172,6 +1244,9 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
case 'choose': case 'choose':
chooseFor(s, actor, a.cardIds, events); chooseFor(s, actor, a.cardIds, events);
break; break;
case 'open':
openFor(s, actor, a.cardId, events);
break;
case 'rejoin': case 'rejoin':
decideRejoin(s, actor, a.accept, events); decideRejoin(s, actor, a.accept, events);
break; break;
@@ -1188,7 +1263,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
break; break;
case 'timeout': { case 'timeout': {
const phase = s.phase === 'rebuy' ? 'rebuy' : h!.phase; const phase = s.phase === 'rebuy' ? 'rebuy' : h!.phase;
if (phase === 'betting' || phase === 'choose') { if (phase === 'betting' || phase === 'choose' || phase === 'open') {
st.timeoutsInRow += 1; st.timeoutsInRow += 1;
if (st.timeoutsInRow >= 2 && !st.away) { if (st.timeoutsInRow >= 2 && !st.away) {
st.away = true; st.away = true;
@@ -1202,6 +1277,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
const t = toType(timeoutBet(b, idx).kind); const t = toType(timeoutBet(b, idx).kind);
applyBetAction(s, actor, betsFor(s, h!, idx).some((l) => l.type === t) ? t : 'die', events); 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 === '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 === 'rejoin') decideRejoin(s, actor, false, events); else if (phase === 'rejoin') decideRejoin(s, actor, false, events);
else if (phase === 'handEnd') h!.ready.push(actor); else if (phase === 'handEnd') h!.ready.push(actor);
else decideRebuy(s, actor, false, events); else decideRebuy(s, actor, false, events);
@@ -1229,9 +1305,12 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
slots = pair.map((c) => cardView(h, c)); 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 === viewer) slots = cards.map((c) => cardView(h, c));
else { else {
// 3장 섯다 after choosing: others see two face-down cards (the discard stays secret). // 3장 섯다: the 공개패 is face up for everyone; after choosing, others see the two kept cards (the discard stays
const n = o.cardMode === 'three' && h?.chosen[x.id] ? 2 : cards.length; // secret, so a 공개패 that was thrown away is no longer shown).
slots = Array.from({ length: n }, () => ({ hidden: true as const })); const shown = h?.opened[x.id] ?? null;
const chosen = o.cardMode === 'three' ? (h?.chosen[x.id] ?? null) : null;
const kept = chosen ? [...chosen] : cards;
slots = kept.map((c) => (c === shown ? cardView(h!, c) : { hidden: true as const }));
} }
return { return {
id: x.id, id: x.id,
@@ -1247,6 +1326,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
matchBet: better?.total ?? 0, matchBet: better?.total ?? 0,
cards: slots, cards: slots,
chosen: h?.phase === 'choose' && contendersOf(h).includes(x.id) ? !!h.chosen[x.id] : null, chosen: h?.phase === 'choose' && contendersOf(h).includes(x.id) ? !!h.chosen[x.id] : null,
opening: h?.phase === 'open' && contendersOf(h).includes(x.id) ? h.opened[x.id] !== null : null,
isDealer: h?.dealer === x.id, isDealer: h?.dealer === x.id,
isTurn: !!b && b.turn !== null && h?.phase === 'betting' && b.players[b.turn]!.id === x.id, 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), ready: !!h && h.phase === 'handEnd' && h.ready.includes(x.id),
@@ -1286,7 +1366,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
} }
} }
} }
const pots: PotState[] = h ? (b && (h.phase === 'betting' || h.phase === 'choose') ? currentPots(h) : h.carried) : []; const pots: PotState[] = h ? (b && (h.phase === 'betting' || h.phase === 'choose' || h.phase === 'open') ? currentPots(h) : h.carried) : [];
return { return {
options: o, options: o,
me, me,
@@ -1310,6 +1390,7 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
myHand, myHand,
myCombos, myCombos,
myChosen, myChosen,
myOpened: h && me ? (h.opened[me] ?? null) : null,
myDiscard, myDiscard,
rejoin: rejoin:
h?.phase === 'rejoin' h?.phase === 'rejoin'
@@ -1374,6 +1455,9 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
case 'choose': case 'choose':
if (!contendersOf(h).includes(p) || h.chosen[p]) return []; if (!contendersOf(h).includes(p) || h.chosen[p]) return [];
return combos(h.cards[p]!).map((c) => ({ type: 'choose', cardIds: c }) as SeotdaAction); return combos(h.cards[p]!).map((c) => ({ type: 'choose', cardIds: c }) as SeotdaAction);
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 'rejoin': case 'rejoin':
if (!h.rejoinPending.includes(p)) return []; if (!h.rejoinPending.includes(p)) return [];
return st.stack >= h.rejoinCost ? [{ type: 'rejoin', accept: true }, { type: 'rejoin', accept: false }] : [{ type: 'rejoin', accept: false }]; return st.stack >= h.rejoinCost ? [{ type: 'rejoin', accept: true }, { type: 'rejoin', accept: false }] : [{ type: 'rejoin', accept: false }];
@@ -1387,6 +1471,8 @@ export const seotda: GameDefinition<SeotdaState, SeotdaAction, SeotdaView, Seotd
const h = s.hand; const h = s.hand;
if (!h) return []; if (!h) return [];
const revealed = new Set(h.showdown?.hands.find((x) => x.id === player)?.cards ?? []); 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);
const key = (c: number) => `h${h.handNo}r${h.rematchNo}c${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); const own = (h.cards[player] ?? []).filter((c) => !revealed.has(c)).map(key);
return [...own, ...h.deck.map(key)]; return [...own, ...h.deck.map(key)];

View File

@@ -449,9 +449,9 @@ describe('재경기', () => {
}); });
}); });
describe('3장 섯다', () => { describe('3장 섯다 (옵션: 공개패 없이, 마지막 베팅 전에 고르기)', () => {
function three() { function three() {
let s = make({ cardMode: 'three' }); 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)] }, [S(4), P(9), P(10)]); s = rig(s, { A: [S(1), S(8)], B: [P(5), P(6)], C: [P(2), P(7)] }, [S(4), P(9), P(10)]);
s = act(s, 'A', { type: 'check' }); s = act(s, 'A', { type: 'check' });
s = act(s, 'B', { type: 'check' }); s = act(s, 'B', { type: 'check' });
@@ -510,6 +510,76 @@ describe('3장 섯다', () => {
}); });
}); });
describe('3장 섯다 (한게임 기본: 2장 → 공개패 1장 → 1구 베팅 → 1장 더 → 2구 베팅 → 2장 고르기)', () => {
function opened() {
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)]);
return s;
}
test('2장을 받으면 먼저 모두 공개할 패 1장을 고르고, 고른 패는 모두에게 앞면으로 보여요', () => {
let s = opened();
expect(s.hand!.phase).toBe('open');
expect(s.hand!.cards.A).toHaveLength(2);
expect(seotda.activePlayers(s).sort()).toEqual(['A', 'B', 'C']);
expect(reject(s, 'A', { type: 'check' })).toBe('지금은 베팅 시간이 아니에요.');
expect(reject(s, 'A', { type: 'open', cardId: P(9) })).toBe('내 패 중에서 골라 주세요.');
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) })]);
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)},`);
expect(seotda.secretsOf!(s, 'A')).not.toContain(`h1r0c${S(8)}`);
s = act(s, 'B', { type: 'open', cardId: P(6) });
s = act(s, 'C', { type: 'timeout' }); // 낮은 월(2월)을 보여 줘요
expect(s.hand!.opened.C).toBe(P(2));
expect(s.hand!.phase).toBe('betting');
expect(s.hand!.street).toBe(0);
expect(seotda.activePlayers(s)).toEqual(['A']);
});
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' });
expect(s.hand!.phase).toBe('betting');
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 }]);
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광땡');
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 }]);
s = act(s, 'B', { type: 'timeout' });
expect(s.hand!.phase).toBe('handEnd');
expect(s.hand!.showdown!.hands.find((x) => x.id === 'A')!.name).toBe('독사');
});
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: 'die' });
s = act(s, 'C', { type: 'die' });
expect(s.hand!.phase).toBe('handEnd');
expect(s.hand!.foldWin!.winner).toBe('A');
});
test('시간 무제한이면 공개패 고르기에도 마감이 없어요', () => {
const s = make({ turnSeconds: null, cardMode: 'three' });
expect(s.hand!.phase).toBe('open');
expect(s.deadlineAt).toBeNull();
});
});
describe('timeouts, away, leaving', () => { describe('timeouts, away, leaving', () => {
test('timeout: check when nobody bet, otherwise die; two in a row → away with a 5 s limit', () => { test('timeout: check when nobody bet, otherwise die; two in a row → away with a 5 s limit', () => {
let s = make(); let s = make();
@@ -701,7 +771,7 @@ describe('한게임 방식 (원 단위, 기본 설정)', () => {
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: 'check' });
expect(s.hand!.phase).toBe('handEnd'); expect(s.hand!.phase).toBe('handEnd');
expect(s.deadlineAt).not.toBeNull(); expect(s.deadlineAt).not.toBeNull();
const three = hg({ turnSeconds: null, cardMode: 'three' }); const three = hg({ turnSeconds: null, cardMode: 'three', threeOpen: false, threePick: 'beforeBet' });
let t = three; let t = three;
for (const p of ['A', 'B', 'C']) t = act(t, p, { type: 'check' }); for (const p of ['A', 'B', 'C']) t = act(t, p, { type: 'check' });
expect(t.hand!.phase).toBe('choose'); expect(t.hand!.phase).toBe('choose');
@@ -731,7 +801,8 @@ describe('한게임 방식 (원 단위, 기본 설정)', () => {
delete h.forced; delete h.forced;
delete h.log; delete h.log;
const m = seotda.migrate!(v1, 1); const m = seotda.migrate!(v1, 1);
expect(seotda.stateVersion).toBe(2); expect(seotda.stateVersion).toBe(3);
expect(m.options).toMatchObject({ threeOpen: false, threePick: 'beforeBet' });
expect([m.options.startingChips, m.options.baseUnit, m.baseUnit]).toEqual([1_000_000, 10_000, 10_000]); expect([m.options.startingChips, m.options.baseUnit, m.baseUnit]).toEqual([1_000_000, 10_000, 10_000]);
expect(m.options).toMatchObject({ deck: 20, betRule: 'free', quarter: true }); expect(m.options).toMatchObject({ deck: 20, betRule: 'free', quarter: true });
expect(m.seats.map((x) => x.stack)).toEqual(s.seats.map((x) => x.stack * 1000)); expect(m.seats.map((x) => x.stack)).toEqual(s.seats.map((x) => x.stack * 1000));