야단법석 달리기(Magical Athlete): 규칙·컴퓨터 상대·화면·도움말·문서·E2E

- 규칙 모듈 packages/games/src/magical-athlete: 선수 24명(능력 처리 순서가 하나로 정해지는 선수만),
  뱀 순서 뽑기(2~3명은 선수 8명·경주마다 둘, 4~6명은 4명·하나), 몰래 동시에 출전 선수 고르기,
  경주 4번(순한 판·거친 판 번갈아, 거친 판은 화살표·돌·별 칸), 1등 3점·2등 1점(갈수록 커지는 점수표 옵션).
  능력 처리 순서 고정: 칸 효과 → 차례인 사람 → 시계 방향, 연쇄는 줄 끝, 선수당 한 차례 5번, 두 번째 도착 즉시 종료,
  경주 차례 상한. 시간 초과는 안전한 기본값(능력 안 씀), 나간 사람 선수는 자동으로 끝까지.
- 컴퓨터: 평가값 뽑기, 칸 수 기대 이득으로 능력 판단, 레벨별 실수.
- 화면: 뱀 모양 경주로 SVG(PC 11칸·휴대폰 8칸 줄), 말 이동 애니메이션, 능력 버튼, 경주 기록, 결과 표,
  도움말·30초 요약. 판이 화면보다 길면 위에서 시작(가운데 정렬이면 위가 잘려 고르기 카드를 못 누름).
- 등록(GAMES, CATALOG, BOT_GAMES, BOT_STRATEGIES, 화면 레지스트리, 아이콘·판 탭), 문서 docs/games/magical-athlete.md.
- 테스트: 규칙·능력·순서 42개(문서 예시 포함), 컴퓨터 10개, 도움말 2개, 방 통합 2개(컴퓨터 1·3명과 끝까지),
  E2E(PC 방장 + 휴대폰, 실제 뽑기·고르기·굴리기·능력으로 네 경주 끝까지).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 03:45:09 +09:00
