루미큐브·다빈치 코드·마작·라스베가스·부루마불·요트 다이스 소리·애니메이션: 상대·컴퓨터 행동도 화면 변화로 한 번만 울림(처음 들어올 때·재접속은 조용), 타일 놓기·뒤집기, 주사위 굴림, 말 한 칸씩 이동, 점수 통 튀기, 큰 순간 배너

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 13:09:19 +09:00
parent 1b4c80a2df
commit a6ace5b5e8
8 changed files with 1557 additions and 273 deletions

View File

@@ -0,0 +1,46 @@
import { expect, test } from 'bun:test';
import { movePath, newEvents, toSegments, type GameEvent } from './events';
const ev = (type: string, extra: Record<string, unknown> = {}): GameEvent => ({ type, ...extra }) as GameEvent;
test('부루마불 화면: 새 기록만 골라내기(60개 창이 밀려도)', () => {
const old = Array.from({ length: 60 }, (_, i) => ev('turn', { player: 'A', round: i }));
expect(newEvents(old, old)).toEqual([]);
expect(newEvents(old, [...old])).toEqual([]);
const added = [ev('rolled', { player: 'A', dice: [1, 2] }), ev('moved', { player: 'A', from: 0, to: 3, kind: 'roll' })];
expect(newEvents(old, [...old.slice(2), ...added])).toEqual(added);
expect(newEvents(old.slice(0, 5), [...old.slice(0, 5), ...added])).toEqual(added);
expect(newEvents([], added)).toEqual(added);
// Replay jumping back / unrelated log: no match, stay quiet.
expect(newEvents(old.slice(10, 20), old.slice(0, 5))).toBeNull();
});
test('부루마불 화면: 말이 지나가는 칸', () => {
expect(movePath(ev('moved', { from: 37, to: 2, kind: 'roll' }))).toEqual([37, 38, 39, 0, 1, 2]);
expect(movePath(ev('moved', { from: 2, to: 39, kind: 'back' }))).toEqual([2, 1, 0, 39]);
expect(movePath(ev('moved', { from: 30, to: 5, kind: 'space' }))).toEqual([30, 5]);
expect(movePath(ev('moved', { from: 0, to: 0, kind: 'card', passedStart: true }))).toHaveLength(41);
});
test('부루마불 화면: 굴림 → 이동 → 도착 처리 순서로 나누기', () => {
const segs = toSegments(
[
ev('rolled', { player: 'A' }),
ev('moved', { player: 'A', from: 38, to: 3, kind: 'roll', passedStart: true }),
ev('salary', { player: 'A' }),
ev('tollPaid', { from: 'A', to: 'B' }),
ev('turn', { player: 'B' }),
ev('rolled', { player: 'B' }),
ev('toIsland', { player: 'B', why: 'doubles' }),
],
new Map([
['A', 38],
['B', 7],
]),
);
expect(segs.map((s) => [s.player, s.path, s.walk, s.salary, s.start.map((e) => e.type), s.after.map((e) => e.type)])).toEqual([
[null, [], false, false, [], ['rolled']],
['A', [38, 39, 0, 1, 2, 3], true, true, [], ['salary', 'tollPaid', 'turn', 'rolled']],
['B', [7, 10], false, false, ['toIsland'], []],
]);
});

View File

