M9: 게임 26종 30초 요약 카드·[?] 지금 할 수 있는 것 내용

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-06 13:35:21 +09:00
parent 32e3e89d8d
commit 68edd9b434
102 changed files with 6555 additions and 1 deletions

View File

@@ -0,0 +1,68 @@
import { expect, test } from 'bun:test';
import { applyAction, setupGame, usersOf } from '../help-kit.test-util';
import { GAMES } from '@bg/games';
import { helpNow } from './help';
const ids = ['A', 'B', 'C', 'D'];
const users = usersOf(ids);
const view = (s: unknown, who: string | null) => GAMES.dalmuti!.view(s, who) as any;
const nickOf = (id: string) => users[id]!.nickname;
/** Everyone confirms the hand without a revolution, then the two 달무티 give back their suggested cards. */
function toPlaying(state: any) {
let s = state;
for (const p of ids) s = applyAction('dalmuti', s, p, { type: 'confirmHand' });
return s;
}
test('달무티: 손패 확인 단계와 혁명', () => {
const { state } = setupGame('dalmuti', 4);
expect(state.phase.kind).toBe('revolutionCheck');
const top = state.order[0] as string;
const last = state.order[3] as string;
expect(helpNow(view(state, top), top, users)).toContain('[손패 확인]');
expect(helpNow(view(state, top), top, users)).toContain('대농노에게서 가장 좋은 카드 2장');
expect(helpNow(view(state, last), last, users)).toContain('대달무티에게 자동으로');
expect(helpNow(view(state, null), null, users)).toContain('준비 중이에요');
// Give both jesters to the 대농노: the 혁명 button appears and is explained as 대혁명.
const jesters = Object.values(state.hands).flat().filter((c: any) => c.n === 13);
for (const p of ids) state.hands[p] = state.hands[p].filter((c: any) => c.n !== 13);
state.hands[last].push(...jesters);
const t = helpNow(view(state, last), last, users);
expect(t).toContain('[혁명!]');
expect(t).toContain('대혁명');
});
test('달무티: 세금 돌려주기', () => {
const { state } = setupGame('dalmuti', 4);
const s = toPlaying(state);
expect(s.phase.kind).toBe('taxReturn');
const top = s.order[0] as string;
const last = s.order[3] as string;
const t = helpNow(view(s, top), top, users);
expect(t).toContain('돌려줄 카드 2장');
expect(t).toContain('[돌려주기]');
expect(helpNow(view(s, last), last, users)).toContain('세금으로 내 가장 좋은 카드');
expect(helpNow(view(s, null), null, users)).toContain('세금 카드를 주고받는 중');
});
test('달무티: 새로 시작 / 따라 내기 / 기다리기 / 관전', () => {
const { state } = setupGame('dalmuti', 4);
let s = toPlaying(state);
for (const p of [s.order[0], s.order[1]]) {
const v = view(s, p);
s = applyAction('dalmuti', s, p, { type: 'returnTax', cardIds: v.my.suggestedReturn });
}
expect(s.phase.kind).toBe('playing');
const lead = s.current as string;
expect(helpNow(view(s, lead), lead, users)).toContain('새로 시작해요');
const other = ids.find((p) => p !== lead)!;
expect(helpNow(view(s, other), other, users)).toContain(`${nickOf(lead)}님 차례예요. 기다려 주세요`);
expect(helpNow(view(s, null), null, users)).toContain(`${nickOf(lead)}님 차례예요`);
const card = s.hands[lead].find((c: any) => c.n === 12) ?? s.hands[lead].find((c: any) => c.n !== 13);
s = applyAction('dalmuti', s, lead, { type: 'play', cardIds: [card.id] });
const next = s.current as string;
const t = helpNow(view(s, next), next, users);
expect(t).toContain(`지금 바닥은 ${card.n} × 1장`);
expect(t).toContain('[패스]');
});

View File

