그림 맞히기·클루: 그리기·차례 시간 무제한(출제자 정답 공개로 넘기기), 소리·움직임, 할리갈리·사과 게임 문서에 무제한

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 13:01:42 +09:00
parent bafbf95d98
commit b8966db2a6
15 changed files with 413 additions and 84 deletions

View File

@@ -57,3 +57,13 @@ test('그림 맞히기: 공개 / 끝', () => {
s.final = { ranking: [], turns: [], summary: '호랑이님 우승!' };
expect(helpNow(view(s, null), null, users)).toContain('호랑이님 우승!');
});
test('그림 맞히기: 그리기 무제한이면 출제자에게 정답 공개 안내', async () => {
const { setupGame, usersOf } = await import('../help-kit.test-util');
const { GAMES } = await import('@bg/games');
const users = usersOf(['A', 'B', 'C']);
const { state } = setupGame('catchmind', 3, { drawSeconds: null, wordChoice: false });
const d: string = state.turn.drawer;
const t = helpNow(GAMES.catchmind!.view(state, d) as never, d, users);
expect(t).toContain('[정답 공개하고 넘기기]');
});

View File

@@ -32,7 +32,7 @@ export function helpNow(v: CatchmindView, me: string | null, players: Record<str
}
const word = v.word ? `그릴 단어는 "${v.word}"예요(나와 맞힌 사람만 보여요). ` : '';
const report = v.options.letterReport ? ' 글자를 쓰면 신고를 받아 0점이 될 수 있어요.' : '';
return `${word}그림판에 손가락이나 마우스로 그려요. 아래 버튼으로 색, 굵기, 지우개(🧽), 되돌리기(↶), 전체 지우기(🗑)를 쓸 수 있어요.\n글자나 숫자는 쓰지 말고 그림으로만 설명해요.${report}\n그리는 동안 채팅은 못 하고 [거의 다 왔어요]·[비슷해요]·[아니에요] 반응 버튼만 보낼 수 있어요.`;
return `${word}그림판에 손가락이나 마우스로 그려요. 아래 버튼으로 색, 굵기, 지우개(🧽), 되돌리기(↶), 전체 지우기(🗑)를 쓸 수 있어요.\n글자나 숫자는 쓰지 말고 그림으로만 설명해요.${report}\n그리는 동안 채팅은 못 하고 [거의 다 왔어요]·[비슷해요]·[아니에요] 반응 버튼만 보낼 수 있어요.${v.endsAt === null ? '\n그리기 시간은 무제한이에요. 아무도 못 맞히면 [정답 공개하고 넘기기]를 두 번 눌러 넘겨요.' : ''}`;
}
// guesser / solver
if (v.phase === 'choosing') return `${turn} · ${drawer}이 그릴 단어를 고르고 있어요. 그림이 시작되면 보고 정답을 입력해요.${v.canChat ? ' 지금은 채팅만 할 수 있어요.' : ''}${away}`;

View File

