모든 게임: 결과·팝업은 애니메이션이 끝난 뒤에, 증강 윷놀이: 이의있음!이 다음 판에도 뜨게, 증강 고르는 목록·나오게 할 증강을 팝업 목록으로

- lib/motion: motionBusy / useMotionHold / useMotionSettled / useAfterMotionValue / AfterMotion
- 방 화면: 결과 창과 상태 줄은 판이 멈춘 뒤에(실시간 게임은 상태 줄 그대로), 새 판마다 판 화면을 새로 그림
  (결과 창에 둔 채 다음 판이 시작되면 이전 판의 효과 번호가 남아 이의있음!·알림이 안 뜨던 문제)
- 41개 게임: 결과 패널·배너·점수·팝업이 마지막 움직임 뒤에 나오도록 게임별로 정리
- 증강 윷놀이: 명탐정·배달·손버릇·따라쟁이·착각 대상은 아이콘과 설명이 다 보이는 목록에서,
  방 설정의 나오게 할 증강은 팝업 목록에서 스위치로 켜고 끔
- e2e: 늦게 바뀌는 상태 줄·결과 창과 새 증강 화면에 맞춤

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-08 09:07:27 +09:00
parent f18909c44f
commit 4e0eb4d52c
52 changed files with 2142 additions and 855 deletions

View File

