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:
@@ -10,7 +10,7 @@ import { formatWon, formatWonDelta, formatWonShort } from '@bg/games/seotda/mone
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { HwatuCard } from '../../components/cards/HwatuCard';
|
||||
import { HWATU_RATIO, HwatuBack, HwatuCard } from '../../components/cards/HwatuCard';
|
||||
import { haptic, sfx, sounds } from '../../lib/feedback';
|
||||
import { usePhone } from '../../lib/media';
|
||||
import type { BoardProps } from '../types';
|
||||
@@ -146,6 +146,9 @@ const CSS = `
|
||||
font-family: inherit; font-weight: 700; font-size: .78rem; line-height: 1.6; letter-spacing: -.01em; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
|
||||
.sd-jokbo li button:hover { border-color: var(--text-sub); }
|
||||
.sd-jokbo li button.sel { border-color: var(--text-sub); box-shadow: inset 0 0 0 1px var(--text-sub); }
|
||||
.sd-jokbo li button.no { opacity: .38; }
|
||||
.sd-outlook { margin-left: auto; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-sub); font-family: inherit; font-size: .72rem; font-weight: 800; padding: 0 8px; line-height: 1.6; cursor: pointer; }
|
||||
.sd-outlook.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
|
||||
.sd-jokbo li button.hit { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 900; }
|
||||
.sd-jokbo-desc { display: flex; gap: 6px; align-items: center; font-size: .78rem; line-height: 1.35; margin-top: auto; padding: 6px 8px; border-radius: 10px; background: var(--surface); }
|
||||
.sd-jokbo-desc .pics { display: flex; gap: 2px; flex: none; }
|
||||
@@ -162,6 +165,14 @@ const CSS = `
|
||||
.sd-handarea .under { display: flex; justify-content: center; }
|
||||
.sd-handarea .hint { font-size: .8rem; text-align: center; opacity: .92; }
|
||||
.sd-handarea .sd-seal { font-size: 1.25rem; padding: 2px 16px; }
|
||||
.sd-squeeze { position: relative; flex: none; padding: 0; border: 0; background: none; border-radius: 7px; overflow: hidden; cursor: grab; touch-action: none;
|
||||
box-shadow: 0 0 0 3px #fde047, 0 4px 12px rgba(0,0,0,.35); }
|
||||
.sd-squeeze:active { cursor: grabbing; }
|
||||
.sd-squeeze .face, .sd-squeeze .cover { position: absolute; inset: 0; display: block; }
|
||||
.sd-squeeze .cover { transition: transform .06s linear; }
|
||||
.sd-squeeze .tip { position: absolute; left: 50%; top: 42%; transform: translateX(-50%); white-space: nowrap; font-size: .74rem; font-weight: 900; color: #fff;
|
||||
background: rgba(0,0,0,.55); border-radius: 999px; padding: 1px 8px; pointer-events: none; animation: sd-nudge 1.1s ease-in-out infinite; }
|
||||
@keyframes sd-nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -6px); } }
|
||||
.sd-combos { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
|
||||
.sd-combo { border: 0; border-radius: 7px; padding: 2px 10px; font-family: inherit; font-weight: 800; font-size: .88rem; line-height: 1.4; background: rgba(255,255,255,.92); color: #1c1e21; }
|
||||
.sd-combo.best { background: linear-gradient(160deg, #fde047, #f59e0b); color: #5a2a00; box-shadow: 0 0 0 2px #b45309; }
|
||||
@@ -537,6 +548,68 @@ function BetGrid({ view: v, me, act, pending, setHover }: { view: SeotdaView; me
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 패쪼기 (한게임처럼): the extra card comes face down; push the back up (drag) to peek from the bottom-left number, or
|
||||
* tap / Enter to turn it at once. Turns by itself after a few seconds so nobody gets stuck.
|
||||
*/
|
||||
function Squeeze({ card, width, onDone }: { card: SeotdaCardView; width: number; onDone: () => void }) {
|
||||
const h = Math.round(width * HWATU_RATIO);
|
||||
const [dy, setDy] = useState(0);
|
||||
const start = useRef<number | null>(null);
|
||||
const done = useRef(false);
|
||||
const finish = () => {
|
||||
if (done.current) return;
|
||||
done.current = true;
|
||||
sfx.cardFlip();
|
||||
onDone();
|
||||
};
|
||||
const finishRef = useRef(finish);
|
||||
finishRef.current = finish;
|
||||
useEffect(() => {
|
||||
const t = setTimeout(() => finishRef.current(), fxMs(6000) || 6000);
|
||||
return () => clearTimeout(t);
|
||||
}, []);
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="sd-squeeze anim-deal"
|
||||
style={{ width, height: h, ['--from-y' as string]: '-180px' }}
|
||||
aria-label="새로 받은 패 확인하기(밀어 올리거나 누르기)"
|
||||
onPointerDown={(e) => {
|
||||
start.current = e.clientY;
|
||||
e.currentTarget.setPointerCapture?.(e.pointerId);
|
||||
}}
|
||||
onPointerMove={(e) => {
|
||||
if (start.current !== null) setDy(Math.min(h, Math.max(0, start.current - e.clientY)));
|
||||
}}
|
||||
onPointerUp={() => {
|
||||
if (start.current === null) return;
|
||||
start.current = null;
|
||||
if (dy > h * 0.4 || dy < 6) finish();
|
||||
else setDy(0);
|
||||
}}
|
||||
onPointerCancel={() => {
|
||||
start.current = null;
|
||||
setDy(0);
|
||||
}}
|
||||
onClick={(e) => {
|
||||
if (e.detail === 0) finish(); // keyboard (Enter / Space)
|
||||
}}
|
||||
>
|
||||
<span className="face" aria-hidden>
|
||||
<HwatuCard card={card} width={width} monthStyle="corner" />
|
||||
</span>
|
||||
<span className="cover" aria-hidden style={{ transform: `translateY(${-dy}px)` }}>
|
||||
<HwatuBack w={width} h={h} />
|
||||
</span>
|
||||
<span className="tip" aria-hidden>
|
||||
↑ 밀어서 확인
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
interface DockProps {
|
||||
view: SeotdaView;
|
||||
seat: SeotdaSeatView | null;
|
||||
@@ -558,6 +631,14 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
|
||||
const [pick, setPick] = useState<number[]>([]);
|
||||
useEffect(() => setPick([]), [v.handNo, v.rematchNo, v.handPhase]);
|
||||
const [hover, setHover] = useState<BetType | null>(null);
|
||||
// 패쪼기: cards that arrive after the first deal of a (re)match come face down until I peek.
|
||||
const matchTag = `${v.handNo}-${v.rematchNo}`;
|
||||
const first = useRef<{ tag: string; keys: Set<string> } | null>(null);
|
||||
const [peeked, setPeeked] = useState<Set<string>>(() => new Set());
|
||||
const myKeys = (seat?.cards ?? []).filter(isCard).map((c) => c.key);
|
||||
if (myKeys.length && first.current?.tag !== matchTag) first.current = { tag: matchTag, keys: new Set(myKeys) };
|
||||
const squeezing = (key: string) => !!first.current && first.current.tag === matchTag && !first.current.keys.has(key) && !peeked.has(key) && !seat?.handName;
|
||||
const peeking = myKeys.some(squeezing);
|
||||
const u = seat ? userOf(players, seat.id) : null;
|
||||
const cards = seat?.cards ?? [];
|
||||
const opening = !!seat && v.handPhase === 'open' && seat.opening === false;
|
||||
@@ -566,7 +647,8 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
|
||||
const playing = !!seat && seat.inHand && !seat.folded;
|
||||
const w = phone ? (cards.length > 2 ? 62 : 74) : cards.length > 2 ? 76 : 88;
|
||||
const tag = `${v.handNo}-${v.rematchNo}`;
|
||||
const h = v.myHand;
|
||||
// While a card is still face down, don't give away the new 족보.
|
||||
const h = peeking ? null : v.myHand;
|
||||
const hints = v.options.hints;
|
||||
const onCard = (id: number) =>
|
||||
opening ? setPick([id]) : choosing ? setPick((p) => (p.includes(id) ? p.filter((x) => x !== id) : p.length >= 2 ? [p[1]!, id] : [...p, id])) : undefined;
|
||||
@@ -581,7 +663,7 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
|
||||
let under: ReactNode = null;
|
||||
if (seat?.handName) under = <span className={`sd-seal anim-pop${isBig(seat.handName) ? ' big' : ''}`}>{seat.handName}</span>;
|
||||
else if (seat?.folded) under = <span className="sd-seal die">다이</span>;
|
||||
else if (playing && hints && v.myCombos && !v.myChosen)
|
||||
else if (playing && hints && v.myCombos && !v.myChosen && !peeking)
|
||||
under = (
|
||||
<span className="sd-combos">
|
||||
{v.myCombos.map((c) =>
|
||||
@@ -658,7 +740,9 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
|
||||
? hoverBet
|
||||
? `${BET_KO[hover!]}: ${BET_HELP[hover!]}. 걸고 나면 내 돈 ${formatWon(seat!.stack - hoverBet.amount)}, 판돈 ${formatWon(v.pot + hoverBet.amount)}`
|
||||
: v.forcedHalf
|
||||
? `베팅 규칙 ${v.options.betRule}: 첫 베팅은 하프 또는 다이만 할 수 있어요.`
|
||||
? v.options.betRule === 'free'
|
||||
? '3장 섯다 1구: 선은 하프 또는 다이만 할 수 있어요.'
|
||||
: `베팅 규칙 ${v.options.betRule}: 첫 베팅은 하프 또는 다이만 할 수 있어요.`
|
||||
: '내 차례예요. 버튼이나 숫자 키로 걸어요.'
|
||||
: v.handPhase === 'betting' && v.toAct
|
||||
? `${nick(players, v.toAct)}님 차례예요.`
|
||||
@@ -667,7 +751,7 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
|
||||
return (
|
||||
<>
|
||||
<div className={`sd-dock${seat?.isTurn ? ' turn' : ''}${winner ? ' win' : ''}`}>
|
||||
<JokboBoard options={v.options} mine={playing ? h : null} />
|
||||
<JokboBoard options={v.options} mine={playing ? h : null} reach={playing && !peeking ? v.myReach : null} />
|
||||
{seat && u && (
|
||||
<div className="sd-prof" ref={(el) => setRef(seat.id, el)} aria-label={`내 자리, 보유 ${formatWon(seat.stack)}`}>
|
||||
<ActBubble seat={seat} />
|
||||
@@ -691,13 +775,15 @@ function Dock({ view: v, seat, players, act, pending, deadline, winner, setRef,
|
||||
<div className="mine" aria-label="내 패">
|
||||
{cards.length === 0 && <span className="small">{seat.inHand ? '패를 기다리는 중' : '이번 판은 쉬어요'}</span>}
|
||||
{cards.map((c, i) =>
|
||||
isCard(c) ? (
|
||||
isCard(c) && squeezing(c.key) ? (
|
||||
<Squeeze key={c.key} card={c} width={w} onDone={() => setPeeked((p) => new Set(p).add(c.key))} />
|
||||
) : isCard(c) ? (
|
||||
<HwatuCard
|
||||
key={c.key}
|
||||
card={c}
|
||||
width={w}
|
||||
monthStyle="corner"
|
||||
className="anim-deal"
|
||||
className={peeked.has(c.key) ? undefined : 'anim-deal'}
|
||||
onClick={() => onCard(c.id)}
|
||||
disabled={!opening && !choosing}
|
||||
selected={(opening || choosing) && pick.includes(c.id)}
|
||||
|
||||
@@ -75,7 +75,15 @@ test('섯다: 3장 섯다 공개패 → 베팅 2번 → 고르기 단계(한게
|
||||
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' });
|
||||
// 1구 (한게임): 선은 하프·다이만, 그다음은 체크 없이 콜. 2구는 체크.
|
||||
const dealer = view(state, null).toAct as string;
|
||||
expect(helpNow(view(state, dealer), dealer, users)).toContain('선이 [하프]나 [다이]만');
|
||||
while (view(state, null).handPhase === 'betting') {
|
||||
const who = view(state, null).toAct as string;
|
||||
const legal = view(state, who).legal.map((l: { type: string }) => l.type);
|
||||
const t = ['check', 'call', 'half'].find((x) => legal.includes(x))!;
|
||||
state = applyAction('seotda', state, who, { type: t });
|
||||
}
|
||||
expect(view(state, null).handPhase).toBe('choose');
|
||||
expect(view(state, null).street).toBe(1);
|
||||
expect(helpNow(view(state, null), null, users)).toContain('패를 공개해요');
|
||||
|
||||
@@ -94,12 +94,19 @@ function myBetting(v: SeotdaView, seat: SeotdaSeatView): string {
|
||||
const lines = [`내 차례예요. ${roundText(v)}`];
|
||||
const hand = handLine(v, seat);
|
||||
if (hand) lines.push(hand);
|
||||
lines.push(`누를 수 있는 버튼: ${buttons.map((t) => `[${BET_KO[t]}]`).join(' ')}. 버튼 아래 적힌 금액이 바로 판돈에 들어가요. PC에서는 버튼 왼쪽 위 숫자 키(${buttons.map((t) => `${BET_KO[t]} ${BET_KEY[t]}`).join(', ')})로도 걸 수 있어요.`);
|
||||
lines.push(`누를 수 있는 버튼: ${buttons.map((t) => `[${BET_KO[t]}]`).join(' ')}. 버튼 아래 적힌 금액이 바로 판돈에 들어가요. PC에서는 버튼 왼쪽에 적힌 숫자 키(${buttons.map((t) => `${BET_KO[t]} ${BET_KEY[t]}`).join(', ')})로도 걸 수 있어요.`);
|
||||
const tips: string[] = [];
|
||||
if (v.forcedHalf) tips.push(`이 방은 베팅 규칙 ${v.options.betRule}이라 첫 베팅에서 앞쪽 사람은 [하프]나 [다이]만 할 수 있어요.`);
|
||||
if (v.forcedHalf)
|
||||
tips.push(
|
||||
v.options.betRule === 'free'
|
||||
? '3장 섯다 1구에서는 선이 [하프]나 [다이]만 할 수 있어요(한게임 방식).'
|
||||
: `이 방은 베팅 규칙 ${v.options.betRule}이라 첫 베팅에서 앞쪽 사람은 [하프]나 [다이]만 할 수 있어요.`,
|
||||
);
|
||||
if (v.threeCard && v.street === 0 && v.options.threeOpen && v.options.threePick === 'end' && !v.forcedHalf)
|
||||
tips.push('3장 섯다 1구에서는 [체크]를 할 수 없어요. 걸거나 다이해요.');
|
||||
const call = legal.get('call');
|
||||
if (call) tips.push(`앞사람이 걸었어요. [콜]은 그만큼(${won(call.amount)}) 맞추는 거예요.`);
|
||||
else if (legal.has('ping')) tips.push(`[체크]는 걸지 않고 넘기고, [삥]은 기본금만큼 ${won(v.baseUnit)}을 걸어요.`);
|
||||
else if (legal.has('ping')) tips.push(legal.has('check') ? `[체크]는 걸지 않고 넘기고, [삥]은 기본금만큼 ${won(v.baseUnit)}을 걸어요.` : `[삥]은 기본금만큼 ${won(v.baseUnit)}을 걸어요.`);
|
||||
if (!buttons.some((t) => RAISES.includes(t)) && seat.lastAction) tips.push('이번 라운드에 이미 한 번 해서 더 올릴 수는 없어요(올리기는 한 라운드에 한 번).');
|
||||
if (v.legal.some((l) => l.allIn)) tips.push('가진 금액이 모자라면 가진 만큼 다 내는 올인이 돼요.');
|
||||
tips.push('패가 약하면 [다이]로 이번 판을 포기할 수 있어요.');
|
||||
|
||||
@@ -343,7 +343,7 @@ function Rules({ options }: { options?: SeotdaOptions }) {
|
||||
<strong>진행</strong>: 판마다 모두 <strong>기본금</strong>을 판돈에 내요. 선부터 패를 받고 차례로 베팅해요.
|
||||
{o?.cardMode === 'three'
|
||||
? o.threeOpen && o.threePick === 'end'
|
||||
? ' 3장 섯다(한게임)는 2장을 받아 그중 1장을 골라 모두에게 보여 주고(공개패) → 첫 베팅 → 1장을 더 받아 → 마지막 베팅 → 3장 중 쓸 2장을 골라 공개해요. 버린 1장은 공개패가 아니면 끝까지 아무도 못 봐요.'
|
||||
? ' 3장 섯다(한게임)는 2장을 받아 그중 1장을 골라 모두에게 보여 주고(공개패) → 1구 베팅 → 1장을 더 받아(밀어 올려 확인하는 패쪼기) → 2구 베팅 → 3장 중 쓸 2장을 골라 공개해요. 1구에서는 선이 하프나 다이만 할 수 있고, 체크는 없어요. 버린 1장은 공개패가 아니면 끝까지 아무도 못 봐요. 족보판의 [예상족보]를 켜면 다음 패로 만들 수 있는 족보만 밝게 보여요.'
|
||||
: ` 3장 섯다는 2장을 받고${o.threeOpen ? ' 1장을 골라 모두에게 보여 준 뒤' : ''} 베팅 → 1장을 더 받아 ${o.threePick === 'end' ? '마지막 베팅 → 3장 중 쓸 2장을 골라 공개해요' : '3장 중 쓸 2장을 몰래 고르고 → 마지막 베팅 후 공개해요'}. 버린 1장은 끝까지 아무도 못 봐요.`
|
||||
: o?.dealMode === 'twoRounds'
|
||||
? ' 1장 받고 베팅, 1장 더 받고 베팅한 뒤 남은 사람끼리 패를 공개해요.'
|
||||
|
||||
@@ -115,8 +115,11 @@ export function JokboTable({ options, mine }: { options: SeotdaOptions; mine?: S
|
||||
* Compact 족보판 (bottom-left of the table, like 한게임 섯다): every hand in 3 columns, my current hand lit up (when
|
||||
* hints are on); the line below explains the selected hand (my hand by default, or the one clicked).
|
||||
*/
|
||||
export function JokboBoard({ options, mine }: { options: SeotdaOptions; mine: SeotdaView['myHand'] }) {
|
||||
export function JokboBoard({ options, mine, reach }: { options: SeotdaOptions; mine: SeotdaView['myHand']; reach?: SeotdaView['myReach'] }) {
|
||||
const rows = jokboRows(options);
|
||||
// 예상족보 (한게임처럼 켜고 끌 수 있음): rows my next card can still make stay bright, the rest fade.
|
||||
const [outlook, setOutlook] = useState(true);
|
||||
const can = reach && outlook ? (r: JokboRow) => reach.some((x) => r.match(x.value, x.special)) : null;
|
||||
const hitIdx = mine && options.hints ? rows.findIndex((r) => r.match(mine.value, mine.special)) : -1;
|
||||
const [sel, setSel] = useState<number | null>(null);
|
||||
useEffect(() => setSel(null), [hitIdx]);
|
||||
@@ -124,7 +127,14 @@ export function JokboBoard({ options, mine }: { options: SeotdaOptions; mine: Se
|
||||
let n = 0;
|
||||
return (
|
||||
<section className="sd-jokbo" aria-label="족보">
|
||||
<h3>족보</h3>
|
||||
<h3>
|
||||
족보
|
||||
{reach && (
|
||||
<button type="button" className={`sd-outlook${outlook ? ' on' : ''}`} aria-pressed={outlook} onClick={() => setOutlook(!outlook)} title="다음 패로 만들 수 있는 족보만 밝게 보여요">
|
||||
예상족보 {outlook ? '켬' : '끔'}
|
||||
</button>
|
||||
)}
|
||||
</h3>
|
||||
<ol style={{ gridTemplateRows: `repeat(${Math.ceil(rows.length / 3)}, auto)` }}>
|
||||
{rows.map((r, i) => {
|
||||
const label = r.special ? `*${r.short}` : `${++n}.${r.short}`;
|
||||
@@ -132,10 +142,10 @@ export function JokboBoard({ options, mine }: { options: SeotdaOptions; mine: Se
|
||||
<li key={r.name}>
|
||||
<button
|
||||
type="button"
|
||||
className={`${i === hitIdx ? 'hit' : ''}${shown === r ? ' sel' : ''}`}
|
||||
className={`${i === hitIdx ? 'hit' : ''}${shown === r ? ' sel' : ''}${can && !can(r) ? ' no' : ''}`}
|
||||
aria-pressed={shown === r}
|
||||
aria-current={i === hitIdx ? 'true' : undefined}
|
||||
title={`${r.name}${r.note ? `: ${r.note}` : ''}`}
|
||||
title={`${r.name}${r.note ? `: ${r.note}` : ''}${can ? (can(r) ? ' (다음 패로 만들 수 있어요)' : ' (다음 패로는 못 만들어요)') : ''}`}
|
||||
onClick={() => setSel(sel === i ? null : i)}
|
||||
>
|
||||
{label}
|
||||
|
||||
Reference in New Issue
Block a user