움직임 더하기 2차: 루미큐브·마피아·라이어·바둑·클루·오목·포커
- 루미큐브: 옮긴 타일이 원래 자리에서 미끄러져 가고, 남이 바닥에 낸 타일은 그 사람 칸에서 날아옴. 가져온 타일은 남은 타일 더미에서 받침대로 날아오고, 남이 가져가면 뒤집힌 타일이 그 사람 칸으로 날아감. 배너를 공통 useBanner로 바꾸고 "루미큐브!"·"판 끝"·승리 배너 추가 - 마피아: 밤에는 화면이 남색으로 어두워지며 달, 아침에는 해가 떠오름. 득표 막대가 한 줄씩 자라고, 탈락한 사람 칸이 뒤집히며 흐려짐. 탈락·살았다·버텼다·조용한 밤·이긴 팀 배너를 차례로 - 라이어: 득표가 한 줄씩 나온 뒤 지목된 사람에게 스포트라이트와 흔들림, "잡았다!"/"헛다리!"·동점·정답/땡·승리 배너 - 바둑: 패스·계가 배너, 계가 때 집 표시가 차례로 나타나고 결과 점수가 0부터 올라감, 승리 배너 - 클루: 말과 흉기가 새 자리로 튀어 오르며 미끄러져 감, 추리한 세 장이 사건 봉투로 날아가고, 보여 준 카드는 뒤집히며(남에게는 뒷면 카드가 날아감) - 오목: 금수 자리를 누르면 빨간 ✕와 "금수" 글자, 판이 흔들림(키보드 Enter도 같은 안내). "오목!"·승패 배너 - 포커: 쇼다운·인디언 이마 카드가 뒷면이 돌아간 뒤 앞면이 돌아 나오는 진짜 뒤집기로 - 모두 누구의 행동이든 화면 변화에 반응하고, 클릭을 막지 않으며, 동작 줄이기 설정을 따름. 게임 문서 UI 절에 반영 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/** 클루 화면 (docs/games/clue.md §9). */
|
||||
import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties } from 'react';
|
||||
import type { ClueOptions, ClueView, SuggestionView } from '@bg/games/clue';
|
||||
import {
|
||||
PASSAGES,
|
||||
@@ -24,6 +24,7 @@ import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { haptic, sfx, sounds, tone } from '../../lib/feedback';
|
||||
import { cssEsc, flyGhost, reducedMotion } from '../card-fx';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -191,20 +192,56 @@ button.cl-card.can { box-shadow: 0 0 0 3px var(--primary); }
|
||||
.cl-note { grid-template-columns: minmax(0, 1fr); }
|
||||
.cl-card { width: 66px; min-height: 78px; }
|
||||
}
|
||||
/* Tokens / weapons on the map are lifted above the rooms while they slide (see slideFrom). */
|
||||
.cl-map [data-tok], .cl-map [data-weap] { position: relative; }
|
||||
.fx-ghost.cl-ghost { display: flex; align-items: center; justify-content: center; border-radius: 8px; background: linear-gradient(160deg, #fffaf0, #f1e6cf);
|
||||
border: 2px solid #b79c6b; color: #2b2118; font: 800 1.1rem/1 system-ui, sans-serif; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
|
||||
.fx-ghost.cl-ghost.back { background: repeating-linear-gradient(45deg, #7c2d12 0 6px, #9a3412 6px 12px); border-color: #fff7ed; }
|
||||
@media (prefers-reduced-motion: reduce) { .cl-card.new, .cl-room.landed { animation: none; } }
|
||||
`;
|
||||
|
||||
// ---------------------------------------------------------------- small pieces
|
||||
|
||||
function Token({ x, me, pop }: { x: Suspect; me?: boolean; pop?: boolean }) {
|
||||
/**
|
||||
* Slides an element that just moved from (dx, dy) px away back to its place in a little hop, above the other rooms.
|
||||
* Returns whether it animated (the caller staggers several).
|
||||
*/
|
||||
function slideFrom(el: HTMLElement | null, dx: number, dy: number, delay: number): boolean {
|
||||
const d = Math.hypot(dx, dy);
|
||||
if (!el || d < 4 || reducedMotion() || typeof el.animate !== 'function') return false;
|
||||
// The CSS pop of a freshly mounted token would scale the slide; the slide replaces it.
|
||||
el.getAnimations().forEach((a) => a.cancel());
|
||||
el.style.zIndex = '4';
|
||||
const lift = Math.min(36, 10 + d * 0.15);
|
||||
const anim = el.animate(
|
||||
[
|
||||
{ transform: `translate(${dx}px, ${dy}px)` },
|
||||
{ transform: `translate(${dx / 2}px, ${dy / 2 - lift}px) scale(1.2)`, offset: 0.5 },
|
||||
{ transform: 'translate(0px, 0px)' },
|
||||
],
|
||||
{ duration: Math.min(720, 300 + d * 0.8), delay, easing: 'ease-in-out', fill: 'backwards' },
|
||||
);
|
||||
const done = () => (el.style.zIndex = '');
|
||||
anim.onfinish = done;
|
||||
anim.oncancel = done;
|
||||
return true;
|
||||
}
|
||||
|
||||
function Token({ x, me, pop, onMap }: { x: Suspect; me?: boolean; pop?: boolean; onMap?: boolean }) {
|
||||
return (
|
||||
<span className={`cl-tok${x === 'white' ? ' light' : ''}${me ? ' me' : ''}${pop ? ' anim-pop' : ''}`} style={{ background: SUSPECT_COLOR[x] }} title={SUSPECT_KO[x]} aria-hidden>
|
||||
<span
|
||||
className={`cl-tok${x === 'white' ? ' light' : ''}${me ? ' me' : ''}${pop ? ' anim-pop' : ''}`}
|
||||
style={{ background: SUSPECT_COLOR[x] }}
|
||||
title={SUSPECT_KO[x]}
|
||||
data-tok={onMap ? x : undefined}
|
||||
aria-hidden
|
||||
>
|
||||
{SUSPECT_SHORT[x]}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function Card({ id, onClick, can, fresh, label, delay }: { id: string; onClick?: () => void; can?: boolean; fresh?: boolean; label?: string; delay?: number }) {
|
||||
function Card({ id, onClick, can, fresh, flip, label, delay }: { id: string; onClick?: () => void; can?: boolean; fresh?: boolean; flip?: boolean; label?: string; delay?: number }) {
|
||||
const x = itemOf(id);
|
||||
const cat = categoryOf(x);
|
||||
const body = (
|
||||
@@ -224,7 +261,7 @@ function Card({ id, onClick, can, fresh, label, delay }: { id: string; onClick?:
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<span className={`cl-card${fresh ? ' new' : ''}`} role="img" aria-label={aria} style={delay ? ({ '--anim-delay': `${delay}ms` } as CSSProperties) : undefined}>
|
||||
<span className={`cl-card${flip ? ' anim-flip' : fresh ? ' new' : ''}`} role="img" aria-label={aria} style={delay ? ({ '--anim-delay': `${delay}ms` } as CSSProperties) : undefined}>
|
||||
{body}
|
||||
</span>
|
||||
);
|
||||
@@ -245,6 +282,32 @@ function ClueBoard({ view: v, me, players, act, pending }: BoardProps<ClueView>)
|
||||
|
||||
useEffect(() => setSel(null), [v.phase.kind, v.current, v.turnNo]);
|
||||
|
||||
// Tokens and weapons slide on the map from where they were (anyone's move, a suggestion pulling them into a room).
|
||||
// Places are kept relative to the map, so scrolling between two moves does not matter.
|
||||
const placeSig = JSON.stringify([v.pos, v.weaponAt]);
|
||||
const places = useRef<Map<string, { x: number; y: number }> | null>(null);
|
||||
useLayoutEffect(() => {
|
||||
const map = document.querySelector('.cl-map');
|
||||
if (!map) return;
|
||||
const m = map.getBoundingClientRect();
|
||||
const before = places.current;
|
||||
const now = new Map<string, { x: number; y: number }>();
|
||||
map.querySelectorAll<HTMLElement>('[data-tok], [data-weap]').forEach((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
now.set(el.dataset.tok ? `t:${el.dataset.tok}` : `w:${el.dataset.weap}`, { x: r.left + r.width / 2 - m.left, y: r.top + r.height / 2 - m.top });
|
||||
});
|
||||
places.current = now;
|
||||
if (!before) return;
|
||||
let k = 0;
|
||||
for (const [key, at] of now) {
|
||||
const was = before.get(key);
|
||||
if (!was) continue;
|
||||
const [kind, id] = [key.slice(0, 1), key.slice(2)];
|
||||
const el = map.querySelector<HTMLElement>(kind === 't' ? `[data-tok="${cssEsc(id)}"]` : `[data-weap="${cssEsc(id)}"]`);
|
||||
if (slideFrom(el, was.x - at.x, was.y - at.y, k * 90)) k++;
|
||||
}
|
||||
}, [placeSig]);
|
||||
|
||||
// Sounds and highlights for what anyone just did: dice, moves, passages, suggestions, answers, accusations.
|
||||
useEffect(() => {
|
||||
const p = prevView.current;
|
||||
@@ -270,9 +333,23 @@ function ClueBoard({ view: v, me, players, act, pending }: BoardProps<ClueView>)
|
||||
if (sgNew) clSound.suggest();
|
||||
const lastNow = lastOf(v.suggestions);
|
||||
const lastPrev = lastOf(p.suggestions);
|
||||
const tokOf = (player: string) => {
|
||||
const x = v.suspectOf[player];
|
||||
return x ? document.querySelector(`.cl-map [data-tok="${cssEsc(x)}"]`) : null;
|
||||
};
|
||||
// The three suggested cards fly from the suggester's token into the case file in the middle.
|
||||
if (sgNew && lastNow) {
|
||||
const from = tokOf(lastNow.by);
|
||||
const mid = document.querySelector('.cl-mid');
|
||||
[SUSPECT_SHORT[lastNow.suspect], WEAPON_ICON[lastNow.weapon], ROOM_ICON[lastNow.room]].forEach((label, i) =>
|
||||
flyGhost(from, mid, { label, className: 'cl-ghost', delay: 250 + i * 140, ms: 520 }),
|
||||
);
|
||||
}
|
||||
if (lastNow && !sgNew && lastPrev && v.suggestions.length === p.suggestions.length && !lastPrev.refuter && lastNow.refuter) {
|
||||
if (lastNow.shown && (lastNow.by === me || lastNow.refuter === me)) sfx.cardFlip();
|
||||
else sfx.cardDeal();
|
||||
// Everyone else sees a face-down card going from the refuter to the suggester (mine flips open in the panel).
|
||||
if (lastNow.by !== me) flyGhost(tokOf(lastNow.refuter), tokOf(lastNow.by), { className: 'cl-ghost back', ms: 520 });
|
||||
}
|
||||
if (lastNow && p.phase.kind === 'refute' && v.phase.kind !== 'refute' && !lastNow.refuter) clSound.noneShown();
|
||||
if (lastNow && sgNew && v.phase.kind === 'afterSuggest' && !lastNow.refuter) clSound.noneShown();
|
||||
@@ -404,10 +481,10 @@ function Mansion({
|
||||
{can && !free && d !== undefined && <span className="cl-dist">{d}칸</span>}
|
||||
<span className="cl-things">
|
||||
{toks.map((x) => (
|
||||
<Token key={x} x={x} me={x === mySuspect} pop />
|
||||
<Token key={x} x={x} me={x === mySuspect} pop onMap />
|
||||
))}
|
||||
{weaps.map((w) => (
|
||||
<span key={w} className="cl-weap anim-pop" title={WEAPON_KO[w]} aria-hidden>
|
||||
<span key={w} className="cl-weap anim-pop" title={WEAPON_KO[w]} data-weap={w} aria-hidden>
|
||||
{WEAPON_ICON[w]}
|
||||
</span>
|
||||
))}
|
||||
@@ -439,7 +516,7 @@ function Mansion({
|
||||
const p = owner(x);
|
||||
return (
|
||||
<li key={x} style={p ? undefined : { opacity: 0.6 }} aria-label={`${SUSPECT_KO[x]}${p ? '' : '(맡은 사람 없음)'}: ${hallwayText(v.pos[x])}`}>
|
||||
<Token key={posKey(v.pos[x])} x={x} me={x === mySuspect} pop />
|
||||
<Token key={posKey(v.pos[x])} x={x} me={x === mySuspect} pop onMap />
|
||||
<span aria-hidden>{hallwayText(v.pos[x])}</span>
|
||||
</li>
|
||||
);
|
||||
@@ -548,7 +625,7 @@ function LastResult({ view: v, me, players }: { view: ClueView; me: string | nul
|
||||
{last.refuter ? (
|
||||
last.shown ? (
|
||||
<div className="row" style={{ gap: 10, alignItems: 'center' }}>
|
||||
<Card id={last.shown} fresh label={`${last.refuter === me ? '내가 보여 준' : `${nick(players, last.refuter)}님이 보여 준`} 카드: ${ITEM_KO[itemOf(last.shown)]}`} />
|
||||
<Card id={last.shown} flip label={`${last.refuter === me ? '내가 보여 준' : `${nick(players, last.refuter)}님이 보여 준`} 카드: ${ITEM_KO[itemOf(last.shown)]}`} />
|
||||
<span>
|
||||
<strong>{last.refuter === me ? `내가 ${nick(players, last.by)}님에게 보여 준 카드` : `${nick(players, last.refuter)}님이 보여 준 카드`}</strong>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user