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,59 @@
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 users = usersOf(['A', 'B', 'C']);
const view = (s: unknown, who: string | null) => GAMES.catchmind!.view(s, who) as any;
test('그림 맞히기: 단어 고르기 — 출제자 / 맞히는 사람 / 관전', () => {
const { state } = setupGame('catchmind', 3);
const d: string = state.turn.drawer;
const g = ['A', 'B', 'C'].find((p) => p !== d)!;
const dn = users[d]!.nickname;
expect(helpNow(view(state, d), d, users)).toContain('단어 하나를 눌러 골라요');
const gt = helpNow(view(state, g), g, users);
expect(gt).toContain(`${dn}님이 그릴 단어를 고르고 있어요`);
expect(gt).not.toContain(state.turn.choices[0].word);
expect(helpNow(view(state, null), null, users)).toContain(`${dn}님이 그릴 단어를 고르고 있어요`);
});
test('그림 맞히기: 그리기 — 출제자는 단어를 보고, 맞히는 사람은 힌트만', () => {
const { state } = setupGame('catchmind', 3);
const d: string = state.turn.drawer;
const [g1, g2] = ['A', 'B', 'C'].filter((p) => p !== d) as [string, string];
const s = applyAction('catchmind', state, d, { type: 'chooseWord', index: 0 });
const word: string = s.turn.word.word;
const dt = helpNow(view(s, d), d, users);
expect(dt).toContain(`"${word}"`);
expect(dt).toContain('글자나 숫자는 쓰지 말고');
expect(dt).toContain('[거의 다 왔어요]');
const gt = helpNow(view(s, g1), g1, users);
expect(gt).toContain('[맞히기]');
expect(gt).toContain('글자예요');
expect(gt).not.toContain(word);
const spec = helpNow(view(s, null), null, users);
expect(spec).toContain('그림을 그리고 있어요');
expect(spec).not.toContain(word);
const s2 = applyAction('catchmind', s, g1, { type: 'guess', text: word });
const st = helpNow(view(s2, g1), g1, users);
expect(st).toContain('맞혔어요!');
expect(st).toContain('이미 맞힌 사람에게만');
expect(helpNow(view(s2, g2), g2, users)).not.toContain(word);
});
test('그림 맞히기: 공개 / 끝', () => {
const { state } = setupGame('catchmind', 2, { guessMode: 'firstOnly' });
const d: string = state.turn.drawer;
const g = d === 'A' ? 'B' : 'A';
let s = applyAction('catchmind', state, d, { type: 'chooseWord', index: 0 });
const word: string = s.turn.word.word;
expect(helpNow(view(s, g), g, users)).toContain('가장 먼저 맞힌 사람만');
s = applyAction('catchmind', s, g, { type: 'guess', text: word });
expect(s.turn.phase).toBe('reveal');
expect(helpNow(view(s, g), g, users)).toContain(`정답은 "${word}"였어요`);
s.finished = true;
s.final = { ranking: [], turns: [], summary: '호랑이님 우승!' };
expect(helpNow(view(s, null), null, users)).toContain('호랑이님 우승!');
});

View File