@@ -0,0 +1,102 @@
/** 달무티 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view. */
import type { DalmutiView } from '@bg/games/dalmuti';
import type { PublicUser } from '@bg/shared/lite';
const JESTER = 13;
const nm = (players: Record<string, PublicUser>, id: string | null | undefined) => `${(id && players[id]?.nickname) || '다른 사람'}님`;
const rankText = (r: number) => (r === JESTER ? '광대(13)' : String(r));
const faces = (cards: number[]) => cards.map((n) => (n === JESTER ? '광대' : String(n))).join(', ');
/** What the tax step will do for this title (no revolution). */
function taxPlan(title: string): string {
switch (title) {
case '대달무티':
return '혁명이 없으면 대농노에게서 가장 좋은 카드 2장을 받고, 아무 카드 2장을 골라 돌려줘요.';
case '소달무티':
return '혁명이 없으면 소농노에게서 가장 좋은 카드 1장을 받고, 아무 카드 1장을 골라 돌려줘요.';
case '소농노':
return '혁명이 없으면 내 가장 좋은(가장 낮은 숫자) 카드 1장이 소달무티에게 자동으로 넘어가요.';
case '대농노':
return '혁명이 없으면 내 가장 좋은(가장 낮은 숫자) 카드 2장이 대달무티에게 자동으로 넘어가요.';
default:
return '평민은 세금을 내지도 받지도 않아요.';
}
}
export function helpNow(v: DalmutiView, me: string | null, players: Record<string, PublicUser>): string {
const goal = '숫자가 낮을수록 좋은 카드예요. 카드를 먼저 다 낼수록 다음 라운드에서 높은 신분이 돼요.';
if (v.phase === 'finished') return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n결과 창에서 [한 판 더]를 누르면 다시 할 수 있어요.';
const seat = me ? v.seats.find((s) => s.id === me) : undefined;
const my = seat ? v.my : null;
const roundText = `${v.round}/${v.options.rounds}라운드`;
if (v.phase === 'revolutionCheck') {
const done = v.seats.filter((s) => s.confirmed).length;
if (!my) return `${roundText} 준비 중이에요. 모두 자기 카드를 보고 확인하는 중이에요(${done}/${v.seats.length}).\n${goal}`;
const lines: string[] = [];
if (my.canDeclareRevolution) {
const great = v.seats[v.seats.length - 1]?.id === me;
lines.push(`광대 2장이 다 있어요! [혁명!]을 누르면 광대 2장을 보여 주고, 이번 라운드는 세금이 없어요.${great ? ' 나는 대농노라서 대혁명이 되어 신분이 완전히 뒤집혀요.' : ''}`);
lines.push('혁명하지 않으려면 [손패 확인]을 눌러요.');
return lines.join('\n');
}
if (my.canConfirm) {
lines.push(`${roundText} 준비예요(내 신분: ${seat!.title}). 내 카드를 보고 [손패 확인]을 눌러 주세요.`);
lines.push(taxPlan(seat!.title));
} else {
lines.push(`손패를 확인했어요. 다른 사람이 확인하기를 기다리는 중이에요(${done}/${v.seats.length}).`);
lines.push(taxPlan(seat!.title));
}
return lines.join('\n');
}
if (v.phase === 'taxReturn') {
const pending = v.taxPending.filter((p) => !p.done);
const pendingText = pending.map((p) => nm(players, p.from)).join(', ');
if (!my) return `세금 카드를 주고받는 중이에요. 농노는 가장 좋은 카드를 달무티에게 주고, 달무티는 아무 카드나 같은 장수만큼 돌려줘요.${pendingText ? `\n${pendingText}이 돌려줄 카드를 고르고 있어요.` : ''}`;
if (my.owe) {
const got = v.tax.find((t) => t.kind === 'tax' && t.to === me);
const gotText = got?.cards ? `세금으로 ${nm(players, got.from)}에게서 좋은 카드를 받았어요(받은 카드: ${faces(got.cards)}). ` : '';
return `${gotText}${nm(players, my.owe.to)}에게 돌려줄 카드 ${my.owe.count}장을 눌러 고르고 [돌려주기]를 눌러요.\n처음에는 가장 큰 숫자 카드가 골라져 있어요. 받은 카드를 돌려줘도 돼요.`;
}
const paid = v.tax.find((t) => t.kind === 'tax' && t.from === me);
const lines: string[] = [];
if (paid) lines.push(`세금으로 내 가장 좋은 카드${paid.cards ? `(${faces(paid.cards)})` : ''} ${paid.count}장이 ${nm(players, paid.to)}에게 넘어갔어요. 곧 ${paid.count}장을 돌려받아요.`);
else lines.push('세금 카드를 주고받는 중이에요.');
if (pendingText) lines.push(`${pendingText}이 돌려줄 카드를 고르고 있어요. 기다려 주세요.`);
return lines.join('\n');
}
// playing
const top = v.trick?.top ?? null;
const topText = top ? `${rankText(top.rank)} × ${top.count}장` : '';
const cur = v.current;
if (my && cur === me) {
if (my.leading) {
const lines = ['내 차례예요. 새로 시작해요. 같은 숫자 카드를 원하는 장수만큼 낼 수 있어요.', '숫자 묶음을 누르고 −/+로 장수를 정한 뒤 [내기]를 눌러요. 새로 시작할 때는 패스할 수 없어요.'];
if (my.jesters > 0) lines.push('광대는 [🃏 광대 섞기]로 다른 숫자와 함께 내면 그 숫자로 쳐요. 광대만 내면 13이에요.');
return lines.join('\n');
}
const lines = [`내 차례예요. 지금 바닥은 ${topText}이에요.`];
if (top!.rank === 1) lines.push('1보다 낮은 숫자는 없으니 [패스]를 눌러 주세요.');
else {
lines.push(`같은 ${top!.count}장으로 ${rankText(top!.rank)}보다 낮은 숫자를 내거나 [패스]를 눌러요.`);
if (my.choices.length > 0) {
lines.push('밝게 보이는 숫자 묶음만 낼 수 있어요. 묶음을 누른 뒤 [내기]를 눌러요.');
if (my.choices.some((c) => c.needsJester)) lines.push("'광대 필요'라고 적힌 숫자는 광대를 섞어야 장수가 맞아요.");
} else lines.push('낼 수 있는 카드가 없어요. [패스]를 눌러 주세요.');
}
lines.push(v.options.passLocksOut ? '이 방 규칙에서는 패스하면 이번 트릭이 끝날 때까지 못 내요.' : '패스해도 차례가 다시 오면 낼 수 있어요.');
return lines.join('\n');
}
const curNick = nm(players, cur);
const tableLine = top ? `지금 바닥은 ${topText}(${nm(players, top.by)}이 냄)이에요.` : `${curNick}이 새로 시작해요.`;
if (!my || !seat) return `${curNick} 차례예요. ${tableLine}\n${goal}`;
if (seat.place !== null) return `카드를 ${seat.place}번째로 다 냈어요! 다음 라운드에서 그만큼 높은 신분이 돼요.\n${curNick} 차례예요. 남은 사람을 지켜봐요.`;
const lines = [`${curNick} 차례예요. 기다려 주세요. ${tableLine}`];
if (my.lockedOut) lines.push('이번 트릭은 패스해서 빠졌어요. 다음 트릭을 기다려요.');
lines.push(`내 신분은 ${seat.title}, 남은 카드는 ${my.hand.length}장이에요.`);
return lines.join('\n');
}

