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

- 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 { newEvents, toSegments, type Seg } from './events';
import { helpNow } from './help';
import { quickStart } from './quick';
import { fxMs } from '../../lib/motion';
import { fxMs, useAfterMotionValue, useMotionHold } from '../../lib/motion';
type GameEvent = MarbleView['log'][number];
@@ -514,10 +514,9 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
for (;;) {
const seg = w.q[0];
if (!seg) {
if (w.cur) {
w.cur = null;
rerender((x) => x + 1);
}
// Always re-render at the end of the queue: the motion hold below is read from the walker while rendering.
w.cur = null;
rerender((x) => x + 1);
return;
}
const wait = w.hold - Date.now();
@@ -626,19 +625,28 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
seen.current.current = v.current;
}, [v.current]); // eslint-disable-line react-hooks/exhaustive-deps
// The dice and the walking tokens are played with timers: results (and the room's result window) wait for them.
const walking = rolling !== null || !!walker.current.cur || walker.current.q.length > 0;
useMotionHold(walking);
// What the view says now shows once the board has caught up (the prompt, new owners). `v.owned` / `v.log` come
// straight from the view state, so their identity only changes with a new view.
const owned = useAfterMotionValue(v.owned);
const stepKey = [v.phase, v.current, v.lastRoll?.seq ?? 0, JSON.stringify(v.log[v.log.length - 1] ?? null)].join('|');
const settled = useAfterMotionValue(stepKey) === stepKey;
// 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 ownSeen = useRef(new Map(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) {
for (const o of 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]));
ownSeen.current = new Map(owned.map((o) => [o.pos, o]));
if (Object.keys(upd).length) setFresh((f) => ({ ...f, ...upd }));
}, [v.owned]);
}, [owned]);
const moveCell = (to: number) => {
const n = (to + 40) % 40;
@@ -664,9 +672,9 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
const ownedAt = useMemo(() => {
const m = new Map<number, MarbleOwnedView>();
for (const o of v.owned) m.set(o.pos, o);
for (const o of owned) m.set(o.pos, o);
return m;
}, [v.owned]);
}, [owned]);
const seatOf = (id: string) => v.players.find((p) => p.id === id)?.seat ?? 0;
const walk = walker.current.cur;
const trail = walk && walk.seg.walk ? new Set(walk.seg.path.slice(1, walk.i + 1)) : null;
@@ -786,7 +794,7 @@ function MarbleBoard({ view: v, me, players, act, pending }: BoardProps<MarbleVi
})}
</svg>
<div className="mb-center">
<Center view={v} me={me} players={players} act={act} pending={pending} rolling={rolling !== null} card={card} onCardClose={() => setCard(null)} />
<Center view={v} me={me} players={players} act={act} pending={pending} rolling={rolling !== null} settled={settled} card={card} onCardClose={() => setCard(null)} />
</div>
{banner && (
<div className="mb-banner-wrap" aria-hidden>
@@ -835,6 +843,7 @@ function Center({
act,
pending,
rolling,
settled,
card,
onCardClose,
}: {
@@ -844,6 +853,8 @@ function Center({
act: (a: unknown) => void;
pending: boolean;
rolling: boolean;
/** The dice and tokens have finished showing the latest move: the prompt and the result may show. */
settled: boolean;
card: { id: CardId; player: string; seq: number } | null;
onCardClose: () => void;
}) {
@@ -894,8 +905,15 @@ function Center({
)}
</div>
)}
{v.phase !== 'finished' && <Prompt view={v} me={me} players={players} act={act} pending={pending} />}
{v.phase === 'finished' && v.result && (
{v.phase !== 'finished' &&
(settled ? (
<Prompt view={v} me={me} players={players} act={act} pending={pending} />
) : (
<div className="mb-prompt" role="status">
<p>…</p>
</div>
))}
{settled && v.phase === 'finished' && v.result && (
<div className="mb-prompt">
<h3>{v.result.summary}</h3>
</div>
@@ -1189,7 +1207,9 @@ function SpaceSheet({
// ---------------------------------------------------------------- side panel
function PlayerCard({ p, v, me, players, deadline }: { p: MarblePlayerView; v: MarbleView; me: string | null; players: Record<string, PublicUser>; deadline: number | null }) {
function PlayerCard({ p: live, v, me, players, deadline }: { p: MarblePlayerView; v: MarbleView; me: string | null; players: Record<string, PublicUser>; deadline: number | null }) {
// Points, lands and 파산 / 무인도 change once the token has got there (the view's player object is stable per view).
const p = useAfterMotionValue(live);
const active = v.phase !== 'finished' && ((v.phase === 'debt' && v.debt?.debtor === p.id) || (v.phase === 'tradeResponse' && v.trade?.to === p.id) || (v.phase !== 'debt' && v.phase !== 'tradeResponse' && v.current === p.id));
const prev = useRef(p.cash);
const [delta, setDelta] = useState<{ n: number; k: number } | null>(null);
@@ -1447,7 +1467,9 @@ function MarbleSide({ view: v, me, players, act, pending, deadline }: BoardProps
const [confirm, setConfirm] = useState(false);
const [trade, setTrade] = useState(false);
const ref = useRef<HTMLOListElement>(null);
const lines = v.log.map((e) => logLine(e, players)).filter((x): x is string => !!x);
// A move is written down once the board has played it.
const log = useAfterMotionValue(v.log);
const lines = log.map((e) => logLine(e, players)).filter((x): x is string => !!x);
useEffect(() => {
ref.current?.scrollTo({ top: ref.current.scrollHeight });
}, [v.turnSeq]);