@@ -0,0 +1,86 @@
/** 부루마불 화면: what happened since the last view (log diff) and how the tokens should walk it (docs/games/marble.md §9.1). */
import type { MarbleView } from '@bg/games/marble';
export type GameEvent = MarbleView['log'][number];
const ISLAND = 10;
/**
* Events added since `prev`. The log is a sliding window (the engine keeps the last 60), so the new log is a suffix of
* the old one plus the new events. Returns null when the two don't line up (reconnect, replay jumping back): the
* caller then stays quiet instead of replaying old events.
*/
export function newEvents(prev: readonly GameEvent[], next: readonly GameEvent[]): GameEvent[] | null {
if (prev === next) return [];
if (!prev.length) return next.slice();
const a = prev.map((e) => JSON.stringify(e));
const b = next.map((e) => JSON.stringify(e));
for (let k = Math.min(a.length, b.length); k > 0; k--) {
let same = true;
for (let j = 0; j < k && same; j++) same = a[a.length - k + j] === b[j];
if (same) return next.slice(k);
}
return null;
}
/** Squares a token passes through for one `moved` event, starting square first. Space travel / warps jump (2 squares). */
export function movePath(e: GameEvent): number[] {
const from = e.from as number;
const to = e.to as number;
if (e.kind === 'space' || e.kind === 'warp') return [from, to];
const back = e.kind === 'back';
let n = back ? (from - to + 40) % 40 : (to - from + 40) % 40;
if (n === 0 && e.passedStart) n = 40; // "출발로" from 출발: a full lap
const path = [from];
for (let i = 1; i <= n; i++) path.push((((back ? from - i : from + i) % 40) + 40) % 40);
return path;
}
/**
* One piece of the replay queue: a token move (walk square by square, or jump) with the events to play when it starts
* and when it lands; or (player null) just events.
*/
export interface Seg {
player: string | null;
path: number[];
/** Square by square (dice, cards) rather than a jump (space travel, island). */
walk: boolean;
/** The walk passes or reaches 출발 (salary coin on that square). */
salary: boolean;
start: GameEvent[];
after: GameEvent[];
}
const blank = (): Seg => ({ player: null, path: [], walk: false, salary: false, start: [], after: [] });
/**
* Splits new events into queue pieces: a new piece at every move (and at "sent to the island", which has no `moved`
* event), and right after a roll so what the dice caused waits until they stop. `posBefore`: squares in the last view.
*/
export function toSegments(added: readonly GameEvent[], posBefore: ReadonlyMap<string, number>): Seg[] {
const pos = new Map(posBefore);
const out: Seg[] = [];
let cur = blank();
const push = (s: Seg) => {
if (s.player || s.start.length || s.after.length) out.push(s);
};
for (const e of added) {
const id = typeof e.player === 'string' ? e.player : null;
if (e.type === 'moved' && id) {
push(cur);
const walk = e.kind !== 'space' && e.kind !== 'warp';
cur = { player: id, path: movePath(e), walk, salary: walk && !!e.passedStart, start: [], after: [] };
pos.set(id, e.to as number);
} else if (e.type === 'toIsland' && id && pos.has(id) && pos.get(id) !== ISLAND) {
push(cur);
cur = { player: id, path: [pos.get(id)!, ISLAND], walk: false, salary: false, start: [e], after: [] };
pos.set(id, ISLAND);
} else if (e.type === 'rolled') {
cur.after.push(e);
push(cur);
cur = blank();
} else cur.after.push(e);
}
push(cur);
return out;
}

View File

