야단법석 달리기: 주사위·발걸음·능력·칸 효과·결승 소리, 말이 뛰는 움직임·넘어짐·메달, 뽑기 카드 등장; E2E: 그림 맞히기·클루·라이어·마피아 투표를 시간 무제한으로
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ 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 { haptic, sfx, sounds, tone } from '../../lib/feedback';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -20,6 +20,27 @@ const seatColor = (v: MagicalAthleteView, p: string) => COLORS[v.seats.indexOf(p
|
||||
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));
|
||||
|
||||
/** Game sounds on top of the shared palette (site volume applies); `d` = delay in ms (after the dice lands). */
|
||||
const maSound = {
|
||||
/** Footsteps along the track. */
|
||||
steps: (d: number) => {
|
||||
for (let i = 0; i < 3; i++) tone(i % 2 ? 560 : 470, 45, 'triangle', 0.09, d + i * 90);
|
||||
},
|
||||
/** A racer's power: a quick sparkle up. */
|
||||
power: (d: number) => [880, 1175, 1568].forEach((f, i) => tone(f, 90, 'triangle', 0.08, d + i * 60)),
|
||||
/** Star space (+1 point). */
|
||||
star: (d: number) => {
|
||||
tone(1318, 70, 'square', 0.05, d);
|
||||
tone(1976, 160, 'square', 0.05, d + 70);
|
||||
},
|
||||
/** Rock space: tripped. */
|
||||
trip: (d: number) => tone(300, 200, 'sawtooth', 0.05, d, { slideTo: 150 }),
|
||||
/** Arrow space: slide forward / back. */
|
||||
arrow: (d: number, up: boolean) => tone(up ? 500 : 900, 220, 'sine', 0.09, d, { slideTo: up ? 1000 : 450 }),
|
||||
/** Crossing the finish line. */
|
||||
finish: (d: number) => [784, 988, 1318].forEach((f, i) => tone(f, 130, 'triangle', 0.1, d + i * 90)),
|
||||
};
|
||||
|
||||
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). */
|
||||
@@ -42,6 +63,10 @@ const CSS = `
|
||||
.ma-tok circle { stroke: #1f2937; stroke-width: 2; }
|
||||
.ma-tok.cur circle { stroke: var(--focus); stroke-width: 4; }
|
||||
.ma-tok.trip { opacity: .55; }
|
||||
.ma-hop { transform-box: fill-box; transform-origin: center; animation: ma-hop .45s ease-out; }
|
||||
@keyframes ma-hop { 30% { transform: translateY(-10px) scale(1.12); } 60% { transform: translateY(0) scale(.96); } }
|
||||
.ma-hop.tripped { animation: anim-shake .45s ease both; }
|
||||
.ma-medal { transform-box: fill-box; transform-origin: center; animation: anim-pop .32s cubic-bezier(.3,1.6,.5,1) both; }
|
||||
.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; }
|
||||
@@ -97,7 +122,7 @@ button.ma-card:hover:not(:disabled) { border-color: var(--primary); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.ma-tok { transition: none; }
|
||||
.ma-die.rolling, .ma-news .fresh { animation: none; }
|
||||
.ma-die.rolling, .ma-news .fresh, .ma-hop, .ma-medal { animation: none; }
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -209,12 +234,15 @@ function Track({ v, me, players }: { v: MagicalAthleteView; me: string | null; p
|
||||
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>
|
||||
{/* Remounted on every move / trip: a hop (or a stumble) while the token slides. */}
|
||||
<g key={`${x.pos}-${x.tripped}`} className={`ma-hop${x.tripped ? ' tripped' : ''}`}>
|
||||
<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>
|
||||
</g>
|
||||
{x.place && (
|
||||
<text textAnchor="middle" x={n === 1 ? 14 : size} y={n === 1 ? 19 : size + 2} fontSize={n === 1 ? 13 : 10}>
|
||||
<text className="ma-medal" textAnchor="middle" x={n === 1 ? 14 : size} y={n === 1 ? 19 : size + 2} fontSize={n === 1 ? 13 : 10}>
|
||||
{x.place === 1 ? '🥇' : '🥈'}
|
||||
</text>
|
||||
)}
|
||||
@@ -293,9 +321,11 @@ function RacePanel({ v, me, players, act, pending, rolling }: { v: MagicalAthlet
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<p className="small muted" style={{ margin: 0 }}>
|
||||
시간이 지나면 {pr.timeoutText}.
|
||||
</p>
|
||||
{v.options.turnSeconds !== null && (
|
||||
<p className="small muted" style={{ margin: 0 }}>
|
||||
시간이 지나면 {pr.timeoutText}.
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<p className="muted small" style={{ margin: 0 }}>
|
||||
@@ -325,7 +355,7 @@ function Draft({ v, me, players, act, pending }: { v: MagicalAthleteView; me: st
|
||||
</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 })}>
|
||||
<button key={id} type="button" className="ma-card anim-deal" 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>
|
||||
@@ -487,6 +517,8 @@ function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthlete
|
||||
const prevRace = useRef<number>(v.race?.no ?? 0);
|
||||
const [fresh, setFresh] = useState(prevLog.current);
|
||||
const prevTurn = useRef(v.turnSeq);
|
||||
const soundReady = useRef(false);
|
||||
const rollHeard = useRef(v.rollSeq);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (v.rollSeq <= prevRoll.current) {
|
||||
@@ -494,12 +526,10 @@ function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthlete
|
||||
return;
|
||||
}
|
||||
prevRoll.current = v.rollSeq;
|
||||
if (reducedMotion()) return sounds.stone();
|
||||
sfx.dice();
|
||||
if (reducedMotion()) return;
|
||||
setRolling(true);
|
||||
const t = setTimeout(() => {
|
||||
setRolling(false);
|
||||
sounds.stone();
|
||||
}, ROLL_MS);
|
||||
const t = setTimeout(() => setRolling(false), ROLL_MS);
|
||||
return () => clearTimeout(t);
|
||||
}, [v.rollSeq]);
|
||||
|
||||
@@ -513,14 +543,38 @@ function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthlete
|
||||
}
|
||||
const last = r.log.at(-1)?.n ?? 0;
|
||||
if (last <= prevLog.current) return;
|
||||
const first = prevLog.current === 0 && !soundReady.current;
|
||||
const added = r.log.filter((l) => l.n > prevLog.current && l.kind !== 'turn');
|
||||
setFresh(prevLog.current);
|
||||
prevLog.current = last;
|
||||
soundReady.current = true;
|
||||
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();
|
||||
// One sound per update, after the dice lands when this update rolled (the dice has its own sound).
|
||||
if (first) return;
|
||||
const d = v.rollSeq > rollHeard.current && !reducedMotion() ? ROLL_MS : 0;
|
||||
rollHeard.current = v.rollSeq;
|
||||
const sp = added.filter((l) => l.kind === 'space');
|
||||
if (added.some((l) => l.kind === 'finish')) maSound.finish(d);
|
||||
else if (added.some((l) => l.kind === 'power')) maSound.power(d);
|
||||
else if (sp.some((l) => l.text.includes('별'))) maSound.star(d);
|
||||
else if (sp.some((l) => l.text.includes('돌'))) maSound.trip(d);
|
||||
else if (sp.length) maSound.arrow(d, sp.some((l) => l.text.includes('앞 화살표')));
|
||||
else if (added.some((l) => l.kind === 'move')) maSound.steps(d);
|
||||
}, [v.race?.log.at(-1)?.n, v.race?.no]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Draft picks, race selections and a new race, whoever made them.
|
||||
const drafted = Object.values(v.teams).flat().length;
|
||||
const pickedN = Object.values(v.picked).filter(Boolean).length;
|
||||
const prevPhase = useRef({ phase: v.phase, drafted, picked: pickedN, race: v.raceNo });
|
||||
useEffect(() => {
|
||||
const p = prevPhase.current;
|
||||
prevPhase.current = { phase: v.phase, drafted, picked: pickedN, race: v.raceNo };
|
||||
if (v.phase === 'race' && (p.phase !== 'race' || p.race !== v.raceNo)) return sfx.whoosh();
|
||||
if (v.phase === 'draft' && drafted > p.drafted) return sfx.cardDeal();
|
||||
if (v.phase === 'select' && pickedN > p.picked) sfx.chip();
|
||||
}, [v.phase, drafted, pickedN, v.raceNo]);
|
||||
|
||||
useEffect(() => {
|
||||
if (v.turnSeq === prevTurn.current) return;
|
||||
prevTurn.current = v.turnSeq;
|
||||
|
||||
@@ -2465,12 +2465,12 @@ const PLANS: Record<string, Plan> = {
|
||||
},
|
||||
},
|
||||
catchmind: {
|
||||
// PC host + phone guest, 1 round of 60 s: each player draws once with real mouse strokes; the other sees the strokes
|
||||
// PC host + phone guest, 1 round with no drawing time limit (무제한): each player draws once with real mouse strokes; the other sees the strokes
|
||||
// (stroke count + pixels), guesses wrong, gets "아까워요" for a near miss, then the right answer; scores update.
|
||||
lobby: async (host) => {
|
||||
await host.getByRole('group', { name: '라운드 수' }).getByRole('button', { name: '1라운드' }).click();
|
||||
await host.getByRole('group', { name: '그리기 시간' }).getByRole('button', { name: '60초' }).click();
|
||||
await host.getByText(/^여러 명 맞히기 · 1라운드 · 60초/).first().waitFor();
|
||||
await host.getByRole('group', { name: '그리기 시간' }).getByRole('button', { name: '무제한' }).click();
|
||||
await host.getByText(/^여러 명 맞히기 · 1라운드 · 그리기 무제한/).first().waitFor();
|
||||
},
|
||||
drive: async (pages) => {
|
||||
const [host, guest] = pages as [Page, Page];
|
||||
@@ -2499,7 +2499,10 @@ const PLANS: Record<string, Plan> = {
|
||||
players: 3,
|
||||
lobby: async (host) => {
|
||||
await host.getByRole('group', { name: '설명 바퀴 수' }).getByRole('button', { name: '한 바퀴' }).click();
|
||||
await host.getByText(/한 바퀴 · 설명 30초/).first().waitFor();
|
||||
// Every phase without a clock (무제한): the flow below only moves on by what people do.
|
||||
await host.getByRole('button', { name: '▼ 자세한 설정' }).click();
|
||||
for (const g of ['설명 시간', '토론 시간', '투표 시간', '정답 맞히기 시간']) await host.getByRole('group', { name: g }).getByRole('button', { name: '무제한' }).click();
|
||||
await host.getByText(/한 바퀴 · 설명 무제한 · 토론 무제한/).first().waitFor();
|
||||
},
|
||||
drive: async (pages) => {
|
||||
const [host, phone] = pages as [Page, Page, Page];
|
||||
@@ -2597,10 +2600,11 @@ const PLANS: Record<string, Plan> = {
|
||||
// Night cannot end early (only its clock advances it), so give the night's chat+3 picks ample room under load.
|
||||
await host.getByRole('group', { name: '밤 시간' }).getByRole('button', { name: '45초' }).click();
|
||||
await host.getByRole('button', { name: '▼ 자세한 설정' }).click();
|
||||
await host.getByRole('group', { name: '지목 투표 시간' }).getByRole('button', { name: '10초', exact: true }).click();
|
||||
// 지목 투표·찬반 투표 무제한: they end as soon as everybody alive has voted.
|
||||
await host.getByRole('group', { name: '지목 투표 시간' }).getByRole('button', { name: '무제한' }).click();
|
||||
await host.getByRole('group', { name: '최후의 반론 시간' }).getByRole('button', { name: '10초', exact: true }).click();
|
||||
await host.getByRole('group', { name: '찬반 투표 시간' }).getByRole('button', { name: '5초', exact: true }).click();
|
||||
await host.getByText(/밤 45초 · 투표 10초/).first().waitFor();
|
||||
await host.getByRole('group', { name: '찬반 투표 시간' }).getByRole('button', { name: '무제한' }).click();
|
||||
await host.getByText(/밤 45초 · 투표 무제한/).first().waitFor();
|
||||
},
|
||||
drive: async (pages) => {
|
||||
const [host, phone] = pages as [Page, Page, Page, Page];
|
||||
@@ -2663,8 +2667,11 @@ const PLANS: Record<string, Plan> = {
|
||||
|
||||
for (const i of [M, P, D]) await mafiaBanner(pages[i]!, '지목 투표', 15_000);
|
||||
await mafiaPick(pages[P]!, MAFIA_NICKS[M]!);
|
||||
await pages[P]!.getByRole('timer', { name: '시간 제한 없음' }).waitFor();
|
||||
await mafiaShots(pages, '3b-vote-unlimited');
|
||||
await mafiaPick(pages[D]!, MAFIA_NICKS[M]!);
|
||||
await mafiaPick(pages[M]!, MAFIA_NICKS[P]!);
|
||||
// The last vote ends the 무제한 vote at once (no pressed state to wait for).
|
||||
await pages[M]!.locator('button.mf-tile[data-target="ok"]', { has: pages[M]!.locator('.nm', { hasText: new RegExp(`^${MAFIA_NICKS[P]}( \\(나\\))?$`) }) }).click();
|
||||
await mafiaBanner(host, '최후의 반론', 20_000);
|
||||
await pages[M]!.locator('.mf-news', { hasText: '지목 투표 결과' }).waitFor();
|
||||
if (await pages[P]!.getByLabel('전체 채팅 메시지').count()) throw new Error('others can talk during the last defense');
|
||||
@@ -2673,8 +2680,8 @@ const PLANS: Record<string, Plan> = {
|
||||
await mafiaShots(pages, '4-defense');
|
||||
await mafiaBanner(pages[P]!, '찬반 투표', 20_000);
|
||||
await pages[P]!.getByRole('button', { name: '찬성 (탈락)' }).click();
|
||||
await pages[D]!.getByRole('button', { name: '찬성 (탈락)' }).click();
|
||||
await pages[P]!.getByRole('button', { name: '찬성 (탈락)', pressed: true }).waitFor();
|
||||
await pages[D]!.getByRole('button', { name: '찬성 (탈락)' }).click();
|
||||
|
||||
for (const p of pages) await p.getByRole('dialog', { name: '게임 결과' }).waitFor({ timeout: 20_000 });
|
||||
for (const p of pages) await p.locator('.mf-final', { hasText: '시민 팀 승리' }).waitFor();
|
||||
@@ -2804,8 +2811,8 @@ const PLANS: Record<string, Plan> = {
|
||||
// and the refuter see the shown card. After 8 suggestions everybody accuses a guess, so the game ends.
|
||||
players: 3,
|
||||
lobby: async (host) => {
|
||||
await host.getByRole('group', { name: '차례 제한 시간' }).getByRole('button', { name: '30초' }).click();
|
||||
await host.getByText(/주사위 이동 · 차례 30초/).first().waitFor();
|
||||
await host.getByRole('group', { name: '차례 제한 시간' }).getByRole('button', { name: '무제한' }).click();
|
||||
await host.getByText(/주사위 이동 · 차례 시간 무제한/).first().waitFor();
|
||||
},
|
||||
drive: async (pages) => {
|
||||
const [host, guest] = pages as [Page, Page, Page];
|
||||
|
||||
Reference in New Issue
Block a user