모든 게임: 결과·팝업은 애니메이션이 끝난 뒤에, 증강 윷놀이: 이의있음!이 다음 판에도 뜨게, 증강 고르는 목록·나오게 할 증강을 팝업 목록으로
- lib/motion: motionBusy / useMotionHold / useMotionSettled / useAfterMotionValue / AfterMotion - 방 화면: 결과 창과 상태 줄은 판이 멈춘 뒤에(실시간 게임은 상태 줄 그대로), 새 판마다 판 화면을 새로 그림 (결과 창에 둔 채 다음 판이 시작되면 이전 판의 효과 번호가 남아 이의있음!·알림이 안 뜨던 문제) - 41개 게임: 결과 패널·배너·점수·팝업이 마지막 움직임 뒤에 나오도록 게임별로 정리 - 증강 윷놀이: 명탐정·배달·손버릇·따라쟁이·착각 대상은 아이콘과 설명이 다 보이는 목록에서, 방 설정의 나오게 할 증강은 팝업 목록에서 스위치로 켜고 끔 - e2e: 늦게 바뀌는 상태 줄·결과 창과 새 증강 화면에 맞춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,7 @@ import { haptic, noise, sfx, tone } from '../../lib/feedback';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
import { fxMs } from '../../lib/motion';
|
||||
import { fxMs, useMotionHold } from '../../lib/motion';
|
||||
|
||||
// The client draws from the view only; names and hints live here so the rules module isn't bundled.
|
||||
const NAME: Record<Category, string> = {
|
||||
@@ -202,6 +202,8 @@ function DiceRow({ dice, size }: { dice: number[]; size?: number }) {
|
||||
interface RollAnim {
|
||||
key: number;
|
||||
mask: boolean[];
|
||||
/** All five the same: the 요트! flash waits until the dice have landed. */
|
||||
yacht?: { sub?: string };
|
||||
}
|
||||
|
||||
function YachtBoard({ view: v, me, players, act, pending, tapConfirm }: BoardProps<YachtView>) {
|
||||
@@ -225,6 +227,12 @@ function YachtBoard({ view: v, me, players, act, pending, tapConfirm }: BoardPro
|
||||
if (!pending) setHeld(v.held);
|
||||
}, [v.held, v.turnSeq, v.rollSeq, pending]);
|
||||
|
||||
const yachtFlash = (sub: string | undefined, key: number) => {
|
||||
setFlash({ text: '요트!', sub, key });
|
||||
sfx.fanfare();
|
||||
haptic([80, 40, 80]);
|
||||
};
|
||||
|
||||
// Roll animation, sound, yacht flash and screen-reader text when a new roll arrives (anyone's roll).
|
||||
useLayoutEffect(() => {
|
||||
if (v.rollSeq <= prevRoll.current || !v.dice) {
|
||||
@@ -237,12 +245,9 @@ function YachtBoard({ view: v, me, players, act, pending, tapConfirm }: BoardPro
|
||||
const mask = v.rollsUsed === 1 ? [true, true, true, true, true] : v.held.map((h) => !h);
|
||||
const animated = !reducedMotion();
|
||||
rollSound(mask.filter(Boolean).length, animated);
|
||||
if (v.dice.every((d) => d === v.dice![0])) {
|
||||
setFlash({ text: '요트!', sub: v.current === me ? undefined : nick(players, v.current ?? ''), key: v.rollSeq });
|
||||
sfx.fanfare();
|
||||
haptic([80, 40, 80]);
|
||||
}
|
||||
if (animated) setAnim({ key: v.rollSeq, mask });
|
||||
const yacht = v.dice.every((d) => d === v.dice![0]) ? { sub: v.current === me ? undefined : nick(players, v.current ?? '') } : undefined;
|
||||
if (animated) setAnim({ key: v.rollSeq, mask, yacht });
|
||||
else if (yacht) yachtFlash(yacht.sub, v.rollSeq);
|
||||
}, [v.rollSeq]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Someone else (re)holding dice: the same knock I hear on my own taps.
|
||||
@@ -261,12 +266,15 @@ function YachtBoard({ view: v, me, players, act, pending, tapConfirm }: BoardPro
|
||||
const end = setTimeout(() => {
|
||||
setAnim(null);
|
||||
setFlick(null);
|
||||
if (anim.yacht) yachtFlash(anim.yacht.sub, anim.key);
|
||||
}, fxMs(ROLL_MS));
|
||||
return () => {
|
||||
clearInterval(t);
|
||||
clearTimeout(end);
|
||||
};
|
||||
}, [anim]);
|
||||
}, [anim]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
// The tumble is staged with timers (flicking faces): results wait for it.
|
||||
useMotionHold(!!anim);
|
||||
|
||||
useEffect(() => {
|
||||
if (!flash) return;
|
||||
@@ -382,7 +390,7 @@ function YachtBoard({ view: v, me, players, act, pending, tapConfirm }: BoardPro
|
||||
{myTurn && v.rollsUsed > 0 && v.rollsUsed < 3 && <p className="muted small" style={{ textAlign: 'center' }}>남길 주사위를 누르면 고정돼요. 점수표의 칸을 누르면 기록해요.</p>}
|
||||
{v.lastScore && <LastScore key={`${v.lastScore.player}:${v.lastScore.category}`} entry={v.lastScore} view={v} me={me} players={players} />}
|
||||
</section>
|
||||
<ScoreSheet view={v} me={me} players={players} myTurn={myTurn} pending={pending} onScore={score} pointer={pointer} />
|
||||
<ScoreSheet view={v} me={me} players={players} myTurn={myTurn} pending={pending} rolling={!!anim} onScore={score} pointer={pointer} />
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
@@ -429,6 +437,7 @@ function ScoreSheet({
|
||||
players,
|
||||
myTurn,
|
||||
pending,
|
||||
rolling,
|
||||
onScore,
|
||||
pointer,
|
||||
}: {
|
||||
@@ -437,6 +446,8 @@ function ScoreSheet({
|
||||
players: Record<string, PublicUser>;
|
||||
myTurn: boolean;
|
||||
pending: boolean;
|
||||
/** Dice still tumbling: the points they make are not shown (or pickable) until they land. */
|
||||
rolling: boolean;
|
||||
onScore: (c: Category, points: number, viaMouse: boolean) => void;
|
||||
pointer: React.MutableRefObject<string>;
|
||||
}) {
|
||||
@@ -461,12 +472,12 @@ function ScoreSheet({
|
||||
const prev = v.current === p ? v.preview?.[c] : undefined;
|
||||
if (p === me && myTurn && v.rollsUsed > 0 && prev !== undefined) {
|
||||
const allowed = v.allowed.includes(c);
|
||||
const show = v.options.showPreview;
|
||||
const show = v.options.showPreview && !rolling;
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className={`yt-cell${show && prev > 0 ? ' good' : ''}${show && prev === 0 ? ' zero' : ''}`}
|
||||
disabled={!allowed || pending}
|
||||
disabled={!allowed || pending || rolling}
|
||||
aria-label={`${catName(c, v.options.scoring)}에 ${show ? `${prev}점 ` : ''}기록하기${allowed ? '' : ' (지금은 넣을 수 없어요)'}`}
|
||||
onPointerDown={(e) => (pointer.current = e.pointerType)}
|
||||
onClick={(e) => {
|
||||
@@ -475,11 +486,11 @@ function ScoreSheet({
|
||||
onScore(c, prev, viaMouse);
|
||||
}}
|
||||
>
|
||||
{show ? prev : '기록'}
|
||||
{show ? prev : rolling ? '' : '기록'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
if (prev !== undefined && v.options.showPreview) return <span className="yt-ghost">{prev}</span>;
|
||||
if (prev !== undefined && v.options.showPreview && !rolling) return <span className="yt-ghost">{prev}</span>;
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user