parent 65c56d3ae7
commit 71381087cc
23 changed files with 4019 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ import { assertCleanText, eachView, seatIds, usersOf } from './help-kit.test-uti
const IDS = Object.keys(GAME_UI);
test('모든 게임에 도움말이 있어요', () => {
expect(IDS).toHaveLength(32);
expect(IDS).toHaveLength(33);
for (const id of IDS) {
const src = readFileSync(join(import.meta.dir, id, 'index.tsx'), 'utf8');
expect(src, id).toMatch(/\bquickStart,/);

View File

@@ -0,0 +1,38 @@
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 ID = 'magical-athlete';
const users = usersOf(['A', 'B', 'C', 'D']);
const view = (s: unknown, who: string | null) => GAMES[ID]!.view(s, who) as any;
const picker = (s: any): string => s.seats[s.draft.order[s.draft.at]];
test('야단법석 달리기: 뽑기 차례 / 기다리기 / 관전', () => {
const { state } = setupGame(ID, 4);
const p = picker(state);
const other = state.seats.find((x: string) => x !== p)!;
expect(helpNow(view(state, p), p, users)).toContain('지금 내가 고를 차례예요');
expect(helpNow(view(state, other), other, users)).toContain(`${users[p]!.nickname}님이 고르는 중`);
expect(helpNow(view(state, null), null, users)).toContain('선수 뽑기 1/2바퀴');
});
test('야단법석 달리기: 출전 선수 고르기와 경주', () => {
let { state } = setupGame(ID, 4);
while (state.phase === 'draft') {
const p = picker(state);
state = applyAction(ID, state, p, { type: 'DRAFT', racer: state.draft.line[0] });
}
expect(helpNow(view(state, 'A'), 'A', users)).toContain('[내보내기]');
state = applyAction(ID, state, 'A', { type: 'SELECT', racers: [state.teams.A[0]] });
expect(helpNow(view(state, 'A'), 'A', users)).toContain('다른 사람이 고를 때까지 기다려요');
for (const p of ['B', 'C', 'D']) state = applyAction(ID, state, p, { type: 'SELECT', racers: [state.teams[p][0]] });
expect(state.phase).toBe('race');
const v = view(state, null);
const owner = v.prompt.owner;
const mine = helpNow(view(state, owner), owner, users);
expect(mine).toContain('1번째 경주예요');
expect(mine).toMatch(/차례예요|골라요/);
const other = state.seats.find((x: string) => x !== owner)!;
expect(helpNow(view(state, other), other, users)).toContain('기다려 주세요');
});

View File

@@ -0,0 +1,64 @@
/** 야단법석 달리기 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view. */
import type { MagicalAthleteView } from '@bg/games/magical-athlete';
import { RACERS } from '@bg/games/magical-athlete/racers';
import type { PublicUser } from '@bg/shared/lite';
export function helpNow(v: MagicalAthleteView, me: string | null, players: Record<string, PublicUser>): string {
const name = (p: string) => `${players[p]?.nickname ?? '다른 사람'}님`;
const seated = !!me && v.seats.includes(me);
const score = seated ? `지금까지 내 점수는 ${v.scores[me!]!.total}점이에요.` : '';
const goal = '경주마다 1등과 2등만 점수를 받아요. 네 경주가 끝나면 점수가 가장 많은 사람이 이겨요.';
if (v.phase === 'finished') return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n결과 창에서 [한 판 더]를 누르면 다시 할 수 있어요.';
if (seated && v.left.includes(me!)) return '나는 그만해서 구경만 할 수 있어요. 내 선수는 자동으로 달려요.';
if (v.phase === 'draft') {
const d = v.draft!;
const head = `선수 뽑기 ${d.round}/${d.rounds}바퀴예요. 펼쳐진 선수 중에서 한 명씩 차례로 뽑아요.`;
if (seated && d.picker === me) {
const best = [...d.line].sort((a, b) => RACERS[b].rating - RACERS[a].rating)[0];
return [
`${head}\n지금 내가 고를 차례예요. 카드를 누르면 바로 내 선수가 돼요.`,
best ? `처음이라면 능력이 쉬운 ${RACERS[best].name}(${RACERS[best].text}) 같은 선수가 무난해요.` : '',
`각자 ${v.perRace * 4}명을 모아 경주마다 ${v.perRace}명씩 내보내요.`,
]
.filter(Boolean)
.join('\n');
}
return `${head}\n지금은 ${name(d.picker)}이 고르는 중이에요. ${seated ? '내 차례가 오면 카드를 눌러 뽑아요.' : ''}\n${goal}`.trim();
}
if (v.phase === 'select') {
const m = v.medals[v.raceNo - 1]!;
const head = `${v.raceNo}번째 경주(1등 ${m.gold}점, 2등 ${m.silver}점)에 내보낼 선수를 모두 몰래 고르는 중이에요.`;
if (!seated) return `${head}\n${goal}`;
if (v.mySelection) return `${head}\n나는 ${v.mySelection.racers.map((id) => RACERS[id].name).join(', ')}을(를) 골랐어요. 다른 사람이 고를 때까지 기다려요.\n${score}`;
return `${head}\n아직 안 달린 내 선수 ${v.perRace}명을 누른 뒤 [내보내기]를 눌러요. 한 번 달린 선수는 다시 못 나가요.\n${score}`;
}
const r = v.race!;
const pr = v.prompt;
const lines = [`${r.no}번째 경주예요(${r.side === 'wild' ? '거친 판: 화살표·돌·별 칸이 있어요' : '순한 판'}). 30칸을 먼저 달려 결승선을 넘으면 돼요.`];
if (!pr) return lines.join('\n');
const racer = pr.racer ? `${RACERS[pr.racer].name}` : '';
if (pr.owner !== me) {
lines.push(`지금은 ${name(pr.owner)}의 ${racer ? `${racer} ` : ''}차례예요. 기다려 주세요.`);
if (seated) {
const mine = r.racers.filter((x) => x.owner === me);
if (mine.length) lines.push(`내 선수: ${mine.map((x) => `${RACERS[x.id].name} ${x.status === 'done' ? `${x.place}등 도착` : x.status === 'out' ? '탈락' : `${x.pos}칸`}`).join(', ')}.`);
}
} else if (pr.step === 'go') {
lines.push('내 선수 둘 중 어느 선수가 먼저 움직일지 골라요. 둘 다 이번 차례에 움직여요.');
} else if (pr.step === 'roll') {
lines.push(`내 ${racer} 차례예요. [🎲 주사위 굴리기]를 누르면 나온 만큼 앞으로 가요.`);
if (pr.racer === 'legs') lines.push('롱다리는 굴리지 않고 5칸을 갈 수도 있어요.');
} else if (pr.step === 'start') {
lines.push(`내 ${racer} 차례예요. ${RACERS[pr.racer!].text} 쓰고 싶지 않으면 [능력 안 쓰고 주사위 굴리기]를 눌러요.`);
} else if (pr.step === 'reroll') {
lines.push(`주사위 ${r.roll?.value}이(가) 나왔어요. 마술사는 마음에 안 들면 다시 굴릴 수 있어요(두 번까지).`);
} else {
lines.push(`주사위 ${r.roll?.value}이(가) 나왔어요. ${RACERS[pr.racer!].text}`);
}
if (score) lines.push(score);
return lines.join('\n');
}

View File

@@ -0,0 +1,825 @@
/** 야단법석 달리기 화면 (docs/games/magical-athlete.md §9). Points are play points of this room only. */
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import type { LogLine, MaPrompt, MaRacerView, MagicalAthleteOptions, MagicalAthleteView, RaceResult, SpaceEffect } from '@bg/games/magical-athlete';
import { RACERS, type RacerId } from '@bg/games/magical-athlete/racers';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, ConfirmSheet } 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 ROLL_MS = 600;
const COLORS = ['#e5484d', '#2f7cf6', '#1f9d55', '#f2a10c', '#8e5cf0', '#0ea5a4'];
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' };
const reducedMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(prefers-reduced-motion: reduce)').matches;
const seatColor = (v: MagicalAthleteView, p: string) => COLORS[v.seats.indexOf(p)] ?? '#888';
const rname = (id: RacerId) => `${RACERS[id].emoji} ${RACERS[id].name}`;
const who = (players: Record<string, PublicUser>, me: string | null, p: string) => (p === me ? '나' : nick(players, p));
const CSS = `
.ma-wrap { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 10px; }
/* Taller than the play area on PC: start at the top (centring would cut the top off where nobody can scroll to). */
.game-main:has(> .ma-wrap) { justify-content: flex-start; }
.ma-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; }
.ma-side-tag { border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: .85rem; }
.ma-side-tag.mild { background: var(--success-soft); color: var(--success); }
.ma-side-tag.wild { background: var(--warning-soft); color: var(--warning); }
.ma-track { padding: 8px; overflow: hidden; }
.ma-track svg { display: block; width: 100%; height: auto; }
.ma-cell { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.ma-cell.start { fill: var(--primary-soft); }
.ma-cell.finish { fill: #fde68a; stroke: #b45309; }
.ma-cell.cur { stroke: var(--focus); stroke-width: 3; }
.ma-num { fill: var(--text-sub); font-size: 11px; font-weight: 700; }
.ma-num.fin { fill: #92400e; }
.ma-fx { font-size: 15px; }
.ma-fxt { font-size: 11px; font-weight: 900; }
.ma-tok { transition: transform .45s ease; }
.ma-tok circle { stroke: #1f2937; stroke-width: 2; }
.ma-tok.cur circle { stroke: var(--focus); stroke-width: 4; }
.ma-tok.trip { opacity: .55; }
.ma-emoji { font-size: 16px; }
.ma-lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.ma-panel { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ma-panel h3 { margin: 0; font-size: 1rem; }
.ma-opts { display: flex; flex-direction: column; gap: 8px; }
.ma-opts .btn { min-height: 52px; font-size: 1.02rem; }
.ma-die { width: 54px; height: 54px; border-radius: 12px; background: #fffdf8; border: 3px solid #1f2937; display: inline-block; flex: none; }
.ma-die svg { width: 100%; height: 100%; display: block; }
@keyframes ma-tumble { 0% { transform: translateY(-14px) rotate(-50deg); } 60% { transform: translateY(3px) rotate(200deg); } 100% { transform: none; } }
.ma-die.rolling { animation: ma-tumble ${ROLL_MS}ms ease-out both; }
.ma-rollrow { display: flex; align-items: center; gap: 12px; }
.ma-news { display: flex; flex-direction: column; gap: 4px; }
.ma-news div { border-radius: 8px; padding: 6px 10px; font-size: .92rem; background: var(--surface-2); }
.ma-news .power { background: var(--primary-soft); font-weight: 700; }
.ma-news .space { background: var(--warning-soft); }
.ma-news .finish { background: var(--success-soft); font-weight: 800; }
@keyframes ma-pop { 0% { transform: scale(.94); opacity: 0; } 100% { transform: none; opacity: 1; } }
.ma-news .fresh { animation: ma-pop .35s ease-out both; }
.ma-log { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; font-size: .85rem; margin: 0; padding: 0; list-style: none; }
.ma-log li { padding: 2px 4px; border-bottom: 1px solid var(--border); }
.ma-log li.power { font-weight: 700; }
.ma-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; margin: 0; padding: 0; list-style: none; }
.ma-legend li { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); }
.ma-legend li.cur { border-color: var(--focus); }
.ma-legend li.gone { opacity: .6; }
.ma-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(0,0,0,.45); flex: none; margin-top: 3px; display: inline-block; }
.ma-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.ma-card { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: var(--radius); border: 3px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-align: left; min-height: 104px; }
button.ma-card { cursor: pointer; }
button.ma-card:hover:not(:disabled) { border-color: var(--primary); }
.ma-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ma-card[aria-pressed='true'] { border-color: var(--primary); background: var(--primary-soft); }
.ma-card:disabled { cursor: default; }
.ma-card.used { opacity: .45; }
.ma-card b { font-size: 1.05rem; }
.ma-card .em { font-size: 1.6rem; line-height: 1; }
.ma-card small { color: var(--text-sub); line-height: 1.35; }
.ma-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ma-chip { display: inline-flex; align-items: center; gap: 2px; border-radius: 999px; padding: 1px 8px; font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.ma-chip.used { opacity: .45; text-decoration: line-through; }
.ma-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; }
.ma-table th, .ma-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); text-align: center; }
.ma-table td.l { text-align: left; }
@media (max-width: 899px) {
.ma-lower { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 599px) {
.ma-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ma-card { padding: 8px; min-height: 96px; }
.ma-card small { font-size: .78rem; }
.ma-legend { grid-template-columns: minmax(0, 1fr); }
.ma-panel.act { position: sticky; bottom: 0; z-index: 4; box-shadow: 0 -4px 14px rgba(0,0,0,.12); }
}
@media (prefers-reduced-motion: reduce) {
.ma-tok { transition: none; }
.ma-die.rolling, .ma-news .fresh { animation: none; }
}
`;
// prettier-ignore
const PIPS: Record<number, [number, number][]> = {
1: [[50, 50]], 2: [[28, 28], [72, 72]], 3: [[26, 26], [50, 50], [74, 74]],
4: [[28, 28], [72, 28], [28, 72], [72, 72]], 5: [[26, 26], [74, 26], [50, 50], [26, 74], [74, 74]],
6: [[28, 24], [72, 24], [28, 50], [72, 50], [28, 76], [72, 76]],
};
function Die({ value, rolling }: { value: number; rolling: boolean }) {
return (
<span className={`ma-die${rolling ? ' rolling' : ''}`} aria-hidden>
<svg viewBox="0 0 100 100">
{PIPS[value]!.map(([x, y], i) => (
<circle key={i} cx={x} cy={y} r={value === 1 ? 14 : 10} fill="#1f2937" />
))}
</svg>
</span>
);
}
function useNarrow(): boolean {
const q = '(max-width: 599px)';
const [narrow, setNarrow] = useState(() => typeof matchMedia !== 'undefined' && matchMedia(q).matches);
useEffect(() => {
if (typeof matchMedia === 'undefined') return;
const m = matchMedia(q);
const on = () => setNarrow(m.matches);
m.addEventListener('change', on);
return () => m.removeEventListener('change', on);
}, []);
return narrow;
}
// ---------------------------------------------------------------- track
const CELL = 60;
function fxText(e: SpaceEffect): string {
if (e.kind === 'arrow') return e.by > 0 ? `앞으로 ${e.by}칸 화살표` : `뒤로 ${-e.by}칸 화살표`;
return e.kind === 'rock' ? '돌(넘어짐)' : '별(1점)';
}
function Track({ v, me, players }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser> }) {
const r = v.race!;
const narrow = useNarrow();
const cols = narrow ? 8 : 11;
const cells = v.finish + 1; // 0..29 + finish
const rows = Math.ceil(cells / cols);
const at = (i: number) => {
const row = Math.floor(i / cols);
const k = i % cols;
const col = row % 2 === 0 ? k : cols - 1 - k;
return { x: col * CELL, y: row * CELL };
};
const fx = new Map(v.spaces[r.side].map((s) => [s.pos, s.effect]));
const onTrack = r.racers.filter((x) => x.status !== 'out');
const groups = new Map<number, MaRacerView[]>();
for (const x of onTrack) groups.set(x.pos, [...(groups.get(x.pos) ?? []), x]);
const curPos = r.cur ? r.racers.find((x) => x.id === r.cur)?.pos : undefined;
const label = `${r.no}번째 경주 ${r.side === 'wild' ? '거친 판' : '순한 판'}. ${r.racers
.map((x) => `${RACERS[x.id].name}(${who(players, me, x.owner)}) ${x.status === 'done' ? `${x.place}등 도착` : x.status === 'out' ? '탈락' : `${x.pos}칸${x.tripped ? ' 넘어짐' : ''}`}`)
.join(', ')}`;
return (
<section className="card ma-track" aria-label="경주로">
<svg viewBox={`-4 -4 ${cols * CELL + 8} ${rows * CELL + 8}`} role="img" aria-label={label}>
{Array.from({ length: cells }, (_, i) => {
const { x, y } = at(i);
const e = fx.get(i);
const cls = `ma-cell${i === 0 ? ' start' : ''}${i === v.finish ? ' finish' : ''}${curPos === i && i !== v.finish ? ' cur' : ''}`;
return (
<g key={i} transform={`translate(${x} ${y})`}>
<rect className={cls} x={2} y={2} width={CELL - 4} height={CELL - 4} rx={10} />
<text className={`ma-num${i === v.finish ? ' fin' : ''}`} x={7} y={15}>
{i === 0 ? '출발' : i === v.finish ? '결승' : i}
</text>
{i === v.finish && (
<text x={CELL / 2} y={CELL / 2 + 12} textAnchor="middle" fontSize={22}>
🏁
</text>
)}
{e && (
<g aria-hidden>
{e.kind === 'arrow' ? (
<text className="ma-fxt" x={CELL - 6} y={15} textAnchor="end" fill={e.by > 0 ? 'var(--success)' : 'var(--danger)'}>
{e.by > 0 ? `▶+${e.by}` : `◀${e.by}`}
</text>
) : (
<text className="ma-fx" x={CELL - 7} y={18} textAnchor="end">
{e.kind === 'rock' ? '🪨' : '⭐'}
</text>
)}
</g>
)}
</g>
);
})}
{onTrack.map((x) => {
const group = groups.get(x.pos)!;
const k = group.indexOf(x);
const n = group.length;
const per = n <= 4 ? 2 : 3;
const size = n === 2 ? 12 : n <= 4 ? 11 : 9;
const { x: cx, y: cy } = at(Math.min(x.pos, v.finish));
const ox = cx + (n === 1 ? CELL / 2 : 14 + (k % per) * ((CELL - 28) / Math.max(1, per - 1)));
// Below the space number (top-left), so a crowded space never hides it.
const oy = cy + (n === 1 ? CELL / 2 + 4 : n === 2 ? 34 : 30 + Math.floor(k / per) * (size * 2 - 6));
const isCur = r.cur === x.id;
return (
<g key={x.id} className={`ma-tok${isCur ? ' cur' : ''}${x.tripped ? ' trip' : ''}`} style={{ transform: `translate(${ox}px, ${oy}px)` }}>
<circle r={n === 1 ? 17 : size} fill={seatColor(v, x.owner)} />
<text className="ma-emoji" textAnchor="middle" dy={n === 1 ? 6 : 4} fontSize={n === 1 ? 17 : size + 2} transform={x.tripped ? 'rotate(90)' : undefined}>
{RACERS[x.id].emoji}
</text>
{x.place && (
<text textAnchor="middle" x={n === 1 ? 14 : size} y={n === 1 ? 19 : size + 2} fontSize={n === 1 ? 13 : 10}>
{x.place === 1 ? '🥇' : '🥈'}
</text>
)}
</g>
);
})}
</svg>
</section>
);
}
function Legend({ v, me, players }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser> }) {
const r = v.race!;
return (
<section className="card ma-panel" aria-label="이번 경주 선수">
<h3>이번 경주 선수</h3>
<ul className="ma-legend">
{r.racers.map((x) => (
<li key={x.id} className={`${r.cur === x.id ? 'cur' : ''}${x.status !== 'run' ? ' gone' : ''}`}>
<span className="ma-dot" style={{ background: seatColor(v, x.owner) }} aria-hidden />
<div style={{ minWidth: 0 }}>
<div>
<strong>{rname(x.id)}</strong> <span className="small muted">· {who(players, me, x.owner)}</span>
</div>
<div className="small">
{x.status === 'done' ? `🏁 ${x.place}등 도착` : x.status === 'out' ? '탈락' : `${x.pos === 0 ? '출발점' : `${x.pos}칸`}${x.tripped ? ' · 넘어짐(다음 차례 쉼)' : ''}`}
</div>
<div className="small muted">{RACERS[x.id].text}</div>
</div>
</li>
))}
</ul>
</section>
);
}
// ---------------------------------------------------------------- panels
function actionFor(pr: MaPrompt, key: string): unknown {
if (pr.step === 'go') return { type: 'GO', racer: key };
if (pr.step === 'roll' && key === 'roll') return { type: 'ROLL' };
return { type: 'CHOOSE', key };
}
const STEP_TITLE: Record<MaPrompt['step'], string> = {
go: '어느 선수가 먼저 갈까요?',
start: '차례 시작: 능력을 쓸까요?',
roll: '주사위를 굴려요',
reroll: '다시 굴릴까요?',
boost: '능력을 쓸까요?',
};
function RacePanel({ v, me, players, act, pending, rolling }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser>; act: (a: unknown) => void; pending: boolean; rolling: boolean }) {
const r = v.race!;
const pr = v.prompt;
const mine = !!pr && pr.owner === me;
const curName = r.cur ? rname(r.cur) : '';
return (
<section className="card ma-panel act" aria-label="내 차례 할 일">
{pr ? (
<>
<div className="ma-rollrow">
{r.roll?.value ? <Die value={r.roll.value} rolling={rolling} /> : <span className="ma-die" aria-hidden style={{ opacity: 0.35 }} />}
<div style={{ minWidth: 0 }}>
<strong>{pr.owner === me ? '내 차례' : `${nick(players, pr.owner)}님 차례`}</strong>
<div className="small">{curName ? `${curName}${r.roll?.value ? ` · 주사위 ${r.roll.value}` : ''}` : '먼저 갈 선수 고르기'}</div>
</div>
</div>
{mine ? (
<>
<h3>{STEP_TITLE[pr.step]}</h3>
<div className="ma-opts" role="group" aria-label={STEP_TITLE[pr.step]}>
{pr.options.map((o, i) => (
<button key={o.key} type="button" className={`btn ${i === 0 ? 'btn-primary' : 'btn-secondary'} btn-block`} disabled={pending || rolling} onClick={() => act(actionFor(pr, o.key))}>
{o.label}
</button>
))}
</div>
<p className="small muted" style={{ margin: 0 }}>
시간이 지나면 {pr.timeoutText}.
</p>
</>
) : (
<p className="muted small" style={{ margin: 0 }}>
{nick(players, pr.owner)}님이 {pr.step === 'roll' ? '주사위를 굴릴 차례예요' : pr.step === 'go' ? '먼저 갈 선수를 고르는 중이에요' : '능력을 쓸지 고르는 중이에요'}.
</p>
)}
</>
) : (
<p className="muted" style={{ margin: 0 }}>
경주가 끝났어요.
</p>
)}
</section>
);
}
function Draft({ v, me, players, act, pending }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser>; act: (a: unknown) => void; pending: boolean }) {
const d = v.draft!;
const mine = d.picker === me;
return (
<section className="card ma-panel" aria-label="선수 뽑기">
<h3>
선수 뽑기 {d.round}/{d.rounds}바퀴 · {mine ? '내가 고를 차례예요' : `${nick(players, d.picker)}님이 고르는 중`}
</h3>
<p className="small muted" style={{ margin: 0 }}>
순서: {[d.picker, ...d.next].map((p) => who(players, me, p)).join(' → ')} (남은 선수 더미 {v.deckCount}명)
</p>
<div className="ma-cards" role="group" aria-label="펼쳐진 선수">
{d.line.map((id) => (
<button key={id} type="button" className="ma-card" disabled={!mine || pending} aria-label={`${RACERS[id].name}: ${RACERS[id].text}${mine ? ' 누르면 뽑아요' : ''}`} onClick={() => act({ type: 'DRAFT', racer: id })}>
<span className="em" aria-hidden>
{RACERS[id].emoji}
</span>
<b>{RACERS[id].name}</b>
<small>{RACERS[id].text}</small>
</button>
))}
</div>
</section>
);
}
function Select({ v, me, players, act, pending }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser>; act: (a: unknown) => void; pending: boolean }) {
const [sel, setSel] = useState<RacerId[]>([]);
useEffect(() => setSel([]), [v.raceNo]);
const seated = !!me && v.seats.includes(me) && !v.left.includes(me);
const team = seated ? v.teams[me!]! : [];
const used = seated ? v.used[me!]! : [];
const done = v.mySelection;
const toggle = (id: RacerId) =>
setSel((cur) => (cur.includes(id) ? cur.filter((x) => x !== id) : v.perRace === 1 ? [id] : [...cur, id].slice(-v.perRace)));
const side = v.options.track === 'mild' ? '순한 판' : v.options.track === 'wild' ? '거친 판' : v.raceNo % 2 ? '순한 판' : '거친 판';
const m = v.medals[v.raceNo - 1]!;
return (
<section className="card ma-panel" aria-label="출전 선수 고르기">
<h3>
{v.raceNo}번째 경주({side}, 1등 {m.gold}점 · 2등 {m.silver}점)에 내보낼 선수 {v.perRace}명
</h3>
<p className="small muted" style={{ margin: 0 }}>
다른 사람에게는 고른 선수가 경주가 시작될 때까지 보이지 않아요. 고른 사람: {v.seats.filter((p) => v.picked[p]).map((p) => who(players, me, p)).join(', ') || '아직 없음'}
</p>
{seated && !done && (
<>
<div className="ma-cards" role="group" aria-label="내 선수">
{team.map((id) => {
const u = used.includes(id);
return (
<button key={id} type="button" className={`ma-card${u ? ' used' : ''}`} disabled={u || pending} aria-pressed={sel.includes(id)} aria-label={`${RACERS[id].name}${u ? '(이미 달렸어요)' : ''}: ${RACERS[id].text}`} onClick={() => toggle(id)}>
<span className="em" aria-hidden>
{RACERS[id].emoji}
</span>
<b>{RACERS[id].name}</b>
<small>{u ? '이미 달렸어요' : RACERS[id].text}</small>
</button>
);
})}
</div>
<button className="btn btn-primary btn-block" disabled={pending || sel.length !== v.perRace} onClick={() => act({ type: 'SELECT', racers: sel })}>
{sel.length === v.perRace ? `${sel.map(rname).join(', ')} 내보내기` : `선수 ${v.perRace}명을 골라 주세요`}
</button>
</>
)}
{done && <p style={{ margin: 0 }}>내가 고른 선수: {done.racers.map(rname).join(', ')}. 다른 사람을 기다려요.</p>}
</section>
);
}
function Results({ v, me, players }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser> }) {
if (!v.results.length) return null;
const cell = (id: RacerId | null, rr: RaceResult) => {
if (!id) return '—';
const o = rr.field.find((x) => x.id === id)!.owner;
return (
<>
<span className="ma-dot" style={{ background: seatColor(v, o), marginRight: 4, verticalAlign: '-2px' }} aria-hidden />
{rname(id)} <span className="muted small">({who(players, me, o)})</span>
</>
);
};
return (
<section className="card ma-panel" aria-label="경주 결과">
<h3>경주 결과</h3>
<table className="ma-table">
<thead>
<tr>
<th scope="col">경주</th>
<th scope="col">🥇 1등</th>
<th scope="col">🥈 2등</th>
</tr>
</thead>
<tbody>
{v.results.map((rr) => (
<tr key={rr.no}>
<td>
{rr.no}
{rr.capped && <div className="small muted">시간 다 됨</div>}
</td>
<td className="l">{cell(rr.gold, rr)}</td>
<td className="l">{cell(rr.silver, rr)}</td>
</tr>
))}
</tbody>
</table>
</section>
);
}
function FinalTable({ v, me, players }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser> }) {
const r = v.result!;
return (
<section className="card ma-panel" aria-label="최종 결과">
<h3>최종 결과</h3>
<table className="ma-table">
<thead>
<tr>
<th scope="col">순위</th>
<th scope="col">이름</th>
<th scope="col">🥇</th>
<th scope="col">🥈</th>
<th scope="col">⭐ 보너스</th>
<th scope="col">합계</th>
</tr>
</thead>
<tbody>
{r.ranking.map((row) => (
<tr key={row.player}>
<td>{row.rank}등</td>
<td className="l">
<span className="ma-dot" style={{ background: seatColor(v, row.player), marginRight: 4, verticalAlign: '-2px' }} aria-hidden />
{who(players, me, row.player)}
{row.left && <span className="muted small"> (나감)</span>}
</td>
<td>{row.gold}</td>
<td>{row.silver}</td>
<td>{row.bonus}</td>
<td>
<strong>{row.total}점</strong>
</td>
</tr>
))}
</tbody>
</table>
</section>
);
}
const ICON: Record<LogLine['kind'], string> = { turn: '▶', roll: '🎲', move: '👟', power: '✨', space: '🧭', finish: '🏁', info: 'ℹ️' };
function News({ lines, fresh }: { lines: LogLine[]; fresh: number }) {
if (!lines.length) return null;
return (
<div className="ma-news" aria-hidden>
{lines.map((l) => (
<div key={l.n} className={`${l.kind}${l.n > fresh ? ' fresh' : ''}`}>
{ICON[l.kind]} {l.text}
</div>
))}
</div>
);
}
// ---------------------------------------------------------------- board
function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthleteView>) {
const [rolling, setRolling] = useState(false);
const [announce, setAnnounce] = useState('');
const prevRoll = useRef(v.rollSeq);
const prevLog = useRef<number>(v.race?.log.at(-1)?.n ?? 0);
const prevRace = useRef<number>(v.race?.no ?? 0);
const [fresh, setFresh] = useState(prevLog.current);
const prevTurn = useRef(v.turnSeq);
useLayoutEffect(() => {
if (v.rollSeq <= prevRoll.current) {
prevRoll.current = v.rollSeq;
return;
}
prevRoll.current = v.rollSeq;
if (reducedMotion()) return sounds.stone();
setRolling(true);
const t = setTimeout(() => {
setRolling(false);
sounds.stone();
}, ROLL_MS);
return () => clearTimeout(t);
}, [v.rollSeq]);
// New log lines → screen-reader announcement and the "방금 일어난 일" highlight.
useEffect(() => {
const r = v.race;
if (!r) return;
if (r.no !== prevRace.current) {
prevRace.current = r.no;
prevLog.current = 0;
}
const last = r.log.at(-1)?.n ?? 0;
if (last <= prevLog.current) return;
const added = r.log.filter((l) => l.n > prevLog.current && l.kind !== 'turn');
setFresh(prevLog.current);
prevLog.current = last;
if (added.length) setAnnounce(added.slice(-4).map((l) => l.text).join(' '));
if (added.some((l) => l.kind === 'power')) haptic(30);
if (added.some((l) => l.kind === 'finish')) sounds.ding();
}, [v.race?.log.at(-1)?.n, v.race?.no]); // eslint-disable-line react-hooks/exhaustive-deps
useEffect(() => {
if (v.turnSeq === prevTurn.current) return;
prevTurn.current = v.turnSeq;
if (isMyTurn(v, me)) {
haptic(40);
if (document.visibilityState === 'hidden') sounds.myTurn();
}
}, [v.turnSeq]); // eslint-disable-line react-hooks/exhaustive-deps
const r = v.race;
// Lines of the latest step (since the last turn line), newest last.
const recent = (() => {
if (!r) return [];
const lastTurn = [...r.log].reverse().find((l) => l.kind === 'turn');
const from = lastTurn ? r.log.indexOf(lastTurn) : 0;
const prevTurnIdx = lastTurn ? [...r.log.slice(0, from)].reverse().find((l) => l.kind === 'turn') : undefined;
// Show the previous racer's turn too while the current one hasn't done anything yet.
const start = from === r.log.length - 1 && prevTurnIdx ? r.log.indexOf(prevTurnIdx) : from;
return r.log.slice(start).filter((l) => l.kind !== 'turn').slice(-6);
})();
return (
<div className="ma-wrap">
<style>{CSS}</style>
<div className="card ma-head">
<strong>{v.phase === 'finished' ? '게임 끝' : v.phase === 'draft' ? '선수 뽑기' : `${v.raceNo} / ${v.races} 경주`}</strong>
{r && v.phase === 'race' && <span className={`ma-side-tag ${r.side}`}>{r.side === 'wild' ? '거친 판' : '순한 판'}</span>}
<span className="small muted">
{v.perRace === 2 ? '경주마다 선수 둘씩 · ' : ''}1등 {v.medals[Math.min(v.raceNo, v.races) - 1]!.gold}점 · 2등 {v.medals[Math.min(v.raceNo, v.races) - 1]!.silver}점
</span>
</div>
{v.result && <FinalTable v={v} me={me} players={players} />}
{v.phase === 'draft' && v.draft && <Draft v={v} me={me} players={players} act={act} pending={pending} />}
{v.phase === 'select' && <Select v={v} me={me} players={players} act={act} pending={pending} />}
{r && (
<>
{v.phase !== 'race' && <p className="small muted" style={{ margin: 0 }}>{r.no}번째 경주가 끝났을 때 모습이에요.</p>}
<Track v={v} me={me} players={players} />
<div className="ma-lower">
{v.phase === 'race' && (
<div className="stack" style={{ gap: 10 }}>
<RacePanel v={v} me={me} players={players} act={act} pending={pending} rolling={rolling} />
<section className="card ma-panel" aria-label="방금 일어난 일">
<h3>방금 일어난 일</h3>
{recent.length ? <News lines={recent} fresh={fresh} /> : <p className="small muted" style={{ margin: 0 }}>아직 없어요.</p>}
</section>
</div>
)}
<section className="card ma-panel" aria-label="경주 기록">
<h3>경주 기록</h3>
<ul className="ma-log">
{[...r.log].reverse().map((l) => (
<li key={l.n} className={l.kind}>
{ICON[l.kind]} {l.text}
</li>
))}
</ul>
</section>
</div>
<Legend v={v} me={me} players={players} />
</>
)}
<Results v={v} me={me} players={players} />
<p className="sr-only" aria-live="polite">
{announce}
</p>
</div>
);
}
// ---------------------------------------------------------------- side panel
function Side({ view: v, me, players, act, deadline, active }: BoardProps<MagicalAthleteView>) {
const [ask, setAsk] = useState(false);
const total = v.options.turnSeconds ? v.options.turnSeconds * 1000 : 30_000;
const playing = v.phase !== 'finished';
return (
<>
<section className="card stack" style={{ padding: 12, gap: 8 }} aria-label="참가자">
{v.seats.map((p) => {
const sc = v.scores[p]!;
const on = active.includes(p);
return (
<div key={p} style={{ padding: '4px 6px', borderRadius: 10, border: `3px solid ${on ? 'var(--focus)' : 'transparent'}` }}>
<div className="row" style={{ gap: 8, flexWrap: 'nowrap' }}>
<span className="ma-dot" style={{ background: seatColor(v, p) }} aria-hidden />
<Avatar user={userOf(players, p)} size={28} />
<div style={{ flex: 1, minWidth: 0 }}>
<div style={{ fontWeight: 700, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>
{nick(players, p)}
{p === me && <span className="muted small"> (나)</span>}
</div>
<div className="small muted">
{v.left.includes(p) ? '나감(자동)' : v.away.includes(p) ? '자리 비움' : `🥇${sc.gold} 🥈${sc.silver}${sc.bonus ? ` ⭐${sc.bonus}` : ''}`}
</div>
</div>
<strong style={{ fontSize: '1.15rem', fontVariantNumeric: 'tabular-nums' }} aria-label={`${nick(players, p)} ${sc.total}점`}>
{sc.total}점
</strong>
{on && playing && <TurnTimer deadline={deadline} totalMs={total} mine={p === me} size={36} />}
</div>
<div className="ma-chips" style={{ marginTop: 4 }} aria-label={`${nick(players, p)}의 선수`}>
{v.teams[p]!.map((id) => (
<span key={id} className={`ma-chip${v.used[p]!.includes(id) && !(v.race && v.phase === 'race' && v.race.racers.some((x) => x.id === id)) ? ' used' : ''}`} title={RACERS[id].text}>
{rname(id)}
</span>
))}
</div>
</div>
);
})}
</section>
{playing && me && v.seats.includes(me) && !v.left.includes(me) && (
<button className="btn btn-danger btn-sm" onClick={() => setAsk(true)}>
🏳 그만하고 나가기
</button>
)}
{ask && (
<ConfirmSheet
title="그만할까요?"
body="내 선수는 남은 경주를 자동으로 달리고, 나는 맨 뒤 순위가 돼요."
confirm="그만하기"
danger
onConfirm={() => act({ type: 'LEAVE' })}
onClose={() => setAsk(false)}
/>
)}
</>
);
}
// ---------------------------------------------------------------- status
function isMyTurn(v: MagicalAthleteView, me: string | null): boolean {
if (!me || v.phase === 'finished' || v.left.includes(me)) return false;
if (v.phase === 'draft') return v.draft?.picker === me;
if (v.phase === 'select') return v.seats.includes(me) && !v.picked[me];
return v.prompt?.owner === me;
}
function statusText(v: MagicalAthleteView, me: string | null, players: Record<string, PublicUser>): string {
if (v.phase === 'finished') return v.result?.summary ?? '게임이 끝났어요';
if (me && v.left.includes(me)) return '나갔어요. 구경하는 중이에요';
if (v.phase === 'draft') return isMyTurn(v, me) ? '내 차례예요. 선수를 한 명 뽑아 주세요' : `${nick(players, v.draft!.picker)}님이 선수를 뽑는 중이에요`;
if (v.phase === 'select') return isMyTurn(v, me) ? `내 차례예요. ${v.raceNo}번째 경주에 내보낼 선수를 골라 주세요` : '모두 출전 선수를 고르는 중이에요';
const pr = v.prompt;
if (!pr) return '잠시만 기다려 주세요';
if (pr.owner === me) return pr.step === 'roll' ? `내 차례예요. ${pr.racer ? RACERS[pr.racer].name : ''} 주사위를 굴려 주세요` : '내 차례예요. 어떻게 할지 골라 주세요';
return `${nick(players, pr.owner)}님 차례예요 · ${v.raceNo}/${v.races} 경주`;
}
// ---------------------------------------------------------------- options
function Seg<T extends string | number>({ 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]) => (
<button key={String(k)} type="button" aria-pressed={value === k} onClick={() => onChange(k)}>
{l}
</button>
))}
</div>
);
}
function Field({ label, children }: { label: string; children: React.ReactNode }) {
return (
<div className="stack" style={{ gap: 6 }}>
<strong>{label}</strong>
{children}
</div>
);
}
function Options({ value: o, onChange }: OptionsProps<MagicalAthleteOptions>) {
const set = (patch: Partial<MagicalAthleteOptions>) => onChange({ ...o, ...patch });
return (
<div className="stack" style={{ gap: 16 }}>
<Field label="경주로">
<Seg
label="경주로"
value={o.track}
options={[
['alternate', '순한·거친 번갈아'],
['mild', '모두 순한 판'],
['wild', '모두 거친 판'],
]}
onChange={(track) => set({ track })}
/>
</Field>
<Field label="점수표">
<Seg
label="점수표"
value={o.scoring}
options={[
['flat', '1등 3점·2등 1점'],
['rising', '갈수록 커져요'],
]}
onChange={(scoring) => set({ scoring })}
/>
</Field>
<Field label="2~3명일 때 선수 둘씩">
<Seg
label="2~3명일 때 선수 둘씩"
value={o.twoRacers}
options={[
['auto', '켜기(원작)'],
['off', '끄기'],
]}
onChange={(twoRacers) => set({ twoRacers })}
/>
</Field>
<Field label="고르기·굴리기 제한 시간">
<Seg
label="고르기·굴리기 제한 시간"
value={o.turnSeconds === null ? 'none' : String(o.turnSeconds)}
options={[
['20', '20초'],
['30', '30초'],
['60', '60초'],
['none', '무제한'],
]}
onChange={(k) => set({ turnSeconds: k === 'none' ? null : (Number(k) as 20 | 30 | 60) })}
/>
</Field>
</div>
);
}
function optionsSummary(o: MagicalAthleteOptions): string {
return [
o.track === 'alternate' ? '순한·거친 번갈아' : o.track === 'mild' ? '모두 순한 판' : '모두 거친 판',
o.scoring === 'flat' ? '1등 3점·2등 1점' : '점수 갈수록 커짐',
o.twoRacers === 'auto' ? '2~3명은 선수 둘씩' : '선수 한 명씩',
o.turnSeconds === null ? '시간 제한 없음' : `${o.turnSeconds}초`,
].join(' · ');
}
// ---------------------------------------------------------------- rules
function Rules({ options }: { options?: MagicalAthleteOptions }) {
const rising = options?.scoring === 'rising';
return (
<div className="stack">
<style>{CSS}</style>
<p>
저마다 엉뚱한 능력을 가진 선수를 뽑아 <strong>경주 4번</strong>을 벌여요. 경주마다 <strong>1등은 {rising ? '3·4·5·6점' : '3점'}</strong>,{' '}
<strong>2등은 {rising ? '1·1·2·2점' : '1점'}</strong>을 받고, 네 경주가 끝나면 점수가 가장 많은 사람이 이겨요. 같으면 함께 이겨요.
</p>
<p>
<strong>선수 뽑기</strong>: (사람 수 × 2)명의 선수를 펼치고 뱀 순서(1→끝, 끝→1)로 한 명씩 뽑아요. 시작하는 사람을 바꿔 한 번 더 해서 각자 4명을
가져요. 2~3명이면 이걸 네 번 해서 8명씩 가지고, 경주마다 선수 둘을 내보내요.
</p>
<p>
<strong>출전</strong>: 경주마다 아직 안 달린 내 선수 중에서 몰래 골라요. 모두 고르면 함께 공개돼요. 선수마다 한 번만 달려요.
</p>
<p>
<strong>경주</strong>: 출발점부터 결승선까지 30칸이에요. 내 차례에 주사위를 굴려 그만큼 가요. 선수 능력이 수시로 끼어들어요. 두 번째 선수가 결승선을
넘는 순간 경주가 끝나요. 다음 경주는 가장 뒤처진 선수의 주인부터 시작해요.
</p>
<p>
<strong>거친 판</strong>(2·4번째 경주): <span aria-hidden>▶</span>화살표 칸에 멈추면 그 방향으로 더 가고, 🪨 돌 칸에 멈추면 넘어지고(다음 주사위 이동을
쉬어요), ⭐ 별 칸에 멈추면 1점을 받아요.
</p>
<p>
<strong>능력 순서</strong>: 한 가지 일로 여러 능력이 일어나면 칸 효과 → 지금 차례인 사람의 선수 → 시계 방향 다른 사람 선수 순서로 처리하고, 그 능력이 또
일으킨 일은 그 뒤에 이어서 처리해요. 한 선수의 능력은 한 차례에 다섯 번까지만 일어나요.
</p>
<h3 style={{ margin: '8px 0 0' }}>선수 24명</h3>
<ul className="ma-legend">
{Object.values(RACERS).map((r) => (
<li key={r.id}>
<span style={{ fontSize: '1.4rem' }} aria-hidden>
{r.emoji}
</span>
<div>
<strong>{r.name}</strong>
{r.optional && <span className="small muted"> (고를 수 있음)</span>}
<div className="small">{r.text}</div>
</div>
</li>
))}
</ul>
<p className="muted">시간이 지나면 고를 수 있는 능력은 쓰지 않고, 굴릴 차례면 주사위를 굴려요. 뽑기는 펼쳐진 선수 중 하나를, 출전은 남은 선수를 차례대로 내보내요.</p>
<p className="muted small">점수는 이 방에서만 쓰는 놀이용 점수예요.</p>
</div>
);
}
const ui: GameUI<MagicalAthleteView, MagicalAthleteOptions> = {
Board,
Side,
statusText,
isMyTurn,
Options,
optionsSummary,
Rules,
quickStart,
helpNow,
};
export default ui;

