움직임 더하기 2차: 루미큐브·마피아·라이어·바둑·클루·오목·포커

- 루미큐브: 옮긴 타일이 원래 자리에서 미끄러져 가고, 남이 바닥에 낸 타일은 그 사람 칸에서 날아옴. 가져온 타일은 남은 타일 더미에서 받침대로 날아오고, 남이 가져가면 뒤집힌 타일이 그 사람 칸으로 날아감. 배너를 공통 useBanner로 바꾸고 "루미큐브!"·"판 끝"·승리 배너 추가
- 마피아: 밤에는 화면이 남색으로 어두워지며 달, 아침에는 해가 떠오름. 득표 막대가 한 줄씩 자라고, 탈락한 사람 칸이 뒤집히며 흐려짐. 탈락·살았다·버텼다·조용한 밤·이긴 팀 배너를 차례로
- 라이어: 득표가 한 줄씩 나온 뒤 지목된 사람에게 스포트라이트와 흔들림, "잡았다!"/"헛다리!"·동점·정답/땡·승리 배너
- 바둑: 패스·계가 배너, 계가 때 집 표시가 차례로 나타나고 결과 점수가 0부터 올라감, 승리 배너
- 클루: 말과 흉기가 새 자리로 튀어 오르며 미끄러져 감, 추리한 세 장이 사건 봉투로 날아가고, 보여 준 카드는 뒤집히며(남에게는 뒷면 카드가 날아감)
- 오목: 금수 자리를 누르면 빨간 ✕와 "금수" 글자, 판이 흔들림(키보드 Enter도 같은 안내). "오목!"·승패 배너
- 포커: 쇼다운·인디언 이마 카드가 뒷면이 돌아간 뒤 앞면이 돌아 나오는 진짜 뒤집기로
- 모두 누구의 행동이든 화면 변화에 반응하고, 클릭을 막지 않으며, 동작 줄이기 설정을 따름. 게임 문서 UI 절에 반영

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 22:36:44 +09:00
parent d35b7207a3
commit 843786f687
14 changed files with 539 additions and 83 deletions

View File