@@ -5,7 +5,7 @@ import type { PublicUser, ServerMessage } from '@bg/shared/lite';
import { nameHue } from '../../components/ChatMessage';
import { Avatar } from '../../components/ui';
import { useServerNow } from '../../components/TurnTimer';
import { haptic, sounds } from '../../lib/feedback';
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import { useWide } from '../../lib/media';
import { socket } from '../../net/socket';
import type { BoardProps, GameUI, OptionsProps } from '../types';
@@ -70,6 +70,23 @@ const CHAT_MAX = 100;
const nick = (players: Record<string, PublicUser>, id: string) => players[id]?.nickname ?? '나간 사람';
const userOf = (players: Record<string, PublicUser>, id: string): PublicUser => players[id] ?? { id, nickname: '나간 사람', avatar: null, kind: 'guest' };
/** Game sounds on top of the shared palette (site volume applies). */
const cmSound = {
/** Pencil touching the paper (drawer's own strokes only). */
scribble: () => noise(50, 0.05, 0, 'highpass', 4500),
/** A hint letter turned over. */
hint: () => {
tone(880, 70, 'triangle', 0.1);
tone(1320, 110, 'triangle', 0.08, 60);
},
/** Somebody else got it. */
otherCorrect: () => tone(1175, 120, 'triangle', 0.1),
/** "아까워요!" (only the sender sees it). */
close: () => tone(700, 90, 'triangle', 0.1, 0, { slideTo: 600 }),
/** The drawer's reaction button (heard by the guessers). */
react: () => tone(990, 60, 'sine', 0.08),
};
const CSS = `
.cm { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 8px; align-self: center; }
.cm-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; font-weight: 700; }
@@ -139,6 +156,12 @@ const CSS = `
.cm-form { display: flex; gap: 6px; }
.cm-form .input { flex: 1; min-height: 48px; font-size: 1.05rem; }
.cm-close { color: var(--warning); font-weight: 900; font-size: .95rem; animation: cm-shake .4s ease; }
.cm-over { animation: fade .25s ease both; }
.cm-over .word { animation: cm-word .5s cubic-bezier(.3,1.6,.5,1) both; animation-delay: .1s; }
.cm-hint .ch.flip { animation: anim-flip .42s ease both; }
.cm-strip .p .sc, .cm-score strong { display: inline-block; }
.cm-unl { font-weight: 800; color: var(--text-sub); font-size: .92rem; }
@keyframes cm-word { from { transform: scale(.3) rotate(-6deg); opacity: 0; } }
.cm-away { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--warning-soft); color: var(--text); border-radius: 12px; padding: 8px 12px; }
@keyframes cm-pop { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes cm-shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@@ -156,7 +179,7 @@ const CSS = `
.cm-hint .ch { min-width: 34px; height: 40px; font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
.cm-pop, .cm-close { animation: none; }
.cm-pop, .cm-close, .cm-over, .cm-over .word, .cm-hint .ch.flip { animation: none; }
.cm-bar i { transition: none; }
}
`;
@@ -507,6 +530,7 @@ function Paper({ v, me, act, players }: { v: CatchmindView; me: string | null; a
sender.begin(t.c, t.w, ex, x, y);
drawing.apply({ k: 'b', s: sender.stroke, c: t.c, w: t.w, e: ex });
drawing.addPoint(x, y);
cmSound.scribble();
};
const onMove = (e: React.PointerEvent<HTMLCanvasElement>) => {
if (active.current !== e.pointerId) return;
@@ -606,6 +630,7 @@ function Paper({ v, me, act, players }: { v: CatchmindView; me: string | null; a
</button>
))}
</div>
{v.options.drawSeconds === null && <GiveUp act={act} />}
{!wide && <span className="small muted">그리는 동안에는 채팅 대신 반응 버튼만 쓸 수 있어요.</span>}
</div>
)}
@@ -613,6 +638,29 @@ function Paper({ v, me, act, players }: { v: CatchmindView; me: string | null; a
);
}
/** 무제한 drawings: the drawer may open the answer (press twice). */
function GiveUp({ act }: { act: (a: unknown) => void }) {
const [ask, setAsk] = useState(false);
useEffect(() => {
if (!ask) return;
const t = setTimeout(() => setAsk(false), 3000);
return () => clearTimeout(t);
}, [ask]);
return (
<button
type="button"
className={`btn ${ask ? 'btn-primary' : 'btn-ghost'} btn-sm`}
onClick={() => {
if (!ask) return setAsk(true);
setAsk(false);
act({ type: 'giveUp' });
}}
>
{ask ? '한 번 더 누르면 정답을 공개해요' : '🏳 정답 공개하고 넘기기'}
</button>
);
}
const END_TEXT: Record<TurnEndReason, string> = {
time: '시간이 다 됐어요',
allSolved: '모두 맞혔어요!',
@@ -620,6 +668,7 @@ const END_TEXT: Record<TurnEndReason, string> = {
report: '글자를 썼다는 신고로 끝났어요(출제자 0점)',
drawerAway: '출제자의 연결이 끊겼어요',
drawerLeft: '출제자가 나갔어요',
giveUp: '출제자가 정답을 공개했어요',
};
function Overlay({ v, me, act, players, onSave }: { v: CatchmindView; me: string | null; act: (a: unknown) => void; players: Record<string, PublicUser>; onSave: () => void }) {
@@ -663,7 +712,12 @@ function OverlayMain({ v, act, players, onSave }: { v: CatchmindView; act: (a: u
<h2>그릴 단어를 골라 주세요</h2>
<div className="cm-choices">
{v.choices.map((c, i) => (
<button key={c.word} type="button" className="btn btn-primary" onClick={() => act({ type: 'chooseWord', index: i })} aria-label={`${c.word} (${CATEGORY_KO[c.category]})`}>
<button
key={c.word}
type="button"
className="btn btn-primary anim-deal"
style={{ '--anim-delay': `${i * 90}ms` } as CSSProperties}
onClick={() => act({ type: 'chooseWord', index: i })} aria-label={`${c.word} (${CATEGORY_KO[c.category]})`}>
<span className="ic" aria-hidden>
{CATEGORY_ICON[c.category]}
</span>
@@ -721,7 +775,7 @@ function HintRow({ v }: { v: CatchmindView }) {
{hint ? (
<span role="text" aria-label={`힌트: ${hint.filter((c) => c !== ' ').length}글자, ${hint.map((c) => (c === '○' ? '빈칸' : c === ' ' ? '띄어쓰기' : c)).join(' ')}`} style={{ display: 'inline-flex', gap: 6, flexWrap: 'wrap', justifyContent: 'center' }}>
{hint.map((c, i) => (
<span key={i} className={`ch${c === ' ' ? ' sp' : ''}${c !== '○' && c !== ' ' && !/^[ㄱ-ㅎ]$/.test(c) ? ' open' : ''}`} aria-hidden>
<span key={`${i}-${c}`} className={`ch${c === ' ' ? ' sp' : ''}${c !== '○' && c !== ' ' && !/^[ㄱ-ㅎ]$/.test(c) ? ' open' : ''}${c !== '○' && c !== ' ' && v.phase === 'drawing' ? ' flip' : ''}`} aria-hidden>
{c === ' ' ? '' : c}
</span>
))}
@@ -736,7 +790,21 @@ function HintRow({ v }: { v: CatchmindView }) {
function TimeBar({ v }: { v: CatchmindView }) {
const now = useServerNow(250);
// Ticks in the last 10 seconds of the drawing.
const lastSec = v.phase === 'drawing' && v.endsAt !== null ? Math.ceil(Math.max(0, v.endsAt - now) / 1000) : 0;
const ticked = useRef(0);
useEffect(() => {
if (lastSec > 0 && lastSec <= 10 && lastSec !== ticked.current) sfx.tick();
ticked.current = lastSec;
}, [lastSec]);
if (v.phase === 'ended') return null;
if (v.endsAt === null || v.phaseMs === null) {
return (
<div className="cm-unl" role="status">
⏱ 그리기 시간 무제한 · {v.options.guessMode === 'multi' ? '모두 맞히거나' : '누가 맞히거나'} 출제자가 정답을 공개할 때까지
</div>
);
}
const left = Math.max(0, v.endsAt - now);
const frac = Math.min(1, left / Math.max(1, v.phaseMs));
const sec = Math.ceil(left / 1000);
@@ -777,7 +845,7 @@ function ScoreStrip({ v, me, players }: { v: CatchmindView; me: string | null; p
<span className="nm" aria-hidden style={{ fontWeight: id === me ? 900 : 700 }}>
{nick(players, id)}
</span>
<span className="sc" aria-hidden>
<span key={v.scores[id] ?? 0} className={`sc${v.scores[id] ? ' anim-bump' : ''}`} aria-hidden>
{v.scores[id] ?? 0}점
</span>
</div>
@@ -807,7 +875,7 @@ function ScoreList({ v, me, players }: { v: CatchmindView; me: string | null; pl
✓ 맞힘
</span>
)}
<strong style={{ fontVariantNumeric: 'tabular-nums' }} aria-hidden>
<strong key={v.scores[id] ?? 0} className={v.scores[id] ? 'anim-bump' : undefined} style={{ fontVariantNumeric: 'tabular-nums' }} aria-hidden>
{v.scores[id] ?? 0}점
</strong>
</li>
@@ -917,7 +985,7 @@ function GuessPanel({ v, me, players, act, pending }: { v: CatchmindView; me: st
{v.chat.map((m) => {
const { cls, body } = chatLine(m, me, players, v.drawer);
return (
<li key={m.id} className={`cm-line ${cls}${m.from === me ? ' mine' : ''}`} style={{ '--name-h': nameHue(m.from) } as CSSProperties}>
<li key={m.id} className={`cm-line ${cls}${m.from === me ? ' mine' : ''} anim-slide-up`} style={{ '--name-h': nameHue(m.from) } as CSSProperties}>
{body}
</li>
);
@@ -983,8 +1051,40 @@ function AwayBanner({ v, me, act }: { v: CatchmindView; me: string | null; act:
);
}
/** Sounds for what happens on the table (my own "정답!" is played by the overlay). */
function useTableSounds(v: CatchmindView, me: string | null): void {
const prev = useRef(v);
useEffect(() => {
const p = prev.current;
prev.current = v;
if (p === v) return;
const turnChanged = p.turnNo !== v.turnNo;
if (turnChanged && v.phase === 'choosing') {
if (v.drawer === me) {
sounds.myTurn();
sfx.deal(v.choices?.length ?? 1);
} else sfx.whoosh();
}
if (v.phase === 'drawing' && (p.phase !== 'drawing' || turnChanged)) sfx.whoosh();
if (!turnChanged && v.phase === 'drawing' && v.hintStage > p.hintStage) cmSound.hint();
// New chat lines: someone else got it, the drawer reacted, my "아까워요".
const seen = p.chat.at(-1)?.id ?? 0;
const fresh = v.chat.filter((m) => m.id > seen);
if (fresh.some((m) => m.kind === 'correct' && m.from !== me)) cmSound.otherCorrect();
if (v.role !== 'drawer' && fresh.some((m) => m.kind === 'reaction')) cmSound.react();
if (fresh.some((m) => m.kind === 'close' && m.from === me)) cmSound.close();
if (!turnChanged && p.phase === 'drawing' && v.phase === 'reveal') {
if (v.endReason === 'report') sfx.alarm();
else if (v.endReason === 'allSolved') sfx.fanfare();
else if (v.solvers.length === 0) sfx.bad();
else sfx.cardFlip();
}
}, [v]); // eslint-disable-line react-hooks/exhaustive-deps
}
function CatchmindBoard({ view: v, me, players, act, pending }: BoardProps<CatchmindView>) {
const wide = useWide();
useTableSounds(v, me);
return (
<div className="cm">
<style>{CSS}</style>
@@ -1068,7 +1168,7 @@ function statusText(v: CatchmindView, me: string | null, players: Record<string,
// ---------------------------------------------------------------- options
function Seg<T extends string | number | boolean>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
function Seg<T extends string | number | boolean | null>({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) {
return (
<div className="segmented" role="group" aria-label={label}>
{options.map(([k, l]) => (
@@ -1137,9 +1237,11 @@ function Options({ value: o, onChange }: OptionsProps<CatchmindOptions>) {
[80, '80초'],
[100, '100초'],
[120, '120초'],
[null, '무제한'],
]}
onChange={(drawSeconds) => set({ drawSeconds })}
/>
{o.drawSeconds === null && <span className="small muted">맞힐 때까지 그려요. 아무도 못 맞히면 출제자가 [정답 공개하고 넘기기]로 넘겨요. 힌트는 80초 기준으로 나와요.</span>}
</Field>
<Field label="단어 난이도">
<Seg
@@ -1212,7 +1314,7 @@ function Options({ value: o, onChange }: OptionsProps<CatchmindOptions>) {
function optionsSummary(o: CatchmindOptions): string {
const hint = o.hints === 'full' ? '힌트 많이' : o.hints === 'basic' ? '글자 수 힌트' : '힌트 없음';
const diff = o.difficulty === 'easy' ? '쉬운 단어' : o.difficulty === 'normal' ? '보통 단어' : '';
return [o.guessMode === 'multi' ? '여러 명 맞히기' : '첫 정답자만', `${o.rounds}라운드`, `${o.drawSeconds}초`, hint, diff, o.customOnly ? '추가 단어만' : ''].filter(Boolean).join(' · ');
return [o.guessMode === 'multi' ? '여러 명 맞히기' : '첫 정답자만', `${o.rounds}라운드`, o.drawSeconds === null ? '그리기 무제한' : `${o.drawSeconds}초`, hint, diff, o.customOnly ? '추가 단어만' : ''].filter(Boolean).join(' · ');
}
// ---------------------------------------------------------------- rules
@@ -1223,7 +1325,7 @@ function Rules({ options }: { options?: CatchmindOptions }) {
<div className="stack">
<p>
한 사람(출제자)이 제시어를 <strong>그림으로</strong> 그리고, 나머지는 그림을 보며 <strong>채팅으로 정답</strong>을 맞혀요. 차례대로 돌아가며 모두 한 번씩 그리면 1라운드예요
{o ? `(이 방은 ${o.rounds}라운드, 그리기 ${o.drawSeconds}초)` : ''}.
{o ? `(이 방은 ${o.rounds}라운드, 그리기 ${o.drawSeconds === null ? '시간 무제한' : `${o.drawSeconds}초`})` : ''}.
</p>
<p>
출제자는 단어 3개 중 하나를 10초 안에 골라요. 그리는 동안에는 글자를 쓰면 안 되고, 채팅 대신 "거의 다 왔어요" 같은 반응 버튼만 쓸 수 있어요. 글자를 쓰면 맞히는 사람들이 신고할 수 있어요.
@@ -1234,7 +1336,10 @@ function Rules({ options }: { options?: CatchmindOptions }) {
: '먼저 맞힐수록 점수가 커요: 10점, 8점, 6점, 그다음부터 4점. 출제자는 맞힌 사람 1명마다 2점(최대 12점)을 받아요.'}{' '}
띄어쓰기·문장부호는 무시하고, "사과요"처럼 끝에 붙인 말도 정답으로 봐요. 거의 맞히면 나에게만 "아까워요!"가 떠요.
</p>
<p>시간이 지나면 힌트가 나와요: 처음엔 글자 수, 절반이 지나면 초성, 3/4이 지나면 한 글자. 점수가 같으면 많이 맞힌 사람이 앞서요.</p>
<p>
시간이 지나면 힌트가 나와요: 처음엔 글자 수, 절반이 지나면 초성, 3/4이 지나면 한 글자.{' '}
{o?.drawSeconds === null ? '그리기 시간이 무제한이면 40초에 초성, 60초에 한 글자가 나오고, 아무도 못 맞히면 출제자가 정답을 공개하고 넘길 수 있어요. ' : ''}점수가 같으면 많이 맞힌 사람이 앞서요.
</p>
</div>
);
}