View File

@@ -0,0 +1,114 @@
/** 야단법석 달리기 30초 규칙 요약 (docs/07 §5). */
import type { QuickCard } from '../types';
function Card({ x, y, emoji, name, picked = false }: { x: number; y: number; emoji: string; name: string; picked?: boolean }) {
return (
<g transform={`translate(${x} ${y})`}>
<rect width={56} height={74} rx={8} fill={picked ? '#dbeafe' : '#fff'} stroke={picked ? '#2563eb' : '#6b7280'} strokeWidth={picked ? 3.5 : 2} />
<text x={28} y={36} textAnchor="middle" fontSize={26}>
{emoji}
</text>
<text x={28} y={62} textAnchor="middle" fontSize={11} fontWeight={800} fill="#111827">
{name}
</text>
</g>
);
}
function DraftPic() {
return (
<svg viewBox="0 0 260 150" width={250} height={144} aria-hidden>
<Card x={6} y={10} emoji="🐇" name="토끼" />
<Card x={68} y={10} emoji="🦵" name="롱다리" picked />
<Card x={130} y={10} emoji="🍌" name="바나나" />
<Card x={192} y={10} emoji="🐌" name="꼼지락이" />
<text x={130} y={112} textAnchor="middle" fontSize={15} fontWeight={800} fill="#111827">
1→2→3→3→2→1 뱀 순서로 뽑기
</text>
<text x={130} y={136} textAnchor="middle" fontSize={13} fill="#374151">
각자 4명, 경주마다 몰래 1명 출전
</text>
</svg>
);
}
function RacePic() {
const cells = Array.from({ length: 7 }, (_, i) => i);
return (
<svg viewBox="0 0 260 150" width={250} height={144} aria-hidden>
{cells.map((i) => (
<rect key={i} x={6 + i * 36} y={46} width={32} height={32} rx={6} fill={i === 6 ? '#fde68a' : '#f3f4f6'} stroke="#6b7280" strokeWidth={1.5} />
))}
<text x={240} y={68} textAnchor="middle" fontSize={16}>
🏁
</text>
<circle cx={22} cy={62} r={13} fill="#e5484d" stroke="#1f2937" strokeWidth={2} />
<text x={22} y={68} textAnchor="middle" fontSize={15}>
🐇
</text>
<path d="M30 40 Q 92 0 154 40" fill="none" stroke="#2563eb" strokeWidth={3} strokeDasharray="5 4" />
<circle cx={130} cy={62} r={13} fill="#2f7cf6" stroke="#1f2937" strokeWidth={2} />
<text x={130} y={68} textAnchor="middle" fontSize={15}>
🍌
</text>
<rect x={14} y={92} width={36} height={36} rx={8} fill="#fffdf8" stroke="#1f2937" strokeWidth={3} />
{[[24, 102], [40, 118], [32, 110], [24, 118], [40, 102]].map(([cx, cy], i) => (
<circle key={i} cx={cx} cy={cy} r={3.5} fill="#1f2937" />
))}
<text x={62} y={108} fontSize={13} fontWeight={800} fill="#111827">
5 굴려 앞으로!
</text>
<text x={62} y={128} fontSize={13} fontWeight={800} fill="#b45309">
✨ 바나나를 지나면 넘어져요
</text>
</svg>
);
}
function MedalPic() {
return (
<svg viewBox="0 0 260 150" width={250} height={144} aria-hidden>
<rect x={30} y={70} width={60} height={50} fill="#e5e7eb" stroke="#6b7280" />
<rect x={100} y={40} width={60} height={80} fill="#fde68a" stroke="#b45309" />
<text x={130} y={34} textAnchor="middle" fontSize={26}>
🥇
</text>
<text x={60} y={64} textAnchor="middle" fontSize={24}>
🥈
</text>
<text x={130} y={88} textAnchor="middle" fontSize={18} fontWeight={900} fill="#78350f">
3점
</text>
<text x={60} y={102} textAnchor="middle" fontSize={16} fontWeight={900} fill="#374151">
1점
</text>
<text x={210} y={92} textAnchor="middle" fontSize={15} fontWeight={800} fill="#111827">
× 경주 4번
</text>
<text x={130} y={142} textAnchor="middle" fontSize={13} fill="#374151">
2등이 들어오면 바로 경주 끝
</text>
</svg>
);
}
export const quickStart: QuickCard[] = [
{
pic: <DraftPic />,
alt: '토끼, 롱다리, 바나나, 꼼지락이 선수 카드 중 롱다리를 뽑아요',
title: '능력 선수 뽑기',
text: '펼쳐진 선수를 뱀 순서로 한 명씩 뽑아 각자 4명을 모아요. 경주마다 그중 한 명을 몰래 골라 내보내요.',
},
{
pic: <RacePic />,
alt: '주사위 5가 나와 토끼가 바나나를 지나쳐 앞으로 가요',
title: '굴리고 달리기',
text: '내 차례에 주사위를 굴려 그만큼 가요. 선수마다 능력이 있어서 밀고, 끌고, 넘어뜨리며 순위가 뒤집혀요.',
},
{
pic: <MedalPic />,
alt: '1등 금메달 3점, 2등 은메달 1점, 경주 4번',
title: '1·2등만 점수',
text: '두 번째 선수가 결승선을 넘으면 경주가 끝나요. 1등 3점, 2등 1점. 네 경주 합계가 가장 많으면 이겨요.',
},
];

View File

@@ -34,6 +34,7 @@ export const GAME_UI: Record<string, () => Promise<{ default: GameUI }>> = {
clue: () => import('./clue'),
uno: () => import('./uno'),
liar: () => import('./liar'),
'magical-athlete': () => import('./magical-athlete'),
};
const cache = new Map<string, GameUI>();