@@ -12,6 +12,7 @@ import type { PublicUser } from '@bg/shared/lite';
import { Avatar } from '../../components/ui';
import { useServerNow } from '../../components/TurnTimer';
import { haptic, sfx, sounds, tone } from '../../lib/feedback';
import { cssEsc, useBanner, type BannerTone } from '../card-fx';
import { ChatMessage, nameHue, sameRun } from '../../components/ChatMessage';
import { useStickToBottom } from '../../lib/useStickToBottom';
import { useChatOutbox, useTypingSignal } from '../../lib/chat-input';
@@ -134,6 +135,16 @@ button.lg-tile { cursor: pointer; }
@keyframes lg-pick { 50% { transform: scale(1.07); } }
.lg-card[data-show='true'] { animation: anim-flip .35s ease both; }
@keyframes lg-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
/* Vote results come in one row at a time (--d = the row's delay). */
.lg-bar { animation: anim-slide-up .3s ease-out both; animation-delay: var(--d, 0ms); }
.lg-bar .tr i { animation-delay: var(--d, 0ms); animation-fill-mode: both; }
.lg-bar .ct { animation: anim-pop .32s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--d, 0ms) + 450ms); }
/* Spotlight on the accused: the screen darkens around their tile (never takes clicks), the tile glows and shakes. */
.lg-spot { position: fixed; inset: 0; z-index: 55; pointer-events: none; animation: lg-spot 1.8s ease both;
background: radial-gradient(circle at var(--x) var(--y), rgba(0,0,0,0) 0, rgba(0,0,0,0) 70px, rgba(8,8,20,.72) 150px); }
@keyframes lg-spot { 0% { opacity: 0; } 18% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.lg-tile.spot { z-index: 1; animation: anim-shake .45s ease .25s both, lg-glow 1.5s ease both; }
@keyframes lg-glow { 0%, 100% { box-shadow: 0 0 0 3px rgba(220,38,38,.35); } 30%, 70% { box-shadow: 0 0 0 5px #fde047, 0 0 28px 6px rgba(253,224,71,.75); } }
@media (max-width: 1099px) {
.lg { height: auto; }
.lg-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'actions players' 'talk talk'; }
@@ -151,7 +162,8 @@ button.lg-tile { cursor: pointer; }
.lg-msgs { min-height: 160px; max-height: 300px; }
}
@media (prefers-reduced-motion: reduce) {
.lg-news, .lg-bar .tr i, .lg-tile[aria-pressed='true'], .lg-tile.accused, .lg-card[data-show='true'] { animation: none; }
.lg-news, .lg-bar, .lg-bar .tr i, .lg-bar .ct, .lg-tile[aria-pressed='true'], .lg-tile.accused, .lg-tile.spot, .lg-card[data-show='true'] { animation: none; }
.lg-spot { display: none; }
}
`;
@@ -274,6 +286,9 @@ function News({ v, players }: { v: LiarView; players: Record<string, PublicUser>
);
}
/** Delay between two vote rows appearing (ms). */
const BAR_GAP = 350;
function VoteBars({ e, players }: { e: Extract<PublicEvent, { t: 'vote' }>; players: Record<string, PublicUser> }) {
const rows = Object.entries(e.tally).sort((a, b) => b[1] - a[1]);
const max = Math.max(1, ...rows.map((r) => r[1]));
@@ -282,13 +297,14 @@ function VoteBars({ e, players }: { e: Extract<PublicEvent, { t: 'vote' }>; play
<span className="big">{eventText(e, players)}</span>
{rows.length > 0 && (
<div className="lg-bars" role="list" aria-label="득표">
{rows.map(([id, n]) => (
<div key={id} className="lg-bar" data-top={id === e.accused} role="listitem" aria-label={`${nick(players, id)} ${n}표`}>
{/* Least votes first, so the top one lands last (one row every 0.35 s). */}
{rows.map(([id, n], i) => (
<div key={id} className="lg-bar" data-top={id === e.accused} role="listitem" aria-label={`${nick(players, id)} ${n}표`} style={{ '--d': `${(rows.length - 1 - i) * BAR_GAP}ms` } as CSSProperties}>
<span className="nm">{nick(players, id)}</span>
<span className="tr" aria-hidden>
<i style={{ width: `${(n / max) * 100}%` }} />
</span>
<span>{n}표</span>
<span className="ct">{n}표</span>
</div>
))}
</div>
@@ -308,7 +324,7 @@ function VoteBars({ e, players }: { e: Extract<PublicEvent, { t: 'vote' }>; play
type Pick = { ids: string[]; chosen: string | null; onPick: (id: string) => void } | null;
function Players({ v, players, me, pick, pending }: { v: LiarView; players: Record<string, PublicUser>; me: string | null; pick: Pick; pending: boolean }) {
function Players({ v, players, me, pick, pending, spot }: { v: LiarView; players: Record<string, PublicUser>; me: string | null; pick: Pick; pending: boolean; spot: string | null }) {
const ph = v.phase;
const accused = v.final?.accused ?? ph.liar;
return (
@@ -321,7 +337,7 @@ function Players({ v, players, me, pick, pending }: { v: LiarView; players: Reco
const p = v.players.find((x) => x.id === id)!;
const u = userOf(players, id);
const speaking = ph.speaker === id;
const cls = `lg-tile${id === me ? ' me' : ''}${p.left ? ' left' : ''}${speaking ? ' speaking' : ''}${accused === id ? ' accused' : ''}`;
const cls = `lg-tile${id === me ? ' me' : ''}${p.left ? ' left' : ''}${speaking ? ' speaking' : ''}${spot === id ? ' spot' : accused === id ? ' accused' : ''}`;
const can = pick?.ids.includes(id) ?? false;
const body = (
<>
@@ -677,19 +693,81 @@ const lgSound = {
caught: () => [523, 784].forEach((f, i) => tone(f, 140, 'square', 0.07, i * 120)),
};
/** Sounds for what anyone did: descriptions, votes being cast, results (the room plays win / lose at the end). */
function useLiarSounds(v: LiarView, me: string | null): void {
/** The accused's tile glows; `x/y` (screen px) only when the tile is on screen, for the darkened-room spotlight. */
type Spot = { id: string; x: number | null; y: number | null; key: number };
/**
* Sounds and motion for what anyone did: descriptions, votes being cast, results (the room plays win / lose at the end).
* A result plays out in order: the vote rows come in one by one, then the spotlight falls on the accused, then the
* banners (caught / escaped, the liar's answer, the winner). A newer announcement cancels whatever is still queued.
*/
function useLiarFx(v: LiarView, me: string | null, players: Record<string, PublicUser>, showBanner: (text: string, tone?: BannerTone, sub?: string) => void, setSpot: (s: Spot | null) => void): void {
const prev = useRef(v);
const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
useEffect(() => () => timers.current.forEach(clearTimeout), []);
useEffect(() => {
const p = prev.current;
prev.current = v;
if (p === v) return;
const last = p.events.at(-1)?.n ?? 0;
const fresh = v.events.filter((e) => e.n > last);
if (fresh.some((e) => e.t === 'end')) return;
const acc = fresh.find((e) => e.t === 'accused');
if (acc && acc.t === 'accused') return acc.liar ? lgSound.caught() : sfx.bad();
if (fresh.some((e) => e.t === 'vote')) return sfx.chips(3);
if (fresh.some((e) => e.t !== 'phase' && e.t !== 'left')) {
timers.current.forEach(clearTimeout);
timers.current = [];
const later = (ms: number, f: () => void) => (ms ? void timers.current.push(setTimeout(f, ms)) : f());
const name = (id: string) => `${nick(players, id)}님`;
let t = 0;
const vote = fresh.find((e) => e.t === 'vote');
if (vote) {
const rows = Object.keys(vote.tally).length;
// A soft chip per row as it lands (the rows themselves are timed in CSS).
for (let i = 0; i < Math.min(rows, 8); i++) sfx.chip(i * BAR_GAP + 300);
t = Math.max(1, rows) * BAR_GAP + 350;
if (!vote.accused) {
later(t, () => (vote.round === 1 ? showBanner('동점!', 'gold', '동점인 사람끼리 다시 투표해요') : showBanner('또 동점!', 'dark', '아무도 지목되지 않았어요')));
t += 1500;
}
}
for (const e of fresh) {
if (e.t === 'accused') {
later(t, () => {
const r = document.querySelector(`.lg-tile[data-player="${cssEsc(e.p)}"]`)?.getBoundingClientRect();
const seen = !!r && r.bottom > 0 && r.top < innerHeight && r.right > 0 && r.left < innerWidth;
setSpot({ id: e.p, x: seen ? r.left + r.width / 2 : null, y: seen ? r.top + r.height / 2 : null, key: e.n });
tone(220, 90, 'triangle', 0.08);
tone(220, 90, 'triangle', 0.08, 160);
});
later(t + 1800, () => setSpot(null));
t += 750;
later(t, () => {
if (e.liar) {
lgSound.caught();
showBanner('잡았다!', 'green', `${josa(name(e.p), ['이', '가'])} 라이어였어요`);
} else {
sfx.bad();
showBanner('헛다리!', 'dark', `${josa(name(e.p), ['은', '는'])} 라이어가 아니에요`);
}
});
t += 1500;
} else if (e.t === 'guess') {
later(t, () => {
if (e.correct) {
sfx.alarm();
showBanner('정답!', 'red', `라이어의 답: "${e.text ?? ''}"`);
} else {
sfx.good();
showBanner('땡!', 'green', e.text === null ? '라이어가 답하지 못했어요' : `라이어의 답: "${e.text}"`);
}
});
t += 1500;
} else if (e.t === 'end') {
// The room plays the win / lose sound; this is only the picture.
const liar = v.final?.liar;
later(t, () => showBanner(e.winner === 'liar' ? '라이어 승리!' : '시민 승리!', e.winner === 'liar' ? 'red' : 'blue', liar ? `라이어는 ${nick(players, liar)}님` : undefined));
}
}
return;
}
if (fresh.some((e) => e.t === 'left')) return sfx.whoosh();
const newDesc = v.descriptions.slice(p.descriptions.length);
if (newDesc.some((d) => d.from !== me)) return newDesc.some((d) => d.text === null) ? sfx.tick() : lgSound.said();
@@ -716,7 +794,9 @@ function LiarBoard({ view: v, me, players, act, pending }: BoardProps<LiarView>)
sounds.myTurn();
}
}, [phaseKey]); // eslint-disable-line react-hooks/exhaustive-deps
useLiarSounds(v, me);
const [banner, showBanner] = useBanner();
const [spot, setSpot] = useState<Spot | null>(null);
useLiarFx(v, me, players, showBanner, setSpot);
const pick: Pick = my && ph.kind === 'vote' && my.voteTargets.length ? { ids: my.voteTargets, chosen: my.vote, onPick: (id) => act({ type: 'vote', target: id }) } : null;
const hot = ph.kind === 'guess' || (ph.kind === 'describe' && !!my?.canDescribe);
@@ -744,7 +824,7 @@ function LiarBoard({ view: v, me, players, act, pending }: BoardProps<LiarView>)
{v.final && <FinalReveal v={v} players={players} />}
<div className="lg-grid">
<div className="lg-col lg-players">
<Players v={v} players={players} me={me} pick={pick} pending={pending} />
<Players v={v} players={players} me={me} pick={pick} pending={pending} spot={spot?.id ?? null} />
</div>
<div className="lg-col lg-talk">
<Descriptions v={v} players={players} me={me} />
@@ -757,6 +837,8 @@ function LiarBoard({ view: v, me, players, act, pending }: BoardProps<LiarView>)
<p className="sr-only" aria-live="polite">
{announce}
</p>
{spot && spot.x !== null && <div key={spot.key} className="lg-spot" aria-hidden style={{ '--x': `${spot.x}px`, '--y': `${spot.y}px` } as CSSProperties} />}
{banner}
</div>
);
}