@@ -0,0 +1,48 @@
/** 그림 맞히기 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view. */
import type { CatchmindView } from '@bg/games/catchmind';
import type { PublicUser } from '@bg/shared/lite';
function hintLine(v: CatchmindView): string {
if (!v.hint) return '이 방은 힌트가 없어요.';
const letters = v.hint.filter((c) => c !== ' ').length;
const more = v.options.hints === 'full' ? ' 시간이 지나면 첫소리(초성)나 글자 하나가 더 보일 수 있어요.' : '';
return `그림 위 힌트 칸을 보면 정답은 ${letters}글자예요.${more}`;
}
export function helpNow(v: CatchmindView, me: string | null, players: Record<string, PublicUser>): string {
const nick = (id: string) => players[id]?.nickname ?? '다른 사람';
const drawer = `${nick(v.drawer)}님`;
const turn = `${v.round}/${v.rounds}라운드`;
if (v.phase === 'ended') return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n최종 순위와 지난 문제 목록에서 누가 무엇을 맞혔는지 볼 수 있어요.';
const away = !!me && v.away.includes(me) ? '\n자리 비움으로 표시돼 그릴 차례를 건너뛰고 있어요. [돌아왔어요]를 누르면 다시 차례가 와요.' : '';
const left = !!me && v.left.includes(me);
if (v.phase === 'reveal') {
const ans = v.word ? `정답은 "${v.word}"였어요. ` : '';
const chat = v.canChat ? ' 아래 채팅 칸에서 이야기를 나눌 수 있어요.' : '';
return `이번 그림이 끝났어요. ${ans}곧 다음 사람이 그려요.${chat}${away}`;
}
if (v.role === 'spectator' || left) {
if (v.phase === 'choosing') return `${turn} · ${drawer}이 그릴 단어를 고르고 있어요. 곧 그림이 시작돼요.`;
return `${turn} · ${drawer}이 그림을 그리고 있어요. 다른 사람들이 채팅으로 정답을 맞히는 중이에요.`;
}
if (v.role === 'drawer') {
if (v.phase === 'choosing') {
const pick = v.choices && v.choices.length > 1 ? '그림판 위 단어 버튼 중 그릴 단어 하나를 눌러 골라요. 10초 안에 안 고르면 첫 번째 단어로 정해져요.' : '그릴 단어를 눌러 정해요.';
return `내가 그릴 차례예요. ${pick}\n단어는 나만 볼 수 있어요.`;
}
const word = v.word ? `그릴 단어는 "${v.word}"예요(나와 맞힌 사람만 보여요). ` : '';
const report = v.options.letterReport ? ' 글자를 쓰면 신고를 받아 0점이 될 수 있어요.' : '';
return `${word}그림판에 손가락이나 마우스로 그려요. 아래 버튼으로 색, 굵기, 지우개(🧽), 되돌리기(↶), 전체 지우기(🗑)를 쓸 수 있어요.\n글자나 숫자는 쓰지 말고 그림으로만 설명해요.${report}\n그리는 동안 채팅은 못 하고 [거의 다 왔어요]·[비슷해요]·[아니에요] 반응 버튼만 보낼 수 있어요.`;
}
// guesser / solver
if (v.phase === 'choosing') return `${turn} · ${drawer}이 그릴 단어를 고르고 있어요. 그림이 시작되면 보고 정답을 입력해요.${v.canChat ? ' 지금은 채팅만 할 수 있어요.' : ''}${away}`;
if (v.role === 'solver') {
const word = v.word ? ` 정답은 "${v.word}"예요.` : '';
return `맞혔어요!${word} 다른 사람들이 맞힐 때까지 기다려요.\n지금 보내는 채팅은 그린 사람과 이미 맞힌 사람에게만 보여요. 정답은 말하지 마세요.${away}`;
}
const pts = v.options.guessMode === 'firstOnly' ? '가장 먼저 맞힌 사람만 점수를 받고 바로 다음 그림으로 넘어가요.' : '먼저 맞힐수록 점수가 높아요(10, 8, 6, 4점...).';
const lines = [`${drawer}이 그리고 있어요. 그림을 보고 생각나는 답을 아래 칸에 써서 [맞히기]를 눌러요. 여러 번 써도 돼요. ${pts}`, hintLine(v)];
if (v.canReport) lines.push(`그림 대신 글자를 썼다면 [🚩 글자를 썼어요]로 신고할 수 있어요(지금 ${v.reports}/${v.reportsNeeded}명).`);
else if (v.reportedByMe) lines.push(`신고했어요(${v.reports}/${v.reportsNeeded}명). 절반이 넘으면 이번 그림이 끝나요.`);
return lines.join('\n') + away;
}

View File

@@ -8,6 +8,8 @@ import { haptic, sounds } from '../../lib/feedback';
import { useWide } from '../../lib/media';
import { socket } from '../../net/socket';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
// ---------------------------------------------------------------- constants (mirror packages/games/src/catchmind/types.ts)
@@ -1239,6 +1241,8 @@ const ui: GameUI<CatchmindView, CatchmindOptions> = {
Options,
optionsSummary,
Rules,
quickStart,
helpNow,
ownChat: true,
};

View File

