M9: 게임 26종 30초 요약 카드·[?] 지금 할 수 있는 것 내용
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
180
apps/web/src/games/poker/help.test.ts
Normal file
180
apps/web/src/games/poker/help.test.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { GAMES } from '@bg/games';
|
||||
import { applyAction, assertCleanText, eachView, seatIds, setupGame, usersOf } from '../help-kit.test-util';
|
||||
import { helpNow } from './help';
|
||||
|
||||
const users = usersOf(['A', 'B', 'C']);
|
||||
const def = GAMES.poker!;
|
||||
const view = (s: unknown, who: string | null) => def.view(s, who) as any;
|
||||
const help = (s: unknown, who: string | null) => helpNow(view(s, who), who, users);
|
||||
const nickOf = (id: string) => `${users[id]!.nickname}님`;
|
||||
|
||||
/** Plays the hand forward (checks/calls, first choice, pass on draw, high on declare) until `stop` is true. */
|
||||
function drive(state: any, stop: (v: any) => boolean, limit = 60): any {
|
||||
let s = state;
|
||||
for (let i = 0; i < limit; i++) {
|
||||
if (stop(view(s, null))) return s;
|
||||
const actor = def.activePlayers(s)[0]!;
|
||||
const legal = (def.legalActions!(s, actor) as any[]) ?? [];
|
||||
const pick =
|
||||
legal.find((a) => /check|call/.test(a.type)) ??
|
||||
legal.find((a) => a.type === 'draw' && a.cardIds.length === 0) ??
|
||||
legal.find((a) => a.type === 'declare' && a.side === 'high') ??
|
||||
legal[0];
|
||||
s = applyAction('poker', s, actor, pick);
|
||||
}
|
||||
throw new Error('poker: target situation not reached');
|
||||
}
|
||||
|
||||
test('7포커: 초이스(동시에 고르기) → 4구 베팅 내 차례 / 상대 차례 / 관전', () => {
|
||||
const { state } = setupGame('poker', 3, { mode: 'sevenPoker' });
|
||||
expect(view(state, null).handPhase).toBe('choice');
|
||||
const a = help(state, 'A');
|
||||
expect(a).toContain('① 버릴 카드 1장');
|
||||
expect(a).toContain('[확인]');
|
||||
expect(a).toContain('남는 2장은 나만 봐요');
|
||||
expect(a).toContain('지금 내 족보:');
|
||||
expect(help(state, null)).toContain('모두 동시에 받은 4장 중');
|
||||
|
||||
const choice = view(state, 'A').my.choice as string[];
|
||||
let s = applyAction('poker', state, 'A', { type: 'choose', discardId: choice[0], openId: choice[1] });
|
||||
expect(help(s, 'A')).toContain('골랐어요');
|
||||
expect(help(s, null)).toContain('아직 고르는 사람:');
|
||||
|
||||
s = drive(s, (v) => v.handPhase === 'betting');
|
||||
const v = view(s, null);
|
||||
const turn: string = v.toAct;
|
||||
const other = ['A', 'B', 'C'].find((id) => id !== turn)!;
|
||||
const mine = help(s, turn);
|
||||
expect(mine).toContain('내 차례예요. 지금은 4구 베팅이에요.');
|
||||
expect(mine).toContain('[다이] [체크] [삥]');
|
||||
expect(mine).toContain('[하프] 모인 칩의 절반만큼 더');
|
||||
expect(mine).toContain('내가 보스(먼저 베팅)');
|
||||
expect(mine).toContain('지금 내 족보:');
|
||||
const theirs = help(s, other);
|
||||
expect(theirs).toContain(`${nickOf(turn)} 차례예요(4구 베팅). 기다려 주세요.`);
|
||||
expect(theirs).toContain(`보스(공개 카드가 가장 좋은 사람, 먼저 베팅)는 ${nickOf(turn)}이에요.`);
|
||||
const spec = help(s, null);
|
||||
expect(spec).toContain('7포커 1/20판이에요.');
|
||||
expect(spec).toContain('지금 모인 칩은 30 칩이에요.');
|
||||
expect(spec).not.toContain('지금 내 족보');
|
||||
|
||||
// Someone pinged: the next player must call or die, and the earlier checker may not raise again.
|
||||
s = applyAction('poker', s, turn, { type: 'k.ping' });
|
||||
const next: string = view(s, null).toAct;
|
||||
expect(help(s, next)).toContain('앞사람에게 맞추려면 10 칩이 필요해요([콜])');
|
||||
expect(help(s, next)).toContain('[따당] 앞사람이 건 만큼의 두 배');
|
||||
});
|
||||
|
||||
test('텍사스 홀덤: 노리밋 버튼과 공용 카드, 모두 포기하면 판 결과', () => {
|
||||
const { state } = setupGame('poker', 2, { mode: 'holdem' });
|
||||
const v = view(state, null);
|
||||
const turn: string = v.toAct;
|
||||
const other = turn === 'A' ? 'B' : 'A';
|
||||
const mine = help(state, turn);
|
||||
expect(mine).toContain('내 차례예요. 지금은 프리플랍 베팅이에요. 누를 수 있는 버튼: [폴드] [콜] [레이즈] [올인]');
|
||||
expect(mine).toContain('[레이즈]를 누르면 올릴 칩(이번 라운드 총 20 칩~1,000 칩)을 고르고 [확인]');
|
||||
expect(mine).toContain('공용 카드는 아직 없어요');
|
||||
expect(mine).toContain('내 카드 2장과 공용 카드를 합쳐');
|
||||
expect(help(state, other)).toContain(`${nickOf(turn)} 차례예요(프리플랍 베팅). 기다려 주세요.`);
|
||||
expect(help(state, null)).toContain('각자 카드 2장과 공용 카드를 합쳐');
|
||||
|
||||
const flop = drive(state, (x) => x.handPhase === 'betting' && x.board.length === 3);
|
||||
expect(help(flop, null)).toContain('가운데 공용 카드 3장이 펼쳐져 있어요');
|
||||
|
||||
const s = applyAction('poker', state, turn, { type: 'nl.fold' });
|
||||
expect(view(s, null).handPhase).toBe('handEnd');
|
||||
const w = help(s, other);
|
||||
expect(w).toContain('다른 사람이 모두 포기해서 내가 모인 칩을 가져갔어요');
|
||||
expect(w).toContain('[다음 판으로]');
|
||||
expect(help(s, null)).toContain(`${nickOf(other)}이 모인 칩을 가져갔어요`);
|
||||
});
|
||||
|
||||
test('바둑이 / 5카드 드로우: 교환 단계', () => {
|
||||
const b = drive(setupGame('poker', 2, { mode: 'badugi' }).state, (v) => v.handPhase === 'draw');
|
||||
const mine = help(b, 'A');
|
||||
expect(mine).toContain('아침 교환: 바꿀 카드를 눌러 위로 올린 뒤');
|
||||
expect(mine).toContain('[패스(안 바꾸기)]');
|
||||
expect(mine).toContain('4장까지 바꿀 수 있어요');
|
||||
expect(help(b, null)).toContain('모두 동시에 바꿀 카드를 고르는 중이에요(아침 교환)');
|
||||
const b2 = applyAction('poker', b, 'A', { type: 'draw', cardIds: [] });
|
||||
expect(help(b2, 'A')).toContain('바꿀 카드를 냈어요');
|
||||
|
||||
const f = drive(setupGame('poker', 2, { mode: 'fiveDraw', drawLimit: 'three' }).state, (v) => v.handPhase === 'draw');
|
||||
expect(help(f, 'B')).toContain('교환: 바꿀 카드를');
|
||||
expect(help(f, 'B')).toContain('3장까지 바꿀 수 있어요(A를 남기면 4장)');
|
||||
const after = drive(f, (v) => v.handPhase === 'betting');
|
||||
expect(help(after, null)).toContain('카드를 바꾼 뒤 마지막 베팅이에요');
|
||||
});
|
||||
|
||||
test('7포커 하이로우: 선언 단계', () => {
|
||||
const s = drive(setupGame('poker', 2, { mode: 'sevenHiLo' }).state, (v) => v.handPhase === 'declare');
|
||||
const mine = help(s, 'A');
|
||||
expect(mine).toContain('[하이]·[로우]·[스윙] 중 하나를 누르세요');
|
||||
expect(mine).toContain('하이 1등과 로우 1등이 칩을 반씩');
|
||||
expect(mine).toContain('지금 내 족보:');
|
||||
expect(mine).not.toContain('로우 로우');
|
||||
const s2 = applyAction('poker', s, 'A', { type: 'declare', side: 'low' });
|
||||
expect(help(s2, 'A')).toContain('로우(으)로 선언했어요');
|
||||
expect(help(s2, null)).toContain('하이·로우·스윙 중 하나를 몰래 고르는 중');
|
||||
});
|
||||
|
||||
test('인디언 포커: 내 이마 카드는 모른다고 안내하고, 관전자에게도 숨김', () => {
|
||||
const { state } = setupGame('poker', 3, { mode: 'indian' });
|
||||
const turn: string = view(state, null).toAct;
|
||||
const mine = help(state, turn);
|
||||
expect(mine).toContain('내 이마 카드는 나만 못 봐요');
|
||||
expect(mine).not.toContain('지금 내 족보');
|
||||
expect(help(state, null)).toContain('구경할 때는 이마 카드가 판이 끝나야 보여요');
|
||||
});
|
||||
|
||||
test('리바이와 게임 끝', () => {
|
||||
const { state } = setupGame('poker', 2, { mode: 'sevenPoker', rebuy: 'limited', rebuyLimit: 2 });
|
||||
const r = structuredClone(state);
|
||||
r.phase = 'rebuy';
|
||||
r.rebuyPending = ['A'];
|
||||
r.seats.find((x: any) => x.id === 'A').stack = 0;
|
||||
r.seats.find((x: any) => x.id === 'A').status = 'busted';
|
||||
const a = help(r, 'A');
|
||||
expect(a).toContain('[칩 다시 받기]');
|
||||
expect(a).toContain('(남은 횟수 2번)');
|
||||
expect(a).toContain('[그만하기]');
|
||||
expect(help(r, 'B')).toContain('호랑이님이 칩을 다시 받을지 고르는 중이에요');
|
||||
|
||||
const f = structuredClone(state);
|
||||
f.phase = 'finished';
|
||||
f.result = { ranking: [['A'], ['B']], scores: { A: 10, B: -10 }, summary: '호랑이님 1위', abandoned: false };
|
||||
expect(help(f, 'B')).toContain('게임이 끝났어요. 호랑이님 1위');
|
||||
expect(help(f, null)).toContain('[한 판 더]');
|
||||
});
|
||||
|
||||
describe('모든 모드의 무작위 한 판: 깨끗한 안내문', () => {
|
||||
const modes: [string, Record<string, unknown>][] = [
|
||||
['holdem', { mode: 'holdem' }],
|
||||
['omaha', { mode: 'omaha' }],
|
||||
['sevenPoker', { mode: 'sevenPoker' }],
|
||||
['sevenHiLo', { mode: 'sevenHiLo', hiLoLow: 'aceToFive', hiLoQualifier: 'eight' }],
|
||||
['badugi', { mode: 'badugi' }],
|
||||
['fiveDraw', { mode: 'fiveDraw', drawLimit: 'three' }],
|
||||
['indian 1', { mode: 'indian' }],
|
||||
['indian 2', { mode: 'indian', indianCards: 2 }],
|
||||
['korean holdem, hints off', { mode: 'holdem', betting: 'korean', hints: false, koreanMaxRaise: 'full' }],
|
||||
['sevenPoker noLimit', { mode: 'sevenPoker', betting: 'noLimit', startingChips: 500, rebuy: 'limited' }],
|
||||
];
|
||||
test.each(modes)('%s', (_name, options) => {
|
||||
for (const n of [2, 4]) {
|
||||
const u = usersOf(seatIds(n));
|
||||
const phases = new Set<string>();
|
||||
eachView(
|
||||
'poker',
|
||||
n,
|
||||
(v, who) => {
|
||||
phases.add(`${v.phase}/${v.handPhase}`);
|
||||
assertCleanText(helpNow(v, who, u), `poker ${JSON.stringify(options)} n=${n} viewer=${who} ${v.phase}/${v.handPhase}`);
|
||||
},
|
||||
{ options, steps: 600 },
|
||||
);
|
||||
expect(phases.has('playing/handEnd')).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
252
apps/web/src/games/poker/help.ts
Normal file
252
apps/web/src/games/poker/help.ts
Normal file
@@ -0,0 +1,252 @@
|
||||
/** 포커 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view. Chips are play points only. */
|
||||
import type { BetActionType, LegalBetView, PokerMode, PokerView, SeatView } from '@bg/games/poker';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
|
||||
/** Button labels exactly as the betting bar renders them (index.tsx BET_KO). */
|
||||
const BET_KO: Record<BetActionType, string> = {
|
||||
'k.check': '체크',
|
||||
'k.ping': '삥',
|
||||
'k.call': '콜',
|
||||
'k.ddadang': '따당',
|
||||
'k.quarter': '쿼터',
|
||||
'k.half': '하프',
|
||||
'k.full': '풀',
|
||||
'k.die': '다이',
|
||||
'nl.fold': '폴드',
|
||||
'nl.check': '체크',
|
||||
'nl.call': '콜',
|
||||
'nl.raise': '레이즈',
|
||||
'nl.allIn': '올인',
|
||||
};
|
||||
/** Button order of the betting bar. */
|
||||
const ORDER: BetActionType[] = ['k.die', 'k.check', 'k.ping', 'k.call', 'k.ddadang', 'k.quarter', 'k.half', 'k.full', 'nl.fold', 'nl.check', 'nl.call', 'nl.raise', 'nl.allIn'];
|
||||
const KOREAN_RAISE: Partial<Record<BetActionType, string>> = {
|
||||
'k.ping': '기본 칩만큼',
|
||||
'k.ddadang': '앞사람이 건 만큼의 두 배',
|
||||
'k.quarter': '모인 칩의 4분의 1만큼 더',
|
||||
'k.half': '모인 칩의 절반만큼 더',
|
||||
'k.full': '모인 칩만큼 더',
|
||||
};
|
||||
const MODE_KO: Record<PokerMode, string> = {
|
||||
holdem: '텍사스 홀덤',
|
||||
omaha: '오마하',
|
||||
sevenPoker: '7포커',
|
||||
sevenHiLo: '7포커 하이로우',
|
||||
badugi: '바둑이',
|
||||
fiveDraw: '5카드 드로우',
|
||||
indian: '인디언 포커',
|
||||
};
|
||||
const SIDE_KO = { high: '하이', low: '로우', swing: '스윙' } as const;
|
||||
const DRAW_NAMES = ['아침', '점심', '저녁'];
|
||||
|
||||
const chips = (n: number) => `${Math.max(0, Math.round(n)).toLocaleString('ko-KR')} 칩`;
|
||||
const nickOf = (players: Record<string, PublicUser>, id: string | null | undefined) => {
|
||||
const n = id ? players[id]?.nickname : undefined;
|
||||
return n ? `${n}님` : '다른 사람';
|
||||
};
|
||||
const namesOf = (players: Record<string, PublicUser>, ids: string[]) => ids.map((id) => nickOf(players, id)).join(', ');
|
||||
const btn = (t: BetActionType) => `[${BET_KO[t]}]`;
|
||||
|
||||
/** "지금 내 족보" from the hints option (the view sends null when hints are off or the mode has none). */
|
||||
function handLine(v: PokerView): string | null {
|
||||
const { handName, lowName } = v.my;
|
||||
if (!handName) return null;
|
||||
const low = lowName ? (lowName === '로우 없음' ? ' · 로우 없음' : ` · 로우 ${lowName}`) : '';
|
||||
return `지금 내 족보: ${handName}${low}`;
|
||||
}
|
||||
|
||||
/** What this betting round is about, per mode. `mine` = written for a seated player in the hand. */
|
||||
function modeLine(v: PokerView, mine: boolean, players: Record<string, PublicUser>, me: string | null): string {
|
||||
const n = v.board.length;
|
||||
switch (v.mode) {
|
||||
case 'holdem':
|
||||
case 'omaha': {
|
||||
const board = n === 0 ? '공용 카드는 아직 없어요(SB·BB 표시는 미리 칩을 낸 블라인드예요).' : `가운데 공용 카드 ${n}장이 펼쳐져 있어요${n === 5 ? '(다 나왔어요)' : ''}.`;
|
||||
const make =
|
||||
v.mode === 'holdem'
|
||||
? `${mine ? '내' : '각자'} 카드 2장과 공용 카드를 합쳐 가장 좋은 5장을 만들어요.`
|
||||
: `${mine ? '내' : '각자'} 카드 4장 중 꼭 2장 + 공용 카드 3장으로 5장을 만들어요.`;
|
||||
return `${board} ${make}`;
|
||||
}
|
||||
case 'sevenPoker':
|
||||
case 'sevenHiLo': {
|
||||
const boss = v.seats.find((s) => s.boss);
|
||||
const parts: string[] = [];
|
||||
if (boss) parts.push(boss.id === me ? '공개 카드가 가장 좋아서 내가 보스(먼저 베팅)예요.' : `보스(공개 카드가 가장 좋은 사람, 먼저 베팅)는 ${nickOf(players, boss.id)}이에요.`);
|
||||
if (v.street === 3) parts.push(`마지막 7번째 카드는 ${mine ? '나만' : '본인만'} 보는 히든 카드예요.`);
|
||||
if (v.mode === 'sevenHiLo' && v.street === 3) parts.push('이 베팅이 끝나면 하이·로우·스윙을 선언해요.');
|
||||
return parts.join(' ');
|
||||
}
|
||||
case 'badugi':
|
||||
return v.street < 3
|
||||
? `이 베팅이 끝나면 ${DRAW_NAMES[v.street] ?? ''} 교환(카드 바꾸기)이 있어요. 숫자도 무늬도 겹치지 않는 낮은 카드일수록 좋아요.`
|
||||
: '마지막 베팅이에요. 끝나면 패를 비교해요(낮을수록 좋아요).';
|
||||
case 'fiveDraw':
|
||||
return v.street === 0 ? '이 베팅이 끝나면 카드를 한 번 바꿀 수 있어요.' : '카드를 바꾼 뒤 마지막 베팅이에요.';
|
||||
case 'indian': {
|
||||
const hand = v.options.indianCards === 2 && v.street === 1 ? ` 손 카드는 ${mine ? '나만' : '본인만'} 보고, 이마 + 손 2장으로 겨뤄요.` : '';
|
||||
return mine
|
||||
? `내 이마 카드는 나만 못 봐요. 다른 사람 이마 카드와 베팅을 보고 내 카드를 짐작해요.${hand}`
|
||||
: `구경할 때는 이마 카드가 판이 끝나야 보여요.${hand}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const roundName = (v: PokerView) => {
|
||||
const s = v.streetName || '베팅';
|
||||
return s.endsWith('베팅') ? s : `${s} 베팅`;
|
||||
};
|
||||
|
||||
function myBetting(v: PokerView, players: Record<string, PublicUser>, me: string): string[] {
|
||||
const legal = new Map<BetActionType, LegalBetView>(v.my.legal.map((l) => [l.type, l]));
|
||||
const usable = ORDER.filter((t) => legal.has(t));
|
||||
const lines = [`내 차례예요. 지금은 ${roundName(v)}이에요. 누를 수 있는 버튼: ${usable.map(btn).join(' ')}`];
|
||||
const call = legal.get('k.call') ?? legal.get('nl.call');
|
||||
const check = legal.has('k.check') || legal.has('nl.check');
|
||||
const fold = v.betStyle === 'korean' ? '[다이]' : '[폴드]';
|
||||
if (call?.allIn) lines.push(`가진 칩이 모자라서 [콜]하면 올인이에요. 이번 판을 포기하려면 ${fold}.`);
|
||||
else if (call) lines.push(`앞사람에게 맞추려면 ${chips(v.my.toCall)}이 필요해요([콜]). 이번 판을 포기하려면 ${fold}.`);
|
||||
else if (check) lines.push('칩을 더 내지 않고 넘기려면 [체크]를 누르세요.');
|
||||
if (v.betStyle === 'korean') {
|
||||
const raises = usable.filter((t) => KOREAN_RAISE[t]);
|
||||
if (raises.length) lines.push(`올리기: ${raises.map((t) => `${btn(t)} ${KOREAN_RAISE[t]}`).join(' · ')}. 버튼 아래 숫자만큼 칩이 바로 나가요.`);
|
||||
else if (!call?.allIn) lines.push('한국식 베팅은 한 라운드에 한 번만 올릴 수 있고, 체크나 콜을 한 뒤에는 못 올려요.');
|
||||
} else {
|
||||
const raise = legal.get('nl.raise');
|
||||
if (raise && raise.minTo !== undefined && raise.maxTo !== undefined) {
|
||||
lines.push(`[레이즈]를 누르면 올릴 칩(이번 라운드 총 ${chips(raise.minTo)}~${chips(raise.maxTo)})을 고르고 [확인]을 눌러요.`);
|
||||
}
|
||||
if (legal.has('nl.allIn')) lines.push('[올인]은 가진 칩을 모두 걸어요.');
|
||||
}
|
||||
const hand = handLine(v);
|
||||
if (hand) lines.push(hand);
|
||||
const mode = modeLine(v, true, players, me);
|
||||
if (mode) lines.push(mode);
|
||||
return lines;
|
||||
}
|
||||
|
||||
function bettingWatch(v: PokerView, players: Record<string, PublicUser>, me: string | null, mine: boolean): string[] {
|
||||
const who = v.toAct ? `${nickOf(players, v.toAct)} 차례예요(${roundName(v)}).` : `${roundName(v)}이에요.`;
|
||||
const lines = [mine ? `${who} 기다려 주세요.` : `${who} 지금 모인 칩은 ${chips(v.pot)}이에요.`];
|
||||
if (mine) {
|
||||
const hand = handLine(v);
|
||||
if (hand) lines.push(hand);
|
||||
}
|
||||
const mode = modeLine(v, mine, players, me);
|
||||
if (mode) lines.push(mode);
|
||||
return lines;
|
||||
}
|
||||
|
||||
/** Neutral description of the current step (spectators, players out of this hand). */
|
||||
function watchText(v: PokerView, players: Record<string, PublicUser>, me: string | null): string {
|
||||
const waiting = v.waiting.length ? ` 아직 고르는 사람: ${namesOf(players, v.waiting)}.` : '';
|
||||
switch (v.handPhase) {
|
||||
case 'betting':
|
||||
return bettingWatch(v, players, me, false).join('\n');
|
||||
case 'choice':
|
||||
return `모두 동시에 받은 4장 중 버릴 카드 1장과 모두에게 보여 줄 카드 1장을 고르는 중이에요. 다 고르면 보여 줄 카드가 한꺼번에 공개돼요.${waiting}`;
|
||||
case 'draw':
|
||||
return `모두 동시에 바꿀 카드를 고르는 중이에요(${drawName(v)}). 버린 카드는 공개되지 않고, 바꾼 장수만 각 자리에 보여요.${waiting}`;
|
||||
case 'declare':
|
||||
return `남은 사람들이 하이·로우·스윙 중 하나를 몰래 고르는 중이에요. 모두 고르면 한꺼번에 공개돼요.${waiting}`;
|
||||
default:
|
||||
return '카드를 나눠 주는 중이에요. 잠시만 기다려 주세요.';
|
||||
}
|
||||
}
|
||||
|
||||
const drawName = (v: PokerView) => (v.mode === 'badugi' ? `${DRAW_NAMES[v.street - 1] ?? ''} 교환`.trim() : '교환');
|
||||
|
||||
function handEndText(v: PokerView, players: Record<string, PublicUser>, me: string | null, seat: SeatView | undefined): string {
|
||||
const lines: string[] = [];
|
||||
const sdName = (id: string) => (v.mode === 'sevenHiLo' ? undefined : v.showdown?.find((e) => e.id === id)?.handName);
|
||||
const who = (id: string) => (id === me ? '내가' : `${nickOf(players, id)}이`);
|
||||
if (v.foldWin && v.winners.length === 1) {
|
||||
lines.push(`다른 사람이 모두 포기해서 ${who(v.winners[0]!)} 모인 칩을 가져갔어요. 이럴 때는 패를 공개하지 않아요.`);
|
||||
} else if (v.winners.length === 1) {
|
||||
const name = sdName(v.winners[0]!);
|
||||
lines.push(`이번 판은 ${who(v.winners[0]!)} ${name ? `${name}(으)로 ` : ''}이겼어요.`);
|
||||
} else if (v.winners.length > 1) {
|
||||
lines.push(`이번 판에 칩을 가져간 사람: ${v.winners.map((id) => (id === me ? '나' : nickOf(players, id))).join(', ')}.`);
|
||||
} else if (v.carryOver > 0) {
|
||||
lines.push(`동점이라 모인 칩 ${chips(v.carryOver)}이 다음 판으로 넘어가요.`);
|
||||
} else {
|
||||
lines.push('이번 판이 끝났어요. 건 칩은 돌려받았어요.');
|
||||
}
|
||||
lines.push('누가 칩을 얼마나 가져갔는지는 [이번 판 결과]에 나와요.');
|
||||
if (v.mode === 'indian') lines.push(`판이 끝나서 ${seat?.inHand ? '내 이마 카드를 포함해 ' : ''}모든 카드가 공개됐어요.`);
|
||||
const last = v.options.endCondition === 'hands' && v.handNo >= v.options.handLimit;
|
||||
if (v.my.canReady) lines.push(`[다음 판으로]를 누르면 준비 완료예요. 모두 누르거나 시간이 지나면 ${last ? '최종 순위가 나와요' : '다음 판이 시작돼요'}.`);
|
||||
else if (seat?.inHand && seat.ready) lines.push('준비했어요. 다른 사람을 기다리는 중이에요.');
|
||||
else if (last) lines.push('마지막 판이었어요. 곧 최종 순위가 나와요.');
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
export function helpNow(v: PokerView, me: string | null, players: Record<string, PublicUser>): string {
|
||||
if (v.phase === 'finished') {
|
||||
return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n[최종 순위]에서 순위를 볼 수 있고, 결과 창에서 [한 판 더]를 누르면 다시 할 수 있어요.';
|
||||
}
|
||||
const seat = me ? v.seats.find((s) => s.id === me) : undefined;
|
||||
const modeName = `${MODE_KO[v.mode]} ${Math.max(1, v.handNo)}${v.options.endCondition === 'hands' ? `/${v.options.handLimit}` : ''}판`;
|
||||
|
||||
if (v.phase === 'rebuy') {
|
||||
if (v.my.canRebuy) {
|
||||
const left = v.my.rebuysLeft !== null ? ` (남은 횟수 ${v.my.rebuysLeft}번)` : '';
|
||||
return `칩을 모두 잃었어요. [칩 다시 받기]를 누르면 놀이용 칩 ${chips(v.options.startingChips)}을 다시 받고 계속해요${left}. 다시 받은 만큼 최종 점수에서 빠져요.\n[그만하기]를 누르면 탈락하고 구경만 해요.`;
|
||||
}
|
||||
const pending = v.seats.filter((s) => s.rebuyPending).map((s) => s.id);
|
||||
return `${pending.length ? namesOf(players, pending) : '칩이 떨어진 사람'}이 칩을 다시 받을지 고르는 중이에요. 잠시 기다려 주세요.`;
|
||||
}
|
||||
|
||||
if (v.handPhase === 'handEnd') return handEndText(v, players, me, seat);
|
||||
const away = seat?.away ? "\n시간을 두 번 넘겨 '자리 비움'이 됐어요. 직접 버튼을 누르면 풀려요." : '';
|
||||
|
||||
if (!seat) return `${modeName}이에요. ${watchText(v, players, me)}`;
|
||||
if (!seat.inHand) {
|
||||
const why = seat.status === 'eliminated' ? '탈락해서 이제 구경만 해요.' : seat.status === 'left' ? '방을 나가서 이번 판에는 빠졌어요.' : '이번 판에는 참가하지 않아요. 다음 판을 기다려 주세요.';
|
||||
return `${why}\n${watchText(v, players, me)}`;
|
||||
}
|
||||
if (seat.folded) {
|
||||
return `이번 판은 포기했어요(${v.betStyle === 'korean' ? '다이' : '폴드'}). 다음 판을 기다려 주세요. 내 카드는 나만 볼 수 있어요.\n${watchText(v, players, me)}${away}`;
|
||||
}
|
||||
|
||||
const m = v.my;
|
||||
const hand = handLine(v);
|
||||
const withHand = (lines: string[]) => (hand ? [...lines, hand] : lines).join('\n') + away;
|
||||
switch (v.handPhase) {
|
||||
case 'betting': {
|
||||
if (me && v.toAct === me) return myBetting(v, players, me).join('\n') + away;
|
||||
const lines = bettingWatch(v, players, me, true);
|
||||
if (seat.allIn) lines.splice(1, 0, '나는 올인해서 이번 판에는 더 걸 수 없어요. 카드는 끝까지 받고, 건 만큼까지 겨뤄요.');
|
||||
return lines.join('\n') + away;
|
||||
}
|
||||
case 'choice':
|
||||
if (m.canChoose) {
|
||||
return withHand([
|
||||
'7포커 초이스: 받은 4장 중 ① 버릴 카드 1장을 먼저 누르고(✕ 표시) ② 모두에게 보여 줄 카드 1장을 누른 뒤 [확인]을 눌러요. 잘못 골랐으면 [다시 고르기].',
|
||||
'버린 카드는 아무도 못 보고, 남는 2장은 나만 봐요. 모두 동시에 골라요.',
|
||||
]);
|
||||
}
|
||||
return withHand(['골랐어요. 모두 고르면 보여 줄 카드가 한꺼번에 공개돼요. 기다려 주세요.']);
|
||||
case 'draw':
|
||||
if (m.canDraw) {
|
||||
const limit = m.drawAceBonus ? '3장까지 바꿀 수 있어요(A를 남기면 4장).' : `${m.drawMax}장까지 바꿀 수 있어요.`;
|
||||
const tip = v.mode === 'badugi' ? ' 숫자나 무늬가 겹치는 카드, 높은 카드를 바꾸면 좋아요.' : '';
|
||||
return withHand([
|
||||
`${drawName(v)}: 바꿀 카드를 눌러 위로 올린 뒤 [2장 바꾸기]처럼 장수가 적힌 버튼을 누르세요. 안 바꾸려면 아무것도 고르지 말고 [패스(안 바꾸기)].`,
|
||||
`${limit} 모두 동시에 내고, 버린 카드는 공개되지 않아요.${tip}`,
|
||||
]);
|
||||
}
|
||||
return withHand(['바꿀 카드를 냈어요. 모두 내면 새 카드를 받아요. 기다려 주세요.']);
|
||||
case 'declare':
|
||||
if (m.canDeclare) {
|
||||
return withHand([
|
||||
'[하이]·[로우]·[스윙] 중 하나를 누르세요. 하이는 높은 족보, 로우는 낮은 패로 겨뤄요. 스윙은 둘 다 이겨야 모두 가져가고, 하나라도 지면 못 받아요.',
|
||||
'모두 고른 뒤 한꺼번에 공개되고, 하이 1등과 로우 1등이 칩을 반씩 나눠요.',
|
||||
]);
|
||||
}
|
||||
return withHand([`${m.declare ? `${SIDE_KO[m.declare]}(으)로 선언했어요. ` : ''}다른 사람이 선언할 때까지 기다려 주세요.`]);
|
||||
default:
|
||||
return `${watchText(v, players, me)}${away}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import { PlayingCard } from '../../components/cards/PlayingCard';
|
||||
import { Chips, PlayChipNotice, formatChips } from '../../components/cards/Chips';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
|
||||
const MODE_KO: Record<PokerMode, string> = {
|
||||
holdem: '텍사스 홀덤',
|
||||
@@ -985,6 +987,8 @@ const ui: GameUI<PokerView, PokerOptions> = {
|
||||
Options,
|
||||
optionsSummary,
|
||||
Rules,
|
||||
quickStart,
|
||||
helpNow,
|
||||
};
|
||||
|
||||
export default ui;
|
||||
|
||||
79
apps/web/src/games/poker/quick.tsx
Normal file
79
apps/web/src/games/poker/quick.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
/** 포커 30초 규칙 요약 (docs/07 §5). Chips are play points only. */
|
||||
import { PlayingCard } from '../../components/cards/PlayingCard';
|
||||
import { ChipIcon } from '../../components/cards/Chips';
|
||||
import type { QuickCard } from '../types';
|
||||
|
||||
function Fan({ cards, label }: { cards: string[]; label: string }) {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }} aria-hidden>
|
||||
<div style={{ display: 'flex' }}>
|
||||
{cards.map((c, i) => (
|
||||
<PlayingCard key={c} card={c} size="md" style={i > 0 ? { marginLeft: -16 } : undefined} />
|
||||
))}
|
||||
</div>
|
||||
<strong style={{ fontSize: '1.2rem' }}>{label}</strong>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MiniButton({ text, sub, color }: { text: string; sub: string; color: string }) {
|
||||
return (
|
||||
<span
|
||||
style={{ display: 'inline-flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', width: 58, height: 52, borderRadius: 10, background: color, color: '#fff', fontWeight: 800, lineHeight: 1.15 }}
|
||||
>
|
||||
<span style={{ fontSize: '1.05rem' }}>{text}</span>
|
||||
<small style={{ fontSize: '0.75rem', opacity: 0.9 }}>{sub}</small>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function BetPic() {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 10 }} aria-hidden>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 6, fontWeight: 900, fontSize: '1.3rem' }}>
|
||||
<ChipIcon size={26} />
|
||||
<span>모인 칩 120</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 4 }}>
|
||||
<MiniButton text="다이" sub="포기" color="#dc2626" />
|
||||
<MiniButton text="체크" sub="0 칩" color="#2563eb" />
|
||||
<MiniButton text="콜" sub="+10 칩" color="#2563eb" />
|
||||
<MiniButton text="하프" sub="+60 칩" color="#7c3aed" />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HandPic() {
|
||||
return (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 8 }} aria-hidden>
|
||||
<div style={{ display: 'flex', gap: 4 }}>
|
||||
<PlayingCard card="QH" size="md" />
|
||||
<PlayingCard card="QS" size="md" />
|
||||
<PlayingCard card="7D" size="md" />
|
||||
</div>
|
||||
<span style={{ fontSize: '1.3rem', fontWeight: 900, padding: '2px 12px', borderRadius: 999, background: '#fde047', color: '#422006' }}>지금: 원페어</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const quickStart: QuickCard[] = [
|
||||
{
|
||||
pic: <Fan cards={['KS', 'KH', 'KD', '7C', '7S']} label="풀하우스" />,
|
||||
alt: '카드 5장(K 세 장과 7 두 장)이 펼쳐져 있고 아래에 풀하우스라고 적혀 있어요',
|
||||
title: '족보가 센 사람이 이겨요',
|
||||
text: '모드마다 카드를 받는 방법은 달라도, 마지막까지 남은 사람끼리 카드를 비교해 족보가 가장 센 사람이 모인 칩을 가져가요.',
|
||||
},
|
||||
{
|
||||
pic: <BetPic />,
|
||||
alt: '모인 칩 숫자 아래에 다이, 체크, 콜, 하프 버튼이 나란히 있어요',
|
||||
title: '차례마다 칩을 걸어요',
|
||||
text: '내 차례에 [체크]로 넘기거나 [콜]로 앞사람만큼 맞추거나 더 올려요. [다이]·[폴드]를 누르면 이번 판은 포기해요.',
|
||||
},
|
||||
{
|
||||
pic: <HandPic />,
|
||||
alt: '퀸 두 장과 7 한 장 아래에 지금 원페어라고 노란 글씨로 적혀 있어요',
|
||||
title: '내 족보는 "지금:"에',
|
||||
text: '족보 표시가 켜진 방에서는 내 카드 아래 "지금:"에 족보가 보여요. 순서는 [족보] 칸에 있어요. 모두 포기하면 남은 한 명이 가져가요.',
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user