@@ -1,12 +1,13 @@
/** 부루마불 화면 (docs/games/marble.md §9). Board, dice, tokens and buildings are drawn here (SVG/CSS only). */
import { useEffect, useMemo, useRef, useState } from 'react';
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
import type { MarbleOptions, MarbleOwnedView, MarblePlayerView, MarbleView } from '@bg/games/marble';
import { CARDS, SPACES, type CardId, type Level } from '@bg/games/marble/board';
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
import { TurnTimer } from '../../components/TurnTimer';
import { haptic, sounds } from '../../lib/feedback';
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { newEvents, toSegments, type Seg } from './events';
import { helpNow } from './help';
import { quickStart } from './quick';
@@ -150,8 +151,19 @@ const CSS = `
.mb-prompt .btn { min-height: 44px; padding: 6px 8px; font-size: .95rem; }
.mb-roll { min-height: 48px; font-size: 1rem; }
}
/* Sounds & motion (§9.1): flying token, current-player ring, big-moment banner, new land / building pop. */
.mb-fly { transform-box: fill-box; transform-origin: center; animation: mb-fly .34s cubic-bezier(.3, 1.5, .5, 1) both; }
@keyframes mb-fly { from { transform: translateY(-26px) scale(.3); opacity: 0; } }
.mb-ring { animation: mb-pulse 1.1s ease-in-out infinite; pointer-events: none; }
.mb-svg .anim-pop { transform-box: fill-box; transform-origin: center; }
.mb-banner-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 3; }
.mb-banner { padding: 10px 24px; border-radius: 18px; font-weight: 900; font-size: 2.1rem; letter-spacing: -.02em; white-space: nowrap;
background: var(--surface); color: var(--primary); border: 3px solid currentColor; box-shadow: 0 12px 34px rgba(0,0,0,.32); }
.mb-banner.good { color: var(--warning); }
.mb-banner.bad { color: var(--danger); }
@media (max-width: 640px) { .mb-banner { font-size: 1.35rem; padding: 6px 14px; border-radius: 12px; } }
@media (prefers-reduced-motion: reduce) {
.mb-cell.pick .mb-pick, .mb-trail, .mb-hop, .mb-die.rolling, .mb-card, .mb-pop { animation: none; }
.mb-cell.pick .mb-pick, .mb-trail, .mb-hop, .mb-die.rolling, .mb-card, .mb-pop, .mb-fly, .mb-ring { animation: none; }
}
`;
@@ -287,12 +299,60 @@ function DieFace({ value }: { value: number | null }) {
// ---------------------------------------------------------------- board
interface Anim {
seq: number;
player: string;
path: number[];
i: number;
}
// ---------------------------------------------------------------- sounds (synthesized; docs/games/marble.md §9.1)
const ROLL_MS = 600;
type Timer = ReturnType<typeof setTimeout>;
const fx = {
/** Token hopping onto the next square. */
step: (i: number) => {
tone(i % 2 ? 620 : 540, 40, 'triangle', 0.08);
noise(28, 0.05, 0, 'lowpass', 1500);
},
/** Token landing on its square. */
land: () => {
tone(300, 90, 'triangle', 0.14);
noise(60, 0.08, 0, 'lowpass', 700);
},
/** Land bought: a stamp, then a coin. */
buy: () => {
noise(70, 0.16, 0, 'lowpass', 600);
tone(170, 120, 'sine', 0.16);
tone(1318, 70, 'square', 0.05, 120);
tone(1976, 160, 'square', 0.05, 190);
},
/** Building: two hammer knocks and a small chime. */
build: () => {
for (const d of [0, 140]) {
noise(45, 0.14, d, 'bandpass', 1300, 1.5);
tone(260, 50, 'triangle', 0.1, d);
}
tone(523, 90, 'triangle', 0.1, 300);
tone(784, 150, 'triangle', 0.1, 380);
},
/** Toll: coins counted out, then the register bell. */
toll: () => {
for (let i = 0; i < 3; i++) sfx.chip(i * 70);
tone(2093, 220, 'triangle', 0.07, 230);
},
/** Washed up on the island: a wave and a falling whistle. */
island: () => {
noise(420, 0.08, 0, 'lowpass', 700);
tone(560, 460, 'sine', 0.1, 80, { slideTo: 200 });
},
/** One more turn stuck on the island: a small wave. */
wave: () => {
noise(380, 0.06, 0, 'lowpass', 600);
tone(392, 200, 'sine', 0.07, 100, { slideTo: 330 });
},
/** Space travel lift-off: rumble and a rising whine. */
rocket: () => {
noise(650, 0.08, 0, 'lowpass', 500);
tone(220, 700, 'sawtooth', 0.035, 0, { slideTo: 1500, attack: 60 });
},
};
const posMap = (v: MarbleView) => new Map(v.players.map((p) => [p.id, p.pos]));
function cellLabel(pos: number, v: MarbleView, players: Record<string, PublicUser>, me: string | null): string {
const sp = SPACES[pos]!;
@@ -312,72 +372,264 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
const my = v.my;
const [focus, setFocus] = useState(0);
const [info, setInfo] = useState<number | null>(null);
const [anim, setAnim] = useState<Anim | null>(null);
const [rolling, setRolling] = useState(false);
const [rolling, setRolling] = useState<number | null>(null);
const [card, setCard] = useState<{ id: CardId; player: string; seq: number } | null>(null);
const [banner, setBanner] = useState<{ text: string; kind: 'good' | 'bad' | 'info'; k: number } | null>(null);
const [announce, setAnnounce] = useState('');
const seen = useRef({ roll: v.lastRoll?.seq ?? 0, move: v.lastMove?.seq ?? 0, card: v.lastCard?.seq ?? 0, current: v.current });
const [, rerender] = useState(0);
const seen = useRef({ roll: v.lastRoll?.seq ?? 0, card: v.lastCard?.seq ?? 0, current: v.current, log: v.log, pos: posMap(v), k: 0 });
const live = useRef({ me, players });
live.current = { me, players };
/** Replay queue: tokens walk the new moves one square at a time (only the drawing; texts and buttons follow the view). */
const walker = useRef({ q: [] as Seg[], cur: null as { seg: Seg; i: number; k: number } | null, timer: null as Timer | null, hold: 0, dead: false });
const timers = useRef(new Set<Timer>());
const cellRefs = useRef<(SVGGElement | null)[]>([]);
const spaceMode = !!my?.space;
const who = (id: string) => (id === me ? '내가' : `${nick(players, id)}님이`);
// Dice roll: tumble + screen-reader text.
const later = (fn: () => void, ms: number) => {
const t = setTimeout(() => {
timers.current.delete(t);
fn();
}, ms);
timers.current.add(t);
};
useEffect(() => {
const r = v.lastRoll;
if (!r || r.seq === seen.current.roll) return;
seen.current.roll = r.seq;
setCard(null); // a new roll replaces an old card on the center
setAnnounce(`${who(r.player)} ${r.dice[0]}, ${r.dice[1]}을 굴렸어요${r.double ? '. 더블!' : ''}`);
sounds.stone();
if (reducedMotion()) return;
setRolling(true);
const t = setTimeout(() => setRolling(false), 600);
return () => clearTimeout(t);
}, [v.lastRoll?.seq]); // eslint-disable-line react-hooks/exhaustive-deps
const w = walker.current;
w.dead = false;
return () => {
w.dead = true;
if (w.timer) clearTimeout(w.timer);
w.timer = null;
w.q = [];
w.cur = null;
for (const t of timers.current) clearTimeout(t);
timers.current.clear();
};
}, []);
// Token walks along the path (forward / back); jumps for warps and space travel.
useEffect(() => {
const m = v.lastMove;
if (!m || m.seq === seen.current.move) return;
seen.current.move = m.seq;
if (reducedMotion() || m.kind === 'warp' || m.kind === 'space') return;
const path: number[] = [];
if (m.kind === 'back') for (let p = m.from; p !== m.to; ) path.push((p = (p + 39) % 40));
else for (let p = m.from; p !== m.to; ) path.push((p = (p + 1) % 40));
if (path.length) setAnim({ seq: m.seq, player: m.player, path: [m.from, ...path], i: 0 });
}, [v.lastMove?.seq]); // eslint-disable-line react-hooks/exhaustive-deps
const showBanner = (text: string, kind: 'good' | 'bad' | 'info') => {
const k = ++seen.current.k;
setBanner({ text, kind, k });
later(() => setBanner((b) => (b && b.k === k ? null : b)), 1700);
};
useEffect(() => {
if (!anim) return;
if (anim.i >= anim.path.length - 1) {
const t = setTimeout(() => setAnim(null), 100);
return () => clearTimeout(t);
/** Sound (and banner / card) for one event; `walked`: its token just walked there (the salary coin already rang). */
const play = (e: GameEvent, walked = false) => {
const { me: m, players: ps } = live.current;
const id = typeof e.player === 'string' ? e.player : '';
switch (e.type) {
case 'salary':
if (!walked) sfx.coin();
break;
case 'bought':
fx.buy();
break;
case 'built':
fx.build();
break;
case 'takeover':
fx.buy();
sfx.capture();
break;
case 'tollPaid':
if (e.waived) sfx.good();
else fx.toll();
break;
case 'paid':
case 'fundPaid':
sfx.chips(3);
break;
case 'cardGain':
case 'sold':
sfx.coin();
break;
case 'fundReceived':
if ((e.amount as number) > 0) sfx.collect();
break;
case 'cardDrawn': {
sfx.cardFlip();
const k = ++seen.current.k;
setCard({ id: e.cardId as CardId, player: id, seq: k });
later(() => setCard((x) => (x && x.seq === k ? null : x)), 3200);
break;
}
case 'toIsland':
fx.island();
showBanner('🏝️ 무인도!', 'bad');
break;
case 'islandStay':
fx.wave();
break;
case 'escaped':
sfx.good();
break;
case 'spaceWait':
sfx.pop();
break;
case 'spaceTravel':
fx.rocket();
showBanner('🚀 우주여행!', 'info');
break;
case 'debt':
sounds.warn();
break;
case 'cannotAfford':
case 'conceded':
sfx.bad();
break;
case 'bankrupt':
sfx.alarm();
showBanner(id === m ? '💸 파산했어요' : `💸 ${nick(ps, id)}님 파산!`, 'bad');
break;
case 'monopoly':
sfx.fanfare();
showBanner(id === m ? '👑 독점 달성!' : `👑 ${nick(ps, id)}님 독점!`, 'good');
break;
case 'tradeProposed':
sfx.select();
break;
case 'tradeResolved':
if (e.accepted) sfx.good();
else sfx.bad();
break;
}
const step = Math.max(45, Math.min(130, 1100 / anim.path.length));
const t = setTimeout(() => setAnim((a) => (a && a.seq === anim.seq ? { ...a, i: a.i + 1 } : a)), step);
return () => clearTimeout(t);
}, [anim]);
};
const playAll = (list: GameEvent[], walked = false) => list.forEach((e, j) => (j ? later(() => play(e, walked), j * 150) : play(e, walked)));
// Card reveal.
const stepMs = (seg: Seg) => (walker.current.q.length > 1 ? 55 : Math.max(55, Math.min(130, 1500 / Math.max(1, seg.path.length - 1))));
const pump = () => {
const w = walker.current;
if (w.dead || w.timer) return;
for (;;) {
const seg = w.q[0];
if (!seg) {
if (w.cur) {
w.cur = null;
rerender((x) => x + 1);
}
return;
}
const wait = w.hold - Date.now();
if (wait > 0) {
w.timer = setTimeout(() => {
w.timer = null;
pump();
}, wait);
return;
}
w.q.shift();
playAll(seg.start);
if (!seg.player || seg.path.length < 2) {
playAll(seg.after, seg.walk);
continue;
}
w.cur = { seg, i: 0, k: ++seen.current.k };
rerender((x) => x + 1);
w.timer = setTimeout(step, seg.walk ? stepMs(seg) : 160);
return;
}
};
const step = () => {
const w = walker.current;
w.timer = null;
const c = w.cur;
if (!c || w.dead) return;
const { seg } = c;
const i = c.i + 1;
const last = i >= seg.path.length - 1;
w.cur = { ...c, i };
if (seg.walk) {
if (seg.salary && seg.path[i] === 0) sfx.coin();
else if (last) fx.land();
else fx.step(i);
}
rerender((x) => x + 1);
w.timer = setTimeout(
last
? () => {
w.timer = null;
w.cur = null;
playAll(seg.after, seg.walk);
rerender((x) => x + 1);
pump();
}
: step,
last ? (seg.walk ? 90 : 260) : stepMs(seg),
);
};
// New events (mine, the others', the computer's) → dice, token walks, sounds, banners. The view the board opens with
// (first render, reconnect, watching, replay start) is only recorded, never replayed.
useLayoutEffect(() => {
const s = seen.current;
const added = newEvents(s.log, v.log);
const before = s.pos;
s.log = v.log;
s.pos = posMap(v);
const rm = reducedMotion();
const r = v.lastRoll;
if (r && r.seq !== s.roll) {
s.roll = r.seq;
setCard(null); // a new roll replaces an old card on the center
setAnnounce(`${who(r.player)} ${r.dice[0]}, ${r.dice[1]}을 굴렸어요${r.double ? '. 더블!' : ''}`);
sfx.dice();
if (!rm) {
const seq = r.seq;
setRolling(seq);
later(() => setRolling((x) => (x === seq ? null : x)), ROLL_MS);
walker.current.hold = Date.now() + ROLL_MS;
}
const thirdDouble = added?.some((e) => e.type === 'toIsland' && e.why === 'doubles');
if (r.double && !thirdDouble)
later(() => {
sfx.good();
showBanner('🎲 더블!', 'good');
}, rm ? 0 : ROLL_MS);
}
if (!added?.length) return;
if (rm) {
playAll(added);
return;
}
const w = walker.current;
w.q.push(...toSegments(added, before));
if (w.q.length > 8) w.q.splice(0, w.q.length - 8); // far behind (a burst of moves): skip the oldest drawings
rerender((x) => x + 1);
pump();
}, [v.log]); // eslint-disable-line react-hooks/exhaustive-deps
// Card text for screen readers (the card itself shows up when the token gets there).
useEffect(() => {
const c = v.lastCard;
if (!c || c.seq === seen.current.card) return;
seen.current.card = c.seq;
setCard({ id: c.id, player: c.player, seq: c.seq });
setAnnounce(`${who(c.player)} 행운카드를 뽑았어요: ${CARDS[c.id].name}. ${CARDS[c.id].text}`);
const t = setTimeout(() => setCard((x) => (x && x.seq === c.seq ? null : x)), 3200);
return () => clearTimeout(t);
}, [v.lastCard?.seq]); // eslint-disable-line react-hooks/exhaustive-deps
// My-turn cue.
// My-turn cue (the room screen rings it when the tab is hidden).
useEffect(() => {
if (v.current !== seen.current.current && v.current === me && v.phase !== 'finished') {
haptic(40);
sounds.myTurn();
if (document.visibilityState !== 'hidden') sounds.myTurn();
}
seen.current.current = v.current;
}, [v.current]); // eslint-disable-line react-hooks/exhaustive-deps
// Newly bought land / new building: pop in once (not on the first render).
const ownSeen = useRef(new Map(v.owned.map((o) => [o.pos, o])));
const [fresh, setFresh] = useState<Record<number, { claim?: string; level?: number }>>({});
useLayoutEffect(() => {
const upd: Record<number, { claim?: string; level?: number }> = {};
for (const o of v.owned) {
const was = ownSeen.current.get(o.pos);
if (!was || was.owner !== o.owner) upd[o.pos] = { claim: o.owner };
else if (o.level > was.level) upd[o.pos] = { level: o.level };
}
ownSeen.current = new Map(v.owned.map((o) => [o.pos, o]));
if (Object.keys(upd).length) setFresh((f) => ({ ...f, ...upd }));
}, [v.owned]);
const moveCell = (to: number) => {
const n = (to + 40) % 40;
setFocus(n);
@@ -406,16 +658,18 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
return m;
}, [v.owned]);
const seatOf = (id: string) => v.players.find((p) => p.id === id)?.seat ?? 0;
const trail = anim ? new Set(anim.path.slice(1, anim.i + 1)) : null;
const walk = walker.current.cur;
const trail = walk && walk.seg.walk ? new Set(walk.seg.path.slice(1, walk.i + 1)) : null;
const band = compact ? 28 : 22;
// Tokens: the moving one is drawn at its animation spot.
// Tokens: a walking one at its walk square, one still waiting in the queue where its walk starts.
const shownPos = (p: MarblePlayerView) => {
if (walk && walk.seg.player === p.id) return walk.seg.path[walk.i]!;
return walker.current.q.find((s) => s.player === p.id && s.path.length)?.path[0] ?? p.pos;
};
const tokens: { p: MarblePlayerView; pos: number; idx: number; n: number }[] = [];
const alive = v.players.filter((p) => p.alive);
for (const p of alive) {
const pos = anim && anim.player === p.id ? anim.path[anim.i]! : p.pos;
tokens.push({ p, pos, idx: 0, n: 0 });
}
for (const p of alive) tokens.push({ p, pos: shownPos(p), idx: 0, n: 0 });
for (const t of tokens) {
const same = tokens.filter((x) => x.pos === t.pos);
t.n = same.length;
@@ -463,7 +717,9 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
<rect x={c.x} y={c.y} width={c.w} height={c.h} style={{ fill: ownerColor ? `color-mix(in srgb, ${ownerColor} 20%, var(--surface))` : 'var(--surface)' }} stroke="var(--border)" strokeWidth={2} />
{a.band && sp.group && <rect x={a.band.x} y={a.band.y} width={a.band.w} height={a.band.h} fill={GROUP_COLORS[sp.group]} />}
{a.band && sp.kind === 'tour' && <rect x={a.band.x} y={a.band.y} width={a.band.w} height={a.band.h} fill="#64748b" />}
{ownerColor && <rect x={c.x + 4} y={c.y + 4} width={c.w - 8} height={c.h - 8} fill="none" stroke={ownerColor} strokeWidth={6} rx={4} />}
{ownerColor && (
<rect key={o!.owner} className={fresh[pos]?.claim === o!.owner ? 'anim-pop' : undefined} x={c.x + 4} y={c.y + 4} width={c.w - 8} height={c.h - 8} fill="none" stroke={ownerColor} strokeWidth={6} rx={4} />
)}
{o && o.level > 0 && a.band && (
<g>
{Array.from({ length: o.level }, (_, k) => {
@@ -471,7 +727,11 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
const step = (horiz ? a.band!.w : a.band!.h) / (o.level + 1);
const x = horiz ? a.band!.x + step * (k + 1) : a.band!.x + a.band!.w / 2;
const y = horiz ? a.band!.y + a.band!.h / 2 : a.band!.y + step * (k + 1);
return <BuildingIcon key={k} level={(k + 1) as Level} x={x} y={y} s={band * 0.85} />;
return (
<g key={k} className={fresh[pos]?.level === k + 1 ? 'anim-pop' : undefined}>
<BuildingIcon level={(k + 1) as Level} x={x} y={y} s={band * 0.85} />
</g>
);
})}
</g>
)}
@@ -495,7 +755,7 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
{o ? `통행료 ${P(o.toll)}` : P(sp.price!)}
</text>
)}
{trail?.has(pos) && <rect className="mb-trail" x={c.x} y={c.y} width={c.w} height={c.h} fill="var(--focus)" opacity={0} key={`t${anim!.seq}-${pos}`} />}
{trail?.has(pos) && <rect className="mb-trail" x={c.x} y={c.y} width={c.w} height={c.h} fill="var(--focus)" opacity={0} key={`t${walk!.k}-${pos}`} />}
{(pick || pos === decisionPos) && (
<rect className={pick ? 'mb-pick' : undefined} x={c.x + 3} y={c.y + 3} width={c.w - 6} height={c.h - 6} fill="none" stroke="var(--focus)" strokeWidth={6} rx={6} />
)}
@@ -505,17 +765,26 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
})}
{tokens.map(({ p, pos, idx, n }) => {
const [x, y] = tokenSpot(pos, idx, n, compact);
const moving = anim && anim.player === p.id;
const moving = walk && walk.seg.player === p.id && walk.i > 0 ? walk : null;
const r = compact ? 15 : 12;
return (
<g key={p.id + (moving ? `-${anim!.i}` : '')} className={moving ? 'mb-hop' : undefined} aria-hidden>
<Token seat={p.seat} x={x} y={y} r={compact ? 15 : 12} />
<g key={p.id + (moving ? `-${moving.k}-${moving.i}` : '')} className={moving ? (moving.seg.walk ? 'mb-hop' : 'mb-fly') : undefined} aria-hidden>
{v.current === p.id && v.phase !== 'finished' && <circle className="mb-ring" cx={x} cy={y} r={r * 1.75} fill="none" stroke={SEAT_COLORS[p.seat]} strokeWidth={4} />}
<Token seat={p.seat} x={x} y={y} r={r} />
</g>
);
})}
</svg>
<div className="mb-center">
<Center view={v} me={me} players={players} act={act} pending={pending} rolling={rolling} card={card} onCardClose={() => setCard(null)} />
<Center view={v} me={me} players={players} act={act} pending={pending} rolling={rolling !== null} card={card} onCardClose={() => setCard(null)} />
</div>
{banner && (
<div className="mb-banner-wrap" aria-hidden>
<div key={banner.k} className={`mb-banner anim-banner ${banner.kind}`}>
{banner.text}
</div>
</div>
)}
</div>
<p className="sr-only" aria-live="polite">
{announce}