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

- 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

@@ -11,7 +11,7 @@ import { bump, cssEsc, flyFrom, flyGhost, fxEl, reducedMotion, seatEl, useBanner
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
import { fxAnim, fxMs } from '../../lib/motion';
import { AfterMotion, fxAnim, fxMs, useAfterMotionValue, useMotionSettled } from '../../lib/motion';
const nick = (players: Record<string, PublicUser>, id: string | null | undefined) => (id ? (players[id]?.nickname ?? '알 수 없음') : '');
const userOf = (players: Record<string, PublicUser>, id: string): PublicUser => players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' };
@@ -238,18 +238,21 @@ function CapturedRow({ seat, label }: { seat: SeatView; label: string }) {
function Progress({ seat, winScore }: { seat: SeatView; winScore: number }) {
const s = seat.score;
const items: [string, boolean][] = [
const now: [string, boolean][] = [
[`광 ${s.gwang}장`, s.gwang >= 3],
[`열끗 ${s.yeol}/5`, s.yeol >= 5],
[`띠 ${s.tti}/5`, s.tti >= 5],
[`피 ${s.pi}/10`, s.pi >= 10],
];
if (s.godori) items.push([`고도리 ${s.godori}/3`, s.godori === 3]);
if (s.hong) items.push([`홍단 ${s.hong}/3`, s.hong === 3]);
if (s.cheong) items.push([`청단 ${s.cheong}/3`, s.cheong === 3]);
if (s.cho) items.push([`초단 ${s.cho}/3`, s.cho === 3]);
if (s.godori) now.push([`고도리 ${s.godori}/3`, s.godori === 3]);
if (s.hong) now.push([`홍단 ${s.hong}/3`, s.hong === 3]);
if (s.cheong) now.push([`청단 ${s.cheong}/3`, s.cheong === 3]);
if (s.cho) now.push([`초단 ${s.cho}/3`, s.cho === 3]);
// Progress changes once the taken cards have flown into the pile.
const [total, ...rest] = useAfterMotionValue([String(s.total), ...now.map(([t, d]) => `${d ? 1 : 0}${t}`)].join('|')).split('|');
const items = rest.map((x): [string, boolean] => [x.slice(1), x[0] === '1']);
return (
<div className="gs-prog" aria-label={`족보 진행: ${items.map((x) => x[0]).join(', ')}. 지금 ${s.total}점, 기준 ${winScore}점`}>
<div className="gs-prog" aria-label={`족보 진행: ${items.map((x) => x[0]).join(', ')}. 지금 ${total}점, 기준 ${winScore}점`}>
{items.map(([t, done]) => (
<span key={t} className={done ? 'done' : undefined}>
{t}
@@ -260,9 +263,11 @@ function Progress({ seat, winScore }: { seat: SeatView; winScore: number }) {
}
function SeatBadges({ seat, v }: { seat: SeatView; v: GostopView }) {
// The score changes once the taken cards have flown into the pile.
const score = useAfterMotionValue(seat.score.total);
return (
<div className="gs-badges">
{seat.participant && <span className="gs-badge score" title="이번 판 지금 점수">지금 {seat.score.total}점</span>}
{seat.participant && <span className="gs-badge score" title="이번 판 지금 점수">지금 {score}점</span>}
{seat.goCount > 0 && <span className="gs-badge go">{seat.goCount}고</span>}
{seat.shakes > 0 && <span className="gs-badge">흔듦 {seat.shakes}</span>}
{seat.bombs > 0 && <span className="gs-badge">폭탄 {seat.bombs}</span>}
@@ -279,8 +284,10 @@ function SeatBadges({ seat, v }: { seat: SeatView; v: GostopView }) {
function SeatBox({ seat, v, players, me, deadline }: { seat: SeatView; v: GostopView; players: Record<string, PublicUser>; me: string | null; deadline: number | null }) {
const u = userOf(players, seat.id);
const active = actorOf(v) === seat.id;
// Room points change once the round's payments have flown.
const total = useAfterMotionValue(seat.total);
return (
<li className={`gs-seat${active ? ' turn anim-glow' : ''}${!seat.participant && v.step !== 'sell' ? ' out' : ''}`} data-fx-seat={seat.id} aria-label={`${u.nickname}, 방 점수 ${signed(seat.total)}${seat.isDealer ? ', 선' : ''}${seat.participant ? `, 지금 ${seat.score.total}점, 손패 ${seat.handCount}장` : ''}`}>
<li className={`gs-seat${active ? ' turn anim-glow' : ''}${!seat.participant && v.step !== 'sell' ? ' out' : ''}`} data-fx-seat={seat.id} aria-label={`${u.nickname}, 방 점수 ${signed(total)}${seat.isDealer ? ', 선' : ''}${seat.participant ? `, 지금 ${seat.score.total}점, 손패 ${seat.handCount}장` : ''}`}>
<div className="gs-head">
<Avatar user={u} size={26} />
<span className="nm">
@@ -289,7 +296,7 @@ function SeatBox({ seat, v, players, me, deadline }: { seat: SeatView; v: Gostop
</span>
{seat.isDealer && <span className="gs-badge dealer">선</span>}
<span style={{ fontVariantNumeric: 'tabular-nums' }} title="방 점수 합계">
합계 <strong>{signed(seat.total)}</strong>
합계 <strong>{signed(total)}</strong>
</span>
{(seat.participant || v.step === 'sell') && (
<span className="gs-backs" aria-label={`손패 ${seat.handCount}장`}>
@@ -405,7 +412,12 @@ function Floor({ v, glow, narrow, players }: { v: GostopView; glow: Set<number>;
}
function LastTurn({ v, players }: { v: GostopView; players: Record<string, PublicUser> }) {
const t = v.lastTurn;
// A new turn (what was flipped and taken) shows once its cards have landed; until then the previous one stays.
const key = `${v.roundNo}-${v.lastTurn?.seq ?? 0}`;
const shownKey = useAfterMotionValue(key);
const kept = useRef(v.lastTurn);
if (shownKey === key) kept.current = v.lastTurn;
const t = kept.current;
if (!t) return <div className="gs-last" aria-hidden />;
const tags = t.tags.map((x) => TAG_KO[x]).filter(Boolean);
const stolen = t.stolen.reduce((a, s) => a + s.cards.length, 0);
@@ -459,7 +471,7 @@ type Ask = { kind: 'target' | 'shake' | 'bomb'; h: HandCardView } | null;
function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; act: (a: unknown) => void; pending: boolean; tapConfirm: boolean; onFocusCard: (h: HandCardView | null) => void }) {
const [lifted, setLifted] = useState<number | null>(null);
const [ask, setAsk] = useState<Ask>(null);
const canPlay = v.step === 'play' && v.turn === v.me && !pending;
const canPlay = v.phase === 'playing' && v.step === 'play' && v.turn === v.me && !pending;
const hints = v.rules.hints;
const cw = useCardW();
useEffect(() => {
@@ -578,12 +590,13 @@ function MyHand({ v, act, pending, tapConfirm, onFocusCard }: { v: GostopView; a
);
}
function MyArea(props: BoardProps<GostopView> & { onFocusCard: (h: HandCardView | null) => void }) {
const { view: v, me, players, act, pending, deadline, tapConfirm, onFocusCard } = props;
function MyArea(props: BoardProps<GostopView> & { onFocusCard: (h: HandCardView | null) => void; holdOpen: boolean }) {
const { view: v, me, players, act, pending, deadline, tapConfirm, onFocusCard, holdOpen } = props;
const seat = v.seats.find((s) => s.id === me);
if (!seat || !me) return null;
const active = actorOf(v) === me;
if (v.phase !== 'playing') return null;
// After the round ends my area stays until the result panel shows, so the last cards can still fly into my pile.
if (v.phase !== 'playing' && !(v.outcome && holdOpen)) return null;
return (
<div className={`gs-me${active ? ' turn anim-glow' : ''}`} data-fx-seat={me} aria-label="내 자리">
<div className="gs-head">
@@ -644,7 +657,13 @@ function SellPanel({ v, me, players, act, pending }: { v: GostopView; me: string
// ---------------------------------------------------------------- decisions (sheets)
function Decisions({ view: v, me, players, act, pending }: BoardProps<GostopView>) {
/** A decision sheet (고·스톱, 뒤집은 패, 총통, 국진) opens once the cards that led to it have landed. */
function Decisions(props: BoardProps<GostopView>) {
const sheet = DecisionSheet(props);
return sheet && <AfterMotion key={props.view.step}>{sheet}</AfterMotion>;
}
function DecisionSheet({ view: v, me, players, act, pending }: BoardProps<GostopView>): React.ReactElement | null {
if (!me || v.phase !== 'playing') return null;
const nop = () => {};
if (v.step === 'goStop' && v.goStop && v.turn === me) {
@@ -744,11 +763,14 @@ function outcomeTitle(o: OutcomeView, players: Record<string, PublicUser>, me: s
function RoundResult({ view: v, me, players, act, pending }: BoardProps<GostopView>) {
const o = v.outcome;
// The panel waits (invisible, so the payment chips can still fly to it) until the last cards, the 스톱! banner and
// the chips have played.
const shown = useMotionSettled(!!o && v.phase !== 'playing');
if (!o || v.phase === 'playing') return null;
const seat = v.seats.find((s) => s.id === me);
const nextMult = v.rules.nagariMultiplier === 'x2' ? Math.min(2 ** v.nagariStreak, v.rules.nagariMaxMultiplier) : 1;
return (
<section className="gs-panel gs-res" data-fx="gs-result" aria-label={`${v.roundNo}판 결과`} aria-live="polite">
<section className="gs-panel gs-res" data-fx="gs-result" aria-label={`${v.roundNo}판 결과`} aria-live="polite" aria-hidden={!shown || undefined} style={shown ? undefined : { visibility: 'hidden' }}>
<h2 style={{ margin: 0 }}>
{v.roundNo}판 결과 · {outcomeTitle(o, players, me)}
</h2>
@@ -1190,11 +1212,12 @@ function GostopBoard(props: BoardProps<GostopView>) {
}
prevMine.current = mine;
}, [mine]); // eslint-disable-line react-hooks/exhaustive-deps
const resultShown = useMotionSettled(!!v.outcome && v.phase !== 'playing');
useEffect(() => {
if (v.outcome && v.phase !== 'playing') {
if (resultShown && v.outcome && v.phase !== 'playing') {
setAnnounce(`${v.roundNo}판 결과: ${outcomeTitle(v.outcome, players, me)}`);
}
}, [v.roundNo, v.phase]); // eslint-disable-line react-hooks/exhaustive-deps
}, [v.roundNo, v.phase, resultShown]); // eslint-disable-line react-hooks/exhaustive-deps
const [banner, showBanner] = useBanner();
useGostopFx(v, me, players, showBanner);
const myIdx = v.seats.findIndex((s) => s.id === me);
@@ -1212,7 +1235,7 @@ function GostopBoard(props: BoardProps<GostopView>) {
</ul>
<Floor v={v} glow={glow} narrow={narrow} players={players} />
<RoundResult {...props} />
<MyArea {...props} onFocusCard={setFocus} />
<MyArea {...props} onFocusCard={setFocus} holdOpen={!resultShown} />
<Decisions {...props} />
{banner}
<p className="sr-only" aria-live="polite">
@@ -1226,8 +1249,14 @@ function GostopBoard(props: BoardProps<GostopView>) {
// ---------------------------------------------------------------- side
function GostopSide({ view: v, me, players, deadline }: BoardProps<GostopView>) {
const ranked = [...v.seats].sort((a, b) => b.total - a.total);
const mySeat = v.seats.find((s) => s.id === me);
// Points change once the cards / payment chips that caused them have landed.
const shownTotals = useAfterMotionValue(v.seats.map((s) => `${s.id}:${s.total}`).join(','));
const totalOf = new Map(shownTotals.split(',').map((x) => [x.slice(0, x.lastIndexOf(':')), Number(x.slice(x.lastIndexOf(':') + 1))] as const));
const total = (s: SeatView) => totalOf.get(s.id) ?? s.total;
const ranked = [...v.seats].sort((a, b) => total(b) - total(a));
const myScore = mySeat ? `${mySeat.score.total}\n${mySeat.score.items.map((x) => `${x.name} ${x.points}점`).join(' · ')}` : '';
const [myTotal, myItems] = useAfterMotionValue(myScore).split('\n');
return (
<>
<style>{CSS}</style>
@@ -1253,7 +1282,7 @@ function GostopSide({ view: v, me, players, deadline }: BoardProps<GostopView>)
{s.isDealer ? ' · 선' : ''}
{s.left ? ' · 나감' : s.autoPilot ? ' · 자동' : ''}
</span>
<strong style={{ fontVariantNumeric: 'tabular-nums' }}>{signed(s.total)}</strong>
<strong style={{ fontVariantNumeric: 'tabular-nums' }}>{signed(total(s))}</strong>
</li>
))}
</ol>
@@ -1261,10 +1290,10 @@ function GostopSide({ view: v, me, players, deadline }: BoardProps<GostopView>)
{mySeat?.participant && v.phase === 'playing' && (
<div className="card stack" style={{ gap: 6, padding: 12 }}>
<strong>
내 점수 {mySeat.score.total}점 / 기준 {v.rules.winScore}점
내 점수 {myTotal}점 / 기준 {v.rules.winScore}점
</strong>
{mySeat.score.items.length > 0 ? (
<span className="small">{mySeat.score.items.map((x) => `${x.name} ${x.points}점`).join(' · ')}</span>
{myItems ? (
<span className="small">{myItems}</span>
) : (
<span className="small muted">아직 점수 족보가 없어요.</span>
)}
@@ -1285,19 +1314,21 @@ function GostopSide({ view: v, me, players, deadline }: BoardProps<GostopView>)
</details>
)}
{v.result && (
<div className="card stack" style={{ gap: 4, padding: 12 }}>
<strong>최종 순위</strong>
{v.result.ranking.map((g, i) => (
<span key={i}>
{v.result!.ranking.slice(0, i).reduce((a, x) => a + x.length, 1)}위 {g.map((id) => nick(players, id)).join(', ')} ({signed(v.result!.scores[g[0]!] ?? 0)})
</span>
))}
{v.stats.bestRound && (
<span className="small muted">
가장 큰 판: {v.stats.bestRound.roundNo}판 {nick(players, v.stats.bestRound.player)} {pts(v.stats.bestRound.amount)}
</span>
)}
</div>
<AfterMotion>
<div className="card stack" style={{ gap: 4, padding: 12 }}>
<strong>최종 순위</strong>
{v.result.ranking.map((g, i) => (
<span key={i}>
{v.result!.ranking.slice(0, i).reduce((a, x) => a + x.length, 1)}위 {g.map((id) => nick(players, id)).join(', ')} ({signed(v.result!.scores[g[0]!] ?? 0)})
</span>
))}
{v.stats.bestRound && (
<span className="small muted">
가장 큰 판: {v.stats.bestRound.roundNo}판 {nick(players, v.stats.bestRound.player)} {pts(v.stats.bestRound.amount)}
</span>
)}
</div>
</AfterMotion>
)}
<details className="card" style={{ padding: 12 }}>
<summary style={{ cursor: 'pointer', fontWeight: 700 }}>족보표</summary>