diff --git a/apps/web/src/games/magical-athlete/index.tsx b/apps/web/src/games/magical-athlete/index.tsx index 81ddccb..f66ba02 100644 --- a/apps/web/src/games/magical-athlete/index.tsx +++ b/apps/web/src/games/magical-athlete/index.tsx @@ -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, 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 ( - - - {RACERS[x.id].emoji} - + {/* Remounted on every move / trip: a hop (or a stumble) while the token slides. */} + + + + {RACERS[x.id].emoji} + + {x.place && ( - + {x.place === 1 ? '๐Ÿฅ‡' : '๐Ÿฅˆ'} )} @@ -293,9 +321,11 @@ function RacePanel({ v, me, players, act, pending, rolling }: { v: MagicalAthlet ))} -

- ์‹œ๊ฐ„์ด ์ง€๋‚˜๋ฉด {pr.timeoutText}. -

+ {v.options.turnSeconds !== null && ( +

+ ์‹œ๊ฐ„์ด ์ง€๋‚˜๋ฉด {pr.timeoutText}. +

+ )} ) : (

@@ -325,7 +355,7 @@ function Draft({ v, me, players, act, pending }: { v: MagicalAthleteView; me: st

{d.line.map((id) => ( -