게임 속도 배율: 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

@@ -12,6 +12,7 @@ import { bump, cssEsc, flyFrom, flyGhost, fxEl, reducedMotion, seatEl, useBanner
import { fanCard, fanLayout, type FanLayout } from './fan';
import { helpNow } from './help';
import { quickStart } from './quick';
import { fxAnim, fxMs } from '../../lib/motion';
// Kept local (type-only import above) so the screen chunk does not pull in the rules module + zod.
const JOKER = 'X1';
@@ -72,7 +73,7 @@ function liftFly(from: DOMRect, to: Element | null | undefined, delay: number):
const dy = b.top + b.height / 2 - (from.top + from.height / 2);
// Onto a card in my hand: shrink to its size. Onto a seat: a small card.
const s = b.width <= 120 ? Math.max(0.4, Math.min(1.2, b.width / from.width)) : 0.6;
const anim = g.animate(
const anim = fxAnim(g.animate(
[
{ transform: 'translate(0px, 0px) scale(1) rotate(0deg)', opacity: 1 },
{ transform: 'translate(0px, -28px) scale(1.08) rotate(-4deg)', opacity: 1, offset: 0.3 },
@@ -80,11 +81,11 @@ function liftFly(from: DOMRect, to: Element | null | undefined, delay: number):
{ transform: `translate(${dx}px, ${dy}px) scale(${s}) rotate(0deg)`, opacity: 0 },
],
{ duration: LIFT_MS, delay, easing: 'cubic-bezier(.35,.6,.3,1)', fill: 'both' },
);
));
const done = () => g.remove();
anim.onfinish = done;
anim.oncancel = done;
setTimeout(done, LIFT_MS + delay + 1500);
setTimeout(done, fxMs(LIFT_MS + delay) + 1500);
return true;
}
@@ -92,8 +93,8 @@ function liftFly(from: DOMRect, to: Element | null | undefined, delay: number):
function reveal(el: Element, delay: number): void {
const h = el as HTMLElement;
if (typeof h.animate !== 'function') return;
h.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 120, delay, fill: 'backwards' });
h.animate([{ transform: 'scale(.8)' }, { transform: 'scale(1.1)', offset: 0.6 }, { transform: 'scale(1)' }], { duration: 280, delay, easing: 'ease-out', composite: 'add' });
fxAnim(h.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 120, delay, fill: 'backwards' }));
fxAnim(h.animate([{ transform: 'scale(.8)' }, { transform: 'scale(1.1)', offset: 0.6 }, { transform: 'scale(1)' }], { duration: 280, delay, easing: 'ease-out', composite: 'add' }));
}
const nick = (players: Record<string, PublicUser>, id: string) => players[id]?.nickname ?? '알 수 없음';
@@ -618,10 +619,10 @@ function MyArea({ v, me, players, act, pending, deadline, fresh, bubble }: { v:
const dx = a[0] - b[0];
const dy = a[1] - b[1];
if (Math.abs(dx) + Math.abs(dy) < 2 || typeof c.animate !== 'function') continue;
c.animate(
fxAnim(c.animate(
[{ transform: `translate(${dx}px, ${dy}px)` }, { transform: `translate(${dx / 2}px, ${dy / 2 - 18}px)`, offset: 0.45 }, { transform: 'translate(0px, 0px)' }],
{ duration: 480, delay: n++ * 14, easing: 'cubic-bezier(.3,.7,.3,1)', fill: 'backwards', composite: 'add' },
);
));
}
}, [order, width, l.wrap]);
return (
@@ -729,12 +730,12 @@ function OldMaidBoard({ view: v, me, players, act, pending, deadline, tapConfirm
if (msgs.length) setAnnounce(msgs.join(' '));
if (Object.keys(bub).length) {
setBubbles((b) => ({ ...b, ...bub }));
setTimeout(() => setBubbles((b) => Object.fromEntries(Object.entries(b).filter(([k]) => !(k in bub)))), 2500);
setTimeout(() => setBubbles((b) => Object.fromEntries(Object.entries(b).filter(([k]) => !(k in bub)))), fxMs(2500));
}
prev.current = { logCount: v.logCount, hand, turn: v.turn };
if (shuffled) {
setRiffle(true);
const t = setTimeout(() => setRiffle(false), 1000);
const t = setTimeout(() => setRiffle(false), fxMs(1000));
return () => clearTimeout(t);
}
return undefined;
@@ -767,7 +768,7 @@ function useOldMaidFx(v: OldMaidView, me: string | null, players: Record<string,
const amPlayer = !!me && v.order.includes(me);
const hand = v.myHand ?? [];
const prevHand = useRef(hand);
const later = (ms: number, f: () => void) => (ms ? setTimeout(f, ms) : f());
const later = (ms: number, f: () => void) => (ms ? setTimeout(f, fxMs(ms)) : f());
/** My seat is my own area; the hand inside it is a better spot for cards leaving / arriving. */
const spot = (p: string) => (p === me ? (fxEl('om-hand') ?? seatEl(p)) : seatEl(p));
const entries = v.log.map((e, i) => ({ e, n: v.logCount - v.log.length + i }));
@@ -858,7 +859,7 @@ function useOldMaidFx(v: OldMaidView, me: string | null, players: Record<string,
setTimeout(() => {
bump(seatEl(thief), 'shake');
bump(fxEl('om-table')?.querySelector('.om-thief-joker'), 'pop');
}, 200);
}, fxMs(200));
});
const started = useRef(false);
useLayoutEffect(() => {
@@ -867,7 +868,7 @@ function useOldMaidFx(v: OldMaidView, me: string | null, players: Record<string,
// Mounted right at the start (nobody has drawn or shuffled yet): show the deal once.
if (v.phase !== 'playing' || v.logCount !== 0 || v.turnNo !== 1) return;
sfx.shuffle();
setTimeout(() => sfx.deal(8, 60), 300);
setTimeout(() => sfx.deal(8, 60), fxMs(300));
// Next frame: the card rows lay themselves out once their width is known (useWidth), so measure after that.
requestAnimationFrame(() => {
const table = fxEl('om-table');