diff --git a/docs/games/seotda.md b/docs/games/seotda.md index 54e7dc7..f2985c0 100644 --- a/docs/games/seotda.md +++ b/docs/games/seotda.md @@ -96,18 +96,19 @@ 기본(한게임 3장 섯다, 2026-10-13 인터넷 규칙 다시 확인): 1. 기본금 → 2장씩 나눠 줌(비공개). -2. 공개패 고르기(동시 진행, `threeOpen`): 각자 2장 중 1장을 골라 모두에게 앞면으로 보여 준다. 시간이 지나면(또는 나간 사람은) 낮은 월의 패가 공개된다. +2. 공개패 고르기(동시 진행, `threeOpen`): 각자 2장 중 1장을 골라 모두에게 앞면으로 보여 준다. 시간이 지나면(또는 나간 사람은) 낮은 월의 패가 공개된다. 공개패는 모든 화면(내 패, 다른 사람 자리, 쇼다운)에서 항상 맨 왼쪽에 놓인다(사용자 요청 2026-10-18). 3. 1구 베팅(선부터). 선은 하프 또는 다이만 할 수 있고(베팅 규칙 222~444면 그 규칙대로), 1구에서는 아무도 체크를 못 한다(선이 다이하면 다음 사람은 체크만 빼고 다 된다, 시간 초과는 다이). 2구는 자유. (2026-10-17, 한게임 3장 섯다: 나무위키 "1라운드 베팅에서 선은 하프나 다이만 가능, 선이 죽으면 그다음 사람은 체크를 제외한 모든 베팅", 한게임 공식 가이드 이미지에서 1구 버튼은 다이·하프만 켜짐.) `threeOpen=끔`이나 `threePick=beforeBet` 변형에는 걸지 않는다. 4. 남은 사람에게 1장 더(비공개, 손에 3장). 화면에서는 **패쪼기**: 새 패가 뒷면으로 와서 위로 밀어 올리면 아래(왼쪽 아래 월 숫자)부터 보이고, 누르거나 Enter면 바로 뒤집힌다. 6초가 지나면 저절로 뒤집힌다. 뒤집기 전에는 내 족보 이름·조합·예상족보를 보여 주지 않는다(새로고침하면 이미 받은 패로 본다). 5. 2구 베팅. 6. 2명 이상 남으면 최종 패 고르기(동시 진행): 각자 3장 중 2장을 고른다. 시간이 지나면 가장 센 조합. 2구 베팅에서 한 사람만 남으면 고르지 않고 끝난다(카드 공개를 고르면 손패 3장을 모두 보여 준다). -7. 쇼다운(고른 2장으로 판정). 버린 1장은 공개패가 아니면 끝까지 아무에게도 보이지 않는다(공개패를 버리면 다른 사람 화면에서 그 패가 빠진다). +7. 쇼다운(고른 2장으로 판정). 버린 1장은 공개패가 아니면 끝까지 아무에게도 보이지 않는다. + - 고른 뒤에도 쇼다운 전까지 다른 사람 화면은 고르기 전과 똑같다(공개패 앞면 + 뒷면 2장, "고름" 표시만). 예전에는 고르면 남긴 2장만 보여서, 공개패가 남았는지 빠졌는지로 무엇을 골랐는지 짐작할 수 있었다(사용자 요청 2026-10-18: "상대가 뭐 골랐는지 안 나오게"). 재경기(구사·멍텅구리구사·같은 족보)는 3장 섯다 방이어도 **2장 섯다**로 한다(2026-10-17): 2장을 한 번에 받고 공개패 없이 베팅 1번 → 쇼다운. 재경기가 끝나면 다음 판은 다시 3장 섯다. 엔진은 (재)경기마다 `hand.three`를 두고(본 판 = `cardMode=three`, 재경기 = false), 화면에는 `view.threeCard`로 알린다. 이 값이 없는 예전 상태(배포 전에 시작한 재경기)는 방의 `cardMode`를 따른다. **예상족보**(`hints` 켬, 아직 패를 더 받을 때): 족보판에서 다음 패 1장으로 만들 수 있는 족보만 밝게, 못 만드는 족보는 흐리게 보인다. [예상족보 켬/끔]으로 끌 수 있다. 서버가 공개된 정보만으로 계산한다(덱 구성 − 내 패 − 모두에게 보인 공개패, 남은 덱 순서는 쓰지 않음, `view.myReach`). -옵션: `threeOpen=끔`이면 2단계가 없다. `threePick=beforeBet`이면 4단계 직후에 2장을 고르고(뒷면 2장만 남김) 그다음 마지막 베팅 → 쇼다운(2026-10-13 이전의 3장 섯다 흐름). 진행 중이던 방(상태 버전 2)은 버전 3으로 옮길 때 예전 흐름(공개패 없음, 베팅 전 고르기)을 그대로 쓴다. +옵션: `threeOpen=끔`이면 2단계가 없다. `threePick=beforeBet`이면 4단계 직후에 2장을 고르고(다른 사람 화면은 그대로 3장) 그다음 마지막 베팅 → 쇼다운(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장으로 승부. @@ -552,7 +553,7 @@ interface SeotdaResult /* extends GameResult */ { - [ ] 체크·콜 후 같은 라운드 레이즈 거부, `maxRaise=half`에서 `full` 거부. - [ ] 2차 베팅 첫 행동자: 선이 1차에서 다이했으면 선 다음 좌석의 남은 사람. - [ ] `dealMode=oneRound`: 베팅 1회 후 바로 쇼다운. -- [ ] 3장 섯다: 선택 전 다른 사람 `view`에 선택 결과 없음, 버린 카드는 쇼다운 후에도 어떤 `view`·이벤트에도 없음. +- [x] 3장 섯다: 쇼다운 전 다른 사람 `view`에 선택 결과 없음(공개패를 남기든 버리든 같은 화면), 공개패는 맨 왼쪽, 버린 카드는 쇼다운 후에도 어떤 `view`·이벤트에도 없음. - [ ] 3장 섯다 시간 초과 자동 선택: 1광·8광·4열끗 → 18광땡 조합 선택. - [ ] 시간 초과: `opened=false`면 체크, 아니면 다이. 2연속 → `away`, 마감 5초. - [ ] 연결 끊김 상태로 선 차례 → 마감 후 자동 체크/다이, 재접속 후 정상 행동. diff --git a/e2e/games.e2e.ts b/e2e/games.e2e.ts index 70a7a82..a705d9a 100644 --- a/e2e/games.e2e.ts +++ b/e2e/games.e2e.ts @@ -1904,11 +1904,19 @@ const PLANS: Record = { await host.getByRole('button', { name: /^3장 섯다/ }).first().click(); }, drive: async (pages) => { - for (const p of pages) { + for (const [i, p] of pages.entries()) { const box = p.getByRole('group', { name: '공개패 고르기' }); await box.waitFor({ timeout: 10_000 }); - await box.locator('button, [role="button"]').first().click(); + // The host shows the right-hand card: it must move to the left (사용자 요청 2026-10-18). + const card = i === 0 ? box.locator('.mine [aria-label]').last() : box.locator('button, [role="button"]').first(); + const name = await card.getAttribute('aria-label'); + await card.click(); await p.getByRole('button', { name: /패 공개하기$/ }).click(); + if (i === 0) { + await p.waitForTimeout(300); + const first = await p.locator('.sd-handarea .mine [aria-label]').first().getAttribute('aria-label'); + if (first !== name) throw new Error(`공개패 ${name} is not leftmost (left: ${first})`); + } } // 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(() => {}); diff --git a/packages/games/src/seotda/index.ts b/packages/games/src/seotda/index.ts index 39bd3ae..e5e1a8b 100644 --- a/packages/games/src/seotda/index.ts +++ b/packages/games/src/seotda/index.ts @@ -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 { 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 ({ ...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, diff --git a/packages/games/src/seotda/seotda.test.ts b/packages/games/src/seotda/seotda.test.ts index 1f766d1..093482c 100644 --- a/packages/games/src/seotda/seotda.test.ts +++ b/packages/games/src/seotda/seotda.test.ts @@ -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)]); + }); +});