View File

@@ -6,6 +6,8 @@ import { Avatar } from '../../components/ui';
import { TurnTimer } from '../../components/TurnTimer';
import { haptic, sounds } from '../../lib/feedback';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
const JESTER = 13;
/** Same names as the rules module (kept here so the screen chunk does not pull in the rules code). */
@@ -1002,6 +1004,8 @@ const ui: GameUI<DalmutiView, DalmutiOptions> = {
Options,
optionsSummary,
Rules,
quickStart,
helpNow,
};
export default ui;

View File

@@ -0,0 +1,85 @@
/** 달무티 30초 규칙 요약 (docs/07 §5). */
import type { QuickCard } from '../types';
const HUE: Record<number, string> = { 1: '#b7791f', 2: '#7c3aed', 3: '#4338ca', 5: '#0f766e', 7: '#4d7c0f', 9: '#c2410c', 12: '#57534e', 13: '#be185d' };
/** One card in a 40 × 56 box at (x, y). */
function Card({ n, x, y }: { n: number; x: number; y: number }) {
const c = HUE[n] ?? '#475569';
return (
<g transform={`translate(${x} ${y})`}>
<rect width={40} height={56} rx={6} fill="#fffdf7" stroke={c} strokeWidth={2.5} />
<rect width={40} height={12} rx={6} fill={c} />
<text x={20} y={40} textAnchor="middle" fontSize={n === 13 ? 20 : 24} fontWeight={900} fill={c}>
{n === 13 ? '★' : n}
</text>
</g>
);
}
function Set({ n, count, x, y }: { n: number; count: number; x: number; y: number }) {
return (
<g>
{Array.from({ length: count }, (_, i) => (
<Card key={i} n={n} x={x + i * 16} y={y} />
))}
</g>
);
}
export const quickStart: QuickCard[] = [
{
pic: (
<svg viewBox="0 0 250 120" width={250} height={120} aria-hidden>
<Card n={1} x={10} y={10} />
<Card n={5} x={70} y={10} />
<Card n={12} x={130} y={10} />
<Card n={13} x={200} y={10} />
<text x={30} y={90} textAnchor="middle" fontSize={14} fontWeight={800} fill="#15803d">좋음</text>
<text x={150} y={90} textAnchor="middle" fontSize={14} fontWeight={800} fill="#b91c1c">나쁨</text>
<text x={220} y={90} textAnchor="middle" fontSize={14} fontWeight={800} fill="#be185d">광대</text>
<path d="M40 104 H140" stroke="#374151" strokeWidth={3} markerEnd="url(#dm-q-arrow)" />
<defs>
<marker id="dm-q-arrow" viewBox="0 0 10 10" refX={8} refY={5} markerWidth={6} markerHeight={6} orient="auto">
<path d="M0 0 L10 5 L0 10 z" fill="#374151" />
</marker>
</defs>
</svg>
),
alt: '숫자 1, 5, 12 카드와 광대 카드. 1이 가장 좋고 12로 갈수록 나빠요',
title: '낮은 숫자가 좋아요',
text: '숫자 n인 카드는 n장씩 있어요. 숫자가 낮을수록 좋아요. 광대는 다른 숫자와 같이 내면 그 숫자가 돼요.',
},
{
pic: (
<svg viewBox="0 0 250 150" width={250} height={150} aria-hidden>
<Set n={9} count={3} x={10} y={10} />
<text x={125} y={44} fontSize={26} fontWeight={900} fill="#374151">→</text>
<Set n={5} count={3} x={160} y={10} />
<text x={40} y={94} textAnchor="middle" fontSize={14} fontWeight={800} fill="#374151">9 × 3장</text>
<text x={192} y={94} textAnchor="middle" fontSize={14} fontWeight={800} fill="#15803d">5 × 3장</text>
<text x={125} y={130} textAnchor="middle" fontSize={14} fontWeight={700} fill="#6b7280">같은 장수 · 더 낮은 숫자</text>
</svg>
),
alt: '9 세 장 위에 5 세 장을 내는 모습',
title: '같은 장수로 더 낮게',
text: '새로 시작하는 사람은 같은 숫자를 원하는 장수만큼 내요. 다음 사람은 같은 장수로 더 낮은 숫자를 내거나 패스해요.',
},
{
pic: (
<svg viewBox="0 0 250 130" width={250} height={130} aria-hidden>
<text x={40} y={50} textAnchor="middle" fontSize={40}>👑</text>
<text x={40} y={80} textAnchor="middle" fontSize={14} fontWeight={800} fill="#374151">대달무티</text>
<text x={210} y={50} textAnchor="middle" fontSize={40}>🧺</text>
<text x={210} y={80} textAnchor="middle" fontSize={14} fontWeight={800} fill="#374151">대농노</text>
<Card n={1} x={88} y={10} />
<Card n={2} x={122} y={10} />
<text x={125} y={92} textAnchor="middle" fontSize={22} fontWeight={900} fill="#b91c1c">← 세금</text>
<text x={125} y={120} textAnchor="middle" fontSize={13} fontWeight={700} fill="#6b7280">먼저 다 내면 다음엔 👑</text>
</svg>
),
alt: '대농노가 좋은 카드 2장을 대달무티에게 세금으로 주는 모습',
title: '먼저 털면 높은 신분',
text: '카드를 먼저 다 낸 순서로 다음 신분이 정해져요. 농노는 가장 좋은 카드를 달무티에게 세금으로 주고, 같은 장수를 돌려받아요.',
},
];