@@ -10,7 +10,7 @@ import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
import { itemsOf, type Item } from './replay';
import { fxMs } from '../../lib/motion';
import { fxMs, useAfterMotionValue, useMotionHold } from '../../lib/motion';
const COLORS = ['#e5484d', '#2f7cf6', '#1f9d55', '#f2a10c', '#8e5cf0', '#0ea5a4'];
@@ -692,6 +692,10 @@ function useRaceDrawing(v: MagicalAthleteView, liveStart: boolean, g: Geo) {
pump();
}, [r?.no, lastN]); // eslint-disable-line react-hooks/exhaustive-deps
// The drawing replays the race step by step with timers: results (scores, the next race, 결과) wait for it.
const w = d.current;
useMotionHold(!!w.timer || w.q.length > 0 || !!w.walk || !!w.die?.rolling);
return { d: d.current, floats, confetti, banner };
}
@@ -1019,7 +1023,13 @@ const STEP_TITLE: Record<MaPrompt['step'], string> = {
};
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 pr = v.prompt;
// A new choice (it can tell the roll: "다시 굴릴까요?", "4칸 가기") shows once the die and the runners have stopped;
// until then the previous one stays, greyed out.
const key = v.prompt ? `${v.prompt.owner}|${v.prompt.step}|${v.prompt.racer ?? ''}|${v.prompt.options.map((o) => o.key).join(',')}` : '';
const settling = useAfterMotionValue(key) !== key;
const kept = useRef(v.prompt);
if (!settling) kept.current = v.prompt;
const pr = kept.current;
if (v.phase !== 'race') return null;
const mine = !!pr && pr.owner === me;
return (
@@ -1033,7 +1043,7 @@ function RacePanel({ v, me, players, act, pending, rolling }: { v: MagicalAthlet
</h3>
<div className={`ma-opts${pr.options.length > 2 ? ' many' : ''}`} 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))}>
<button key={o.key} type="button" className={`btn ${i === 0 ? 'btn-primary' : 'btn-secondary'} btn-block`} disabled={pending || rolling || settling} onClick={() => act(actionFor(pr, o.key))}>
{pr.step === 'roll' && o.key === 'roll' ? `🎲 ${o.label}` : o.label}
</button>
))}
@@ -1059,7 +1069,8 @@ function RacePanel({ v, me, players, act, pending, rolling }: { v: MagicalAthlet
}
function Legend({ v, me, players }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser> }) {
const r = v.race!;
// Positions, falls and places as of the last still screen (the board replays the race behind the view).
const r = JSON.parse(useAfterMotionValue(JSON.stringify({ cur: v.race!.cur, racers: v.race!.racers }))) as { cur: RacerId | null; racers: MaRacerView[] };
return (
<section className="card ma-panel" aria-label="이번 경주 선수">
<h3>이번 경주 선수</h3>
@@ -1155,7 +1166,9 @@ function Select({ v, me, players, act, pending }: { v: MagicalAthleteView; me: s
}
function Results({ v, me, players }: { v: MagicalAthleteView; me: string | null; players: Record<string, PublicUser> }) {
if (!v.results.length) return null;
// A race's result row shows once its finish has been drawn.
const results = v.results.slice(0, useAfterMotionValue(v.results.length));
if (!results.length) return null;
const cell = (id: RacerId | null, rr: RaceResult) => {
if (!id) return '—';
const o = rr.field.find((x) => x.id === id)!.owner;
@@ -1178,7 +1191,7 @@ function Results({ v, me, players }: { v: MagicalAthleteView; me: string | null;
</tr>
</thead>
<tbody>
{v.results.map((rr) => (
{results.map((rr) => (
<tr key={rr.no}>
<td>
{rr.no}
@@ -1243,6 +1256,9 @@ function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthlete
const prevLog = useRef<number>(v.race?.log.at(-1)?.n ?? 0);
const prevRace = useRef<number>(v.race?.no ?? 0);
const prevTurn = useRef(v.turnSeq);
// The race log lists new lines once the board has drawn them.
const [logRace, logN] = useAfterMotionValue(`${v.race?.no ?? 0}:${v.race?.log.at(-1)?.n ?? 0}`).split(':').map(Number);
const logShown = { race: logRace!, n: logN! };
// New log lines → screen-reader announcement (the board draws and sounds them).
useEffect(() => {
@@ -1282,22 +1298,29 @@ function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthlete
}, [v.turnSeq]); // eslint-disable-line react-hooks/exhaustive-deps
const r = v.race;
// A race's end (the next race's selection, the final table, the header) shows once the board has finished
// replaying it; until then the screen stays on the race.
const stage = `${v.phase}:${v.raceNo}`;
const shownStage = useAfterMotionValue(stage);
const ready = shownStage === stage;
const [phase, raceNo] = ready ? [v.phase, v.raceNo] : [shownStage.slice(0, shownStage.indexOf(':')), Number(shownStage.slice(shownStage.indexOf(':') + 1))];
const medal = v.medals[Math.min(raceNo, v.races) - 1] ?? v.medals[0]!;
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>}
<strong>{phase === 'finished' ? '게임 끝' : phase === 'draft' ? '선수 뽑기' : `${raceNo} / ${v.races} 경주`}</strong>
{r && 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}점
{v.perRace === 2 ? '경주마다 선수 둘씩 · ' : ''}1등 {medal.gold}점 · 2등 {medal.silver}점
</span>
</div>
{v.result && <FinalTable v={v} me={me} players={players} />}
{v.result && ready && <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} />}
{v.phase === 'select' && ready && <Select v={v} me={me} players={players} act={act} pending={pending} />}
{r && (
<>
{v.phase !== 'race' && (
{v.phase !== 'race' && ready && (
<p className="small muted" style={{ margin: 0 }}>
{r.no}번째 경주가 끝났을 때 모습이에요.
</p>
@@ -1307,7 +1330,7 @@ function Board({ view: v, me, players, act, pending }: BoardProps<MagicalAthlete
<section className="card ma-panel" aria-label="경주 기록">
<h3>경주 기록</h3>
<ul className="ma-log" tabIndex={0} aria-label="경주 기록 (최신이 위)">
{[...r.log].reverse().map((l) => (
{[...r.log.filter((l) => logShown.race === r.no && l.n <= logShown.n)].reverse().map((l) => (
<li key={l.n} className={l.kind}>
{ICON[l.kind]} {l.text}
</li>
@@ -1332,11 +1355,15 @@ function Side({ view: v, me, players, act, deadline, active }: BoardProps<Magica
const [ask, setAsk] = useState(false);
const total = v.options.turnSeconds ? v.options.turnSeconds * 1000 : 30_000;
const playing = v.phase !== 'finished';
// Points change once the finish / star that gave them has been drawn.
const scoreKey = v.seats.map((p) => [v.scores[p]!.gold, v.scores[p]!.silver, v.scores[p]!.bonus, v.scores[p]!.total].join(',')).join('|');
const shownScores = useAfterMotionValue(scoreKey).split('|');
return (
<>
<section className="card stack" style={{ padding: 12, gap: 8 }} aria-label="참가자">
{v.seats.map((p) => {
const sc = v.scores[p]!;
{v.seats.map((p, i) => {
const [gold, silver, bonus, tot] = (shownScores[i] ?? '').split(',').map(Number);
const sc = shownScores.length === v.seats.length ? { gold: gold!, silver: silver!, bonus: bonus!, total: tot! } : 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'}` }}>