@@ -0,0 +1,130 @@
/** 그림 맞히기 30초 규칙 요약 (docs/07 §5). */
import type { ReactNode } from 'react';
import type { QuickCard } from '../types';
function Pic({ children }: { children: ReactNode }) {
return (
<svg viewBox="0 0 250 150" width={250} height={150} aria-hidden>
{children}
</svg>
);
}
/** White drawing paper with a simple cat doodle. */
function Paper({ x, y, w = 120, blank = false }: { x: number; y: number; w?: number; blank?: boolean }) {
const k = w / 120;
return (
<g transform={`translate(${x} ${y}) scale(${k})`}>
<rect x={0} y={0} width={120} height={110} rx={8} fill="#fff" stroke="#94a3b8" strokeWidth={2} />
{!blank && <Cat />}
</g>
);
}
function Cat() {
return (
<>
<g fill="none" stroke="#1f2937" strokeWidth={3} strokeLinecap="round" strokeLinejoin="round">
<circle cx={60} cy={62} r={28} />
<path d="M38 44 L36 22 L52 36" />
<path d="M82 44 L84 22 L68 36" />
<path d="M30 66 L12 62 M30 72 L12 76 M90 66 L108 62 M90 72 L108 76" />
<path d="M54 72 Q60 78 66 72" />
</g>
<circle cx={50} cy={56} r={3.5} fill="#1f2937" />
<circle cx={70} cy={56} r={3.5} fill="#1f2937" />
</>
);
}
function Bubble({ x, y, text, ok }: { x: number; y: number; text: string; ok?: boolean }) {
return (
<g>
<rect x={x} y={y} width={92} height={30} rx={15} fill={ok ? '#dcfce7' : '#f1f5f9'} stroke={ok ? '#16a34a' : '#94a3b8'} strokeWidth={2} />
<text x={x + 46} y={y + 20} textAnchor="middle" fontSize={14} fontWeight={700} fill="#1f2937">
{text}
</text>
</g>
);
}
export const quickStart: QuickCard[] = [
{
pic: (
<Pic>
<Paper x={8} y={20} />
<text x={118} y={36} fontSize={26} aria-hidden>
🖍
</text>
<Bubble x={150} y={22} text="강아지?" />
<Bubble x={150} y={62} text="호랑이?" />
<Bubble x={150} y={102} text="고양이!" ok />
</Pic>
),
alt: '그림판에 고양이 그림이 있고, 옆에 사람들이 정답을 써 보낸 말풍선이 있어요',
title: '한 명이 그리고 모두 맞혀요',
text: '차례대로 한 사람이 단어를 그림으로 그리고, 나머지는 그림을 보고 정답을 채팅 칸에 써서 맞혀요.',
},
{
pic: (
<Pic>
<Paper x={20} y={20} blank />
<text x={80} y={70} textAnchor="middle" fontSize={30} fontWeight={800} fill="#475569" opacity={0.85}>
고양이
</text>
<g stroke="#dc2626" strokeWidth={7} strokeLinecap="round">
<line x1={40} y1={34} x2={120} y2={114} />
<line x1={120} y1={34} x2={40} y2={114} />
</g>
<g transform="translate(160 28)">
{['○', '○', '○'].map((c, i) => (
<g key={i}>
<rect x={i * 28} y={0} width={24} height={30} rx={5} fill="#f1f5f9" stroke="#94a3b8" />
<text x={i * 28 + 12} y={21} textAnchor="middle" fontSize={15} fill="#334155">
{c}
</text>
</g>
))}
{['ㄱ', 'ㅇ', 'ㅇ'].map((c, i) => (
<g key={i}>
<rect x={i * 28} y={50} width={24} height={30} rx={5} fill="#f1f5f9" stroke="#94a3b8" />
<text x={i * 28 + 12} y={71} textAnchor="middle" fontSize={15} fontWeight={700} fill="#334155">
{c}
</text>
</g>
))}
</g>
</Pic>
),
alt: '그림판에 글자를 쓴 것에 빨간 ✕ 표시가 있고, 옆에 글자 수와 첫소리 힌트 칸이 있어요',
title: '글자는 쓰면 안 돼요',
text: '그리는 사람만 단어를 보고, 글자나 숫자 없이 그림으로만 설명해요. 방 설정에 따라 글자 수·첫소리 힌트가 보여요.',
},
{
pic: (
<Pic>
{[
['1등', '+10', 48],
['2등', '+8', 125],
['3등', '+6', 202],
].map(([a, b, x]) => (
<g key={a as string}>
<circle cx={x as number} cy={60} r={32} fill="#fef3c7" stroke="#d97706" strokeWidth={3} />
<text x={x as number} y={55} textAnchor="middle" fontSize={15} fontWeight={700} fill="#92400e">
{a}
</text>
<text x={x as number} y={77} textAnchor="middle" fontSize={20} fontWeight={800} fill="#92400e">
{b}
</text>
</g>
))}
<text x={125} y={130} textAnchor="middle" fontSize={15} fontWeight={700} fill="currentColor">
빨리 맞힐수록 점수가 커요
</text>
</Pic>
),
alt: '먼저 맞힌 순서대로 1등 10점, 2등 8점, 3등 6점을 받는 모습이에요',
title: '빨리 맞히면 점수가 커요',
text: '먼저 맞힐수록 점수를 많이 받고, 누가 맞히면 그린 사람도 점수를 받아요. 모두 다 그린 뒤 점수가 가장 높으면 우승!',
},
];