게임 속도 배율: 1배도 애니메이션·연출·컴퓨터 생각 시간을 예전의 1.5배로 늦추고, 관리자 사이트 설정 "게임 속도 배율"(1/16~16배, 기본 1)로 나눠 조절. 저장하면 열린 방에도 바로 적용(RoomView.gameSpeed 재전송)

- 서버: SiteSettings.gameSpeed, /api/config에 노출, 컴퓨터 생각 시간(defaultBotDelay)과 마피아·라이어 컴퓨터가 살펴보는 간격에 BOT_SLOWDOWN(1.5)/배율. 게임이 정한 반응 시각(원카드 외치기)은 그대로
- 웹: lib/motion.ts — .game-layout 안 CSS 애니메이션·트랜지션은 useMotionScope가 playbackRate로, Web Animations는 fxAnim, 연출 타이머(배너 유지·다음 단계·복사본 정리·숫자 세기·다시 보기 한 칸)는 fxMs. 채팅·role="timer"·규칙 시간·꾹 눌러 보기는 제외
- 관리자 사이트 탭에 배율 버튼(1/16~16)과 직접 입력
- 테스트: 배율 검증(API 400/200, 열린 방 즉시 반영), 컴퓨터 생각 시간 배율, motion 단위 테스트, e2e/speed.e2e.ts(돌 애니메이션 재생 배율·컴퓨터 응답 시간), 관리자 e2e에 배율 저장
- 문서: 14-admin §5, 07-ui-ux, 06-lobby-rooms, 13-decisions, README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-14 01:24:25 +09:00
parent 5e8f5b821f
commit 18ef402a6a
54 changed files with 536 additions and 134 deletions

View File

@@ -3,12 +3,14 @@
*
* - Everything reacts to *view changes*, so the other players' moves animate and sound too, and skips the first
* render: joining, reloading or a replay jump (the replay page remounts the board) never replays old moves.
* - Web Animations only (no layout change, `composite: 'add'` keeps the element's own transform), short (≤ 0.6 s),
* and flying copies ("ghosts") never take clicks, so nothing waits for an animation.
* - Web Animations only (no layout change, `composite: 'add'` keeps the element's own transform), short (≤ 0.6 s at
* the written lengths; the game speed scales them, lib/motion), and flying copies ("ghosts") never take clicks, so
* nothing waits for an animation.
* - Respects `prefers-reduced-motion` (Web Animations are not covered by the global CSS rule, so it is checked here).
* - Sounds stay in `lib/feedback` (`sfx`, `tone`, `noise`); game-specific ones live in each game folder.
*/
import { useLayoutEffect, useRef, useState, type ReactNode } from 'react';
import { fxAnim, fxMs } from '../lib/motion';
export const reducedMotion = (): boolean => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -48,12 +50,14 @@ export function flyFrom(el: Element | null | undefined, from: Where, o: FlyOpts
const dx = p.x - q.x;
const dy = p.y - q.y;
if (Math.abs(dx) + Math.abs(dy) < 4) return;
(el as HTMLElement).animate(
[
{ transform: `translate(${dx}px, ${dy}px) scale(${o.scale ?? 0.6}) rotate(${o.rotate ?? -10}deg)`, opacity: 0.35 },
{ transform: 'translate(0px, 0px) scale(1) rotate(0deg)', opacity: 1 },
],
{ duration: o.ms ?? 380, delay: o.delay ?? 0, easing: 'cubic-bezier(.2,.8,.3,1)', fill: 'backwards', composite: 'add' },
fxAnim(
(el as HTMLElement).animate(
[
{ transform: `translate(${dx}px, ${dy}px) scale(${o.scale ?? 0.6}) rotate(${o.rotate ?? -10}deg)`, opacity: 0.35 },
{ transform: 'translate(0px, 0px) scale(1) rotate(0deg)', opacity: 1 },
],
{ duration: o.ms ?? 380, delay: o.delay ?? 0, easing: 'cubic-bezier(.2,.8,.3,1)', fill: 'backwards', composite: 'add' },
),
);
}
@@ -97,20 +101,22 @@ export function flyGhost(from: Where, to: Where, o: GhostOpts = {}): void {
g.style.top = `${p.y - h / 2}px`;
document.body.appendChild(g);
const jitter = n > 1 ? (i - (n - 1) / 2) * 6 : 0;
const anim = g.animate(
[
{ transform: 'translate(0px, 0px) scale(.85) rotate(-8deg)', opacity: 0 },
{ opacity: 1, offset: 0.15 },
{ transform: `translate(${q.x - p.x + jitter}px, ${q.y - p.y}px) scale(1) rotate(0deg)`, opacity: 1, offset: 0.85 },
{ transform: `translate(${q.x - p.x + jitter}px, ${q.y - p.y}px) scale(.9) rotate(0deg)`, opacity: 0 },
],
{ duration: o.ms ?? 480, delay: (o.delay ?? 0) + i * (o.gap ?? 70), easing: 'cubic-bezier(.3,.7,.3,1)', fill: 'both' },
const anim = fxAnim(
g.animate(
[
{ transform: 'translate(0px, 0px) scale(.85) rotate(-8deg)', opacity: 0 },
{ opacity: 1, offset: 0.15 },
{ transform: `translate(${q.x - p.x + jitter}px, ${q.y - p.y}px) scale(1) rotate(0deg)`, opacity: 1, offset: 0.85 },
{ transform: `translate(${q.x - p.x + jitter}px, ${q.y - p.y}px) scale(.9) rotate(0deg)`, opacity: 0 },
],
{ duration: o.ms ?? 480, delay: (o.delay ?? 0) + i * (o.gap ?? 70), easing: 'cubic-bezier(.3,.7,.3,1)', fill: 'both' },
),
);
const done = () => g.remove();
anim.onfinish = done;
anim.oncancel = done;
// Safety net (a background tab may never finish the animation).
setTimeout(done, (o.ms ?? 480) + (o.delay ?? 0) + i * (o.gap ?? 70) + 1500);
setTimeout(done, fxMs((o.ms ?? 480) + (o.delay ?? 0) + i * (o.gap ?? 70)) + 1500);
}
}
@@ -127,7 +133,7 @@ export function bump(el: Element | null | undefined, kind: 'pop' | 'shake' = 'po
{ transform: 'translateX(-4px) rotate(-1deg)', offset: 0.75 },
{ transform: 'translateX(0px)' },
];
(el as HTMLElement).animate(frames, { duration: kind === 'pop' ? 320 : 420, easing: 'ease-out', composite: 'add' });
fxAnim((el as HTMLElement).animate(frames, { duration: kind === 'pop' ? 320 : 420, easing: 'ease-out', composite: 'add' }));
}
// ---------------------------------------------------------------- hooks
@@ -177,7 +183,7 @@ export function useBanner(): [ReactNode, (text: string, tone?: BannerTone, sub?:
ensureCss();
if (timer.current) clearTimeout(timer.current);
setB((old) => ({ id: (old?.id ?? 0) + 1, text, tone, sub }));
timer.current = setTimeout(() => setB(null), 1700);
timer.current = setTimeout(() => setB(null), fxMs(1700));
};
useLayoutEffect(() => () => {
if (timer.current) clearTimeout(timer.current);