루미큐브·다빈치 코드·마작·라스베가스·부루마불·요트 다이스 소리·애니메이션: 상대·컴퓨터 행동도 화면 변화로 한 번만 울림(처음 들어올 때·재접속은 조용), 타일 놓기·뒤집기, 주사위 굴림, 말 한 칸씩 이동, 점수 통 튀기, 큰 순간 배너
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/** 다빈치 코드 화면 (docs/games/davinci-code.md §9). */
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState, type CSSProperties } from 'react';
|
||||
import type { DavinciGuess, DavinciOptions, DavinciTileView, DavinciView, PhaseKind, TColor, TileValue } from '@bg/games/davinci-code';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -20,6 +20,60 @@ const valueKo = (v: TileValue) => (v === 'joker' ? '조커' : String(v));
|
||||
const faceOf = (v: TileValue) => (v === 'joker' ? '−' : String(v));
|
||||
const hiddenLeft = (row: DavinciTileView[]) => row.filter((t) => !t.revealed).length;
|
||||
|
||||
/** Standing number-tile sounds (synthesized; the site volume is applied by feedback.ts). */
|
||||
const snd = {
|
||||
/** A tile taken from the face-down pile. */
|
||||
draw: () => {
|
||||
noise(120, 0.08, 0, 'bandpass', 1200, 0.7);
|
||||
tone(330, 60, 'triangle', 0.07, 100);
|
||||
},
|
||||
/** A tile slotted into a row: a solid "딸깍". */
|
||||
set: (delay = 0) => {
|
||||
noise(30, 0.15, delay, 'bandpass', 2600, 2);
|
||||
tone(950, 38, 'triangle', 0.09, delay);
|
||||
tone(260, 70, 'sine', 0.08, delay + 10);
|
||||
},
|
||||
/** A tile tipped over face up. */
|
||||
flip: (delay = 0) => {
|
||||
noise(45, 0.11, delay, 'highpass', 3000);
|
||||
tone(620, 70, 'triangle', 0.08, delay + 25, { slideTo: 1240 });
|
||||
},
|
||||
/** Somebody guessed my tile right. */
|
||||
ouch: (delay = 0) => tone(520, 200, 'triangle', 0.1, delay, { slideTo: 300 }),
|
||||
/** A joker goes into a row (only when the viewer can see it is a joker). */
|
||||
joker: (delay = 0) => [1568, 2093, 2637].forEach((f, i) => tone(f, 90, 'triangle', 0.05, delay + i * 60)),
|
||||
/** A player is out. */
|
||||
out: (delay = 0) => [523, 440, 349].forEach((f, i) => tone(f, 170, 'triangle', 0.09, delay + i * 130)),
|
||||
};
|
||||
|
||||
/** A value that shows for `ms` and then clears itself (timer cleaned up on unmount). */
|
||||
function useTimed<T>(): [T | null, (v: T, ms: number) => void] {
|
||||
const [val, setVal] = useState<T | null>(null);
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
||||
useEffect(() => () => clearTimeout(timer.current), []);
|
||||
const set = useCallback((v: T, ms: number) => {
|
||||
clearTimeout(timer.current);
|
||||
setVal(v);
|
||||
timer.current = setTimeout(() => setVal(null), ms);
|
||||
}, []);
|
||||
return [val, set];
|
||||
}
|
||||
|
||||
/** Wraps a number that bumps (anim-bump) whenever it changes after the first render. */
|
||||
function Bump({ value, children }: { value: number; children: React.ReactNode }) {
|
||||
const prev = useRef(value);
|
||||
const n = useRef(0);
|
||||
if (prev.current !== value) {
|
||||
prev.current = value;
|
||||
n.current += 1;
|
||||
}
|
||||
return (
|
||||
<span key={n.current} className={n.current ? 'dv-bump anim-bump' : 'dv-bump'}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function totalMsOf(v: DavinciView): number {
|
||||
if (v.phase === 'chooseStart') return 15_000;
|
||||
if ((v.idle[v.current] ?? 0) >= 3) return 5_000;
|
||||
@@ -46,6 +100,10 @@ function guessLine(g: DavinciGuess, players: Record<string, PublicUser>): string
|
||||
}
|
||||
|
||||
const CSS = `
|
||||
.dv-bump { display: inline-block; }
|
||||
.dv-banner { position: fixed; z-index: 40; top: 34%; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 92vw; text-align: center;
|
||||
padding: 12px 26px; border-radius: 18px; font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 900;
|
||||
background: linear-gradient(160deg, #42454d, #141519); color: #fff; border: 2px solid #050505; box-shadow: 0 4px 0 rgba(0,0,0,.45), 0 12px 30px rgba(0,0,0,.35); }
|
||||
.dv-board { width: 100%; max-width: 980px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; }
|
||||
.dv-opps { display: grid; gap: 10px; }
|
||||
.dv-player { background: var(--surface); border-radius: var(--radius-lg); padding: 10px 12px; box-shadow: var(--shadow); border: 3px solid transparent; }
|
||||
@@ -74,13 +132,16 @@ const CSS = `
|
||||
.dv-tile.secret { outline: 3px dashed var(--primary); outline-offset: 2px; }
|
||||
.dv-tile.sm { --w: 30px; }
|
||||
.dv-tile.lg { --w: 54px; }
|
||||
.dv-tile.hit { animation: dv-flip .5s ease-out, dv-hit 1.2s ease-out; }
|
||||
.dv-tile.miss { animation: dv-flip .5s ease-out, dv-miss 1.2s ease-out; }
|
||||
.dv-tile.new { animation: dv-drop .35s ease-out; }
|
||||
@keyframes dv-flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }
|
||||
.dv-tile.hit { animation: dv-flip .5s ease-out both, dv-hit 1.2s ease-out both; }
|
||||
.dv-tile.miss { animation: dv-flip .5s ease-out both, dv-miss 1.2s ease-out both; animation-delay: var(--anim-delay, 0ms); }
|
||||
.dv-tile.new { animation: dv-drop .38s ease-out both; animation-delay: var(--anim-delay, 0ms); }
|
||||
.dv-tile.shake { animation: anim-shake .45s ease, dv-miss 1.2s ease-out; }
|
||||
.dv-tile.deal { animation: anim-deal .38s cubic-bezier(0.2, 0.8, 0.3, 1.15) both; animation-delay: var(--anim-delay, 0ms); }
|
||||
.dv-tile.reveal { animation: dv-flip .45s ease-out both; animation-delay: var(--anim-delay, 0ms); }
|
||||
@keyframes dv-flip { 0% { transform: perspective(500px) rotateY(90deg); } 60% { transform: perspective(500px) rotateY(-12deg); } 100% { transform: perspective(500px) rotateY(0); } }
|
||||
@keyframes dv-hit { 0%, 60% { box-shadow: 0 0 0 4px #22c55e, 0 0 18px 6px rgba(34,197,94,.7); } 100% { box-shadow: 0 3px 0 rgba(0,0,0,.35); } }
|
||||
@keyframes dv-miss { 0%, 60% { box-shadow: 0 0 0 4px #ef4444, 0 0 18px 6px rgba(239,68,68,.6); } 100% { box-shadow: 0 3px 0 rgba(0,0,0,.35); } }
|
||||
@keyframes dv-drop { 0% { transform: translateY(-14px); opacity: .3; } 100% { transform: translateY(0); opacity: 1; } }
|
||||
@keyframes dv-drop { 0% { transform: translateY(-34px) scale(.85); opacity: .2; } 70% { transform: translateY(3px); opacity: 1; } 100% { transform: translateY(0); } }
|
||||
.dv-pick { background: none; border: 0; padding: 3px; border-radius: 11px; cursor: pointer; color: inherit; }
|
||||
.dv-pick:disabled { cursor: default; }
|
||||
.dv-pick.can { box-shadow: 0 0 0 3px var(--primary); }
|
||||
@@ -136,19 +197,26 @@ const CSS = `
|
||||
.dv-board { max-height: none; overflow: visible; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.dv-tile.hit, .dv-tile.miss, .dv-tile.new { animation: none; }
|
||||
.dv-tile.hit, .dv-tile.miss, .dv-tile.new, .dv-tile.shake, .dv-tile.deal, .dv-tile.reveal { animation: none; }
|
||||
.dv-banner { display: none; }
|
||||
}
|
||||
`;
|
||||
|
||||
// ---------------------------------------------------------------- tiles
|
||||
|
||||
type Fx = 'hit' | 'miss' | 'new';
|
||||
type FxKind = 'hit' | 'miss' | 'new' | 'shake' | 'deal' | 'reveal';
|
||||
/** One tile's animation: kind, start delay, and a sequence number so the same kind can replay. */
|
||||
interface Fx {
|
||||
k: FxKind;
|
||||
d: number;
|
||||
s: number;
|
||||
}
|
||||
|
||||
function Tile({ color, n, revealed, mine, size, fx }: { color: TColor; n?: TileValue; revealed: boolean; mine?: boolean; size?: 'sm' | 'lg'; fx?: Fx }) {
|
||||
const known = n !== undefined;
|
||||
const cls = ['dv-tile', color, known ? '' : 'back', revealed ? 'open' : '', mine && !revealed ? 'secret' : '', size ?? '', fx ?? ''].filter(Boolean).join(' ');
|
||||
const cls = ['dv-tile', color, known ? '' : 'back', revealed ? 'open' : '', mine && !revealed ? 'secret' : '', size ?? '', fx?.k ?? ''].filter(Boolean).join(' ');
|
||||
return (
|
||||
<span className={cls} aria-hidden>
|
||||
<span key={fx?.s ?? 0} className={cls} aria-hidden style={fx ? ({ '--anim-delay': `${fx.d}ms`, '--from-y': '-60px', '--from-x': '0px' } as CSSProperties) : undefined}>
|
||||
{known ? faceOf(n) : <span className="q">?</span>}
|
||||
</span>
|
||||
);
|
||||
@@ -161,6 +229,8 @@ function tileLabel(t: DavinciTileView, pos: number, mine: boolean): string {
|
||||
|
||||
// ---------------------------------------------------------------- board
|
||||
|
||||
const NO_FX = new Map<string, Fx>();
|
||||
|
||||
interface Sel {
|
||||
target: string;
|
||||
index: number;
|
||||
@@ -171,10 +241,12 @@ function DavinciBoard({ view: v, me, players, act, pending, deadline }: BoardPro
|
||||
const myTurn = amPlayer && v.current === me && !!v.alive[me!] && v.phase !== 'chooseStart' && v.phase !== 'finished';
|
||||
const [sel, setSel] = useState<Sel | null>(null);
|
||||
const [val, setVal] = useState<TileValue | null>(null);
|
||||
const [fx, setFx] = useState<Map<string, Fx>>(new Map());
|
||||
const [fx, setFx] = useTimed<Map<string, Fx>>();
|
||||
const [pendFx, setPendFx] = useTimed<Fx>();
|
||||
const [banner, setBanner] = useTimed<{ text: string; s: number }>();
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const prevHist = useRef(v.history.length);
|
||||
const prevPlaced = useRef(JSON.stringify(v.lastPlaced));
|
||||
const seq = useRef(0);
|
||||
const snap = useRef<{ hist: number; phase: PhaseKind; pending: boolean; elim: number; picked: number; rows: Record<string, boolean[]> } | null>(null);
|
||||
const prevTurn = useRef(`${v.current}|${v.phase === 'chooseStart'}`);
|
||||
|
||||
const resetKey = `${v.phase}|${v.current}|${v.history.length}`;
|
||||
@@ -183,30 +255,89 @@ function DavinciBoard({ view: v, me, players, act, pending, deadline }: BoardPro
|
||||
setVal(null);
|
||||
}, [resetKey]);
|
||||
|
||||
// Effects + screen-reader text for new guesses and newly placed tiles.
|
||||
// Sounds, tile animations and screen-reader text for what anybody did, from view changes only
|
||||
// (the first view after mounting is just recorded, so joining / reconnecting is silent).
|
||||
useEffect(() => {
|
||||
const placedNow = JSON.stringify(v.lastPlaced);
|
||||
const now = {
|
||||
hist: v.history.length,
|
||||
phase: v.phase,
|
||||
pending: !!v.pending,
|
||||
elim: v.eliminationOrder.length,
|
||||
picked: v.picked ? Object.values(v.picked).filter(Boolean).length : 0,
|
||||
rows: Object.fromEntries(v.seats.map((p) => [p, (v.rows[p] ?? []).map((t) => t.revealed)])),
|
||||
};
|
||||
const prev = snap.current;
|
||||
snap.current = now;
|
||||
if (!prev) return;
|
||||
const next = new Map<string, Fx>();
|
||||
if (v.history.length > prevHist.current) {
|
||||
const g = v.history[v.history.length - 1]!;
|
||||
if (g.correct) next.set(`${g.target}:${g.index}`, 'hit');
|
||||
else if (v.lastPlaced && v.lastPlaced.player === g.by && v.lastPlaced.revealed) next.set(`${g.by}:${v.lastPlaced.index}`, 'miss');
|
||||
setAnnounce(
|
||||
`${nick(players, g.by)}님이 ${nick(players, g.target)}님 ${g.index + 1}번째 타일을 ${valueKo(g.said)}(으)로 추리해서 ${g.correct ? '맞혔어요' : '틀렸어요'}.`,
|
||||
);
|
||||
if (g.correct && g.by === me) haptic(30);
|
||||
} else if (placedNow !== prevPlaced.current && v.lastPlaced) {
|
||||
next.set(`${v.lastPlaced.player}:${v.lastPlaced.index}`, v.lastPlaced.revealed ? 'miss' : 'new');
|
||||
const put = (key: string, k: FxKind, d = 0) => next.set(key, { k, d, s: ++seq.current });
|
||||
if (prev.phase === 'chooseStart' && v.phase !== 'chooseStart') {
|
||||
// Start tiles dealt into every row.
|
||||
let k = 0;
|
||||
for (const p of v.seats) (v.rows[p] ?? []).forEach((_, i) => put(`${p}:${i}`, 'deal', Math.min(k++ * 60, 900)));
|
||||
sfx.deal(Math.min(k, 10), 60);
|
||||
} else {
|
||||
if (v.phase === 'chooseStart' && now.picked > prev.picked) sfx.click();
|
||||
if (!prev.pending && v.pending) {
|
||||
snd.draw();
|
||||
setPendFx({ k: 'deal', d: 0, s: ++seq.current }, 700);
|
||||
}
|
||||
let t = 0; // delay of the next sound, so a miss and the tile it costs are heard one after another
|
||||
const g = now.hist === prev.hist + 1 ? v.history[v.history.length - 1]! : null;
|
||||
if (g) {
|
||||
if (g.correct) {
|
||||
put(`${g.target}:${g.index}`, 'hit');
|
||||
snd.flip();
|
||||
if (g.target === me) snd.ouch(140);
|
||||
else sfx.good();
|
||||
if (g.by === me) haptic(30);
|
||||
} else {
|
||||
put(`${g.target}:${g.index}`, 'shake');
|
||||
sfx.bad();
|
||||
t = 320;
|
||||
}
|
||||
setAnnounce(`${nick(players, g.by)}님이 ${nick(players, g.target)}님 ${g.index + 1}번째 타일을 ${valueKo(g.said)}(으)로 추리해서 ${g.correct ? '맞혔어요' : '틀렸어요'}.`);
|
||||
}
|
||||
for (const p of v.seats) {
|
||||
const a = prev.rows[p] ?? [];
|
||||
const b = now.rows[p] ?? [];
|
||||
const lp = v.lastPlaced;
|
||||
if (b.length === a.length + 1 && lp?.player === p) {
|
||||
// A tile slotted into the row (after 멈추기, a miss, a joker, or at the game end).
|
||||
put(`${p}:${lp.index}`, lp.revealed ? 'miss' : 'new', t);
|
||||
if (lp.revealed) snd.flip(t);
|
||||
else snd.set(t);
|
||||
if (v.rows[p]?.[lp.index]?.n === 'joker') snd.joker(t + 90);
|
||||
} else if (b.length === a.length) {
|
||||
// Own tile shown after a miss with an empty pile, or all tiles opened when someone leaves.
|
||||
let opened = 0;
|
||||
b.forEach((r, i) => {
|
||||
if (r && !a[i] && !(g?.correct && g.target === p && g.index === i)) put(`${p}:${i}`, 'miss', t + opened++ * 80);
|
||||
});
|
||||
if (opened) snd.flip(t);
|
||||
}
|
||||
}
|
||||
if (now.elim > prev.elim) {
|
||||
const out = v.eliminationOrder[v.eliminationOrder.length - 1]!;
|
||||
if (!v.left[out]) {
|
||||
setBanner({ text: out === me ? '내 숨은 타일이 다 드러났어요' : `${nick(players, out)}님 탈락!`, s: ++seq.current }, 1700);
|
||||
// The match result sound itself is played by the room page.
|
||||
if (v.phase !== 'finished') snd.out(t + 250);
|
||||
}
|
||||
}
|
||||
if (prev.phase !== 'finished' && v.phase === 'finished') {
|
||||
// Game over: every tile that was still hidden from me is turned over.
|
||||
let k = 0;
|
||||
for (const p of v.seats) {
|
||||
if (p === me) continue;
|
||||
(v.rows[p] ?? []).forEach((r, i) => {
|
||||
if (!r.revealed && !next.has(`${p}:${i}`)) put(`${p}:${i}`, 'reveal', Math.min(400 + k++ * 50, 1000));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
prevHist.current = v.history.length;
|
||||
prevPlaced.current = placedNow;
|
||||
if (next.size) {
|
||||
setFx(next);
|
||||
const t = setTimeout(() => setFx(new Map()), 1300);
|
||||
return () => clearTimeout(t);
|
||||
}
|
||||
return undefined;
|
||||
}, [v.history.length, JSON.stringify(v.lastPlaced)]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
if (next.size) setFx(next, 1700);
|
||||
}, [v]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
const key = `${v.current}|${v.phase === 'chooseStart'}`;
|
||||
@@ -222,6 +353,7 @@ function DavinciBoard({ view: v, me, players, act, pending, deadline }: BoardPro
|
||||
|
||||
const canGuess = myTurn && v.phase === 'guess' && !pending;
|
||||
const pick = (target: string, index: number) => {
|
||||
sfx.select();
|
||||
if (sel && sel.target === target && sel.index === index) {
|
||||
setSel(null);
|
||||
setVal(null);
|
||||
@@ -236,17 +368,22 @@ function DavinciBoard({ view: v, me, players, act, pending, deadline }: BoardPro
|
||||
<style>{CSS}</style>
|
||||
<div className="dv-opps">
|
||||
{opponentsOf(v, me).map((p) => (
|
||||
<PlayerRow key={p} id={p} view={v} me={me} players={players} deadline={deadline} fx={fx} canPick={canGuess && !!v.alive[p]} sel={sel} onPick={pick} />
|
||||
<PlayerRow key={p} id={p} view={v} me={me} players={players} deadline={deadline} fx={fx ?? NO_FX} canPick={canGuess && !!v.alive[p]} sel={sel} onPick={pick} />
|
||||
))}
|
||||
</div>
|
||||
<div className="dv-mid">
|
||||
<Center view={v} me={me} players={players} act={act} pending={pending} myTurn={myTurn} />
|
||||
<Center view={v} me={me} players={players} act={act} pending={pending} myTurn={myTurn} pendFx={pendFx} />
|
||||
<ActionPanel view={v} me={me} players={players} act={act} pending={pending} myTurn={myTurn} sel={sel} val={val} setVal={setVal} onCancel={() => (setSel(null), setVal(null))} />
|
||||
</div>
|
||||
{amPlayer && <MyRow view={v} me={me!} players={players} act={act} pending={pending} myTurn={myTurn} deadline={deadline} fx={fx} />}
|
||||
{amPlayer && <MyRow view={v} me={me!} players={players} act={act} pending={pending} myTurn={myTurn} deadline={deadline} fx={fx ?? NO_FX} />}
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{banner && (
|
||||
<div key={banner.s} className="dv-banner anim-banner" aria-hidden>
|
||||
{banner.text}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -271,7 +408,12 @@ function PlayerHead({ id, view: v, me, players, deadline }: { id: string; view:
|
||||
{v.alive[id] && (v.idle[id] ?? 0) >= 3 && <span className="dv-badge">자리 비움</span>}
|
||||
{v.phase === 'chooseStart' && v.alive[id] && <span className={`dv-badge${choosing ? '' : ' ok'}`}>{choosing ? '고르는 중' : '다 골랐어요'}</span>}
|
||||
<span className="small muted" style={{ marginLeft: 'auto' }}>
|
||||
{v.phase !== 'chooseStart' && `숨은 타일 ${hiddenLeft(row)}개 · `}맞힘 {st.correct}/{st.guesses}
|
||||
{v.phase !== 'chooseStart' && (
|
||||
<>
|
||||
숨은 타일 <Bump value={hiddenLeft(row)}>{hiddenLeft(row)}</Bump>개 ·{' '}
|
||||
</>
|
||||
)}
|
||||
맞힘 <Bump value={st.correct}>{st.correct}</Bump>/{st.guesses}
|
||||
</span>
|
||||
{(isTurn || choosing) && <TurnTimer deadline={deadline} totalMs={totalMsOf(v)} mine={id === me} size={30} />}
|
||||
</div>
|
||||
@@ -303,7 +445,7 @@ function PlayerRow({
|
||||
const isTurn = v.phase !== 'finished' && v.phase !== 'chooseStart' && v.current === id;
|
||||
const name = nick(players, id);
|
||||
return (
|
||||
<section className={`dv-player${isTurn ? ' turn' : ''}${v.alive[id] || v.phase === 'finished' ? '' : ' out'}`} aria-label={`${name}님 타일`}>
|
||||
<section className={`dv-player${isTurn ? ' turn anim-glow' : ''}${v.alive[id] || v.phase === 'finished' ? '' : ' out'}`} aria-label={`${name}님 타일`}>
|
||||
<PlayerHead id={id} view={v} me={me} players={players} deadline={deadline} />
|
||||
<div className="dv-row" role="group" aria-label={`${name}님 타일 줄`}>
|
||||
{row.length === 0 && <span className="small muted">{v.phase === 'chooseStart' ? '시작 타일을 기다리는 중이에요' : '타일이 없어요'}</span>}
|
||||
@@ -363,7 +505,7 @@ function MyRow({
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<section className={`dv-player dv-me${isTurn ? ' turn' : ''}${v.alive[me] || v.phase === 'finished' ? '' : ' out'}`} aria-label="내 타일">
|
||||
<section className={`dv-player dv-me${isTurn ? ' turn anim-glow' : ''}${v.alive[me] || v.phase === 'finished' ? '' : ' out'}`} aria-label="내 타일">
|
||||
<PlayerHead id={me} view={v} me={me} players={players} deadline={deadline} />
|
||||
<div className="dv-row" role="group" aria-label="내 타일 줄">
|
||||
{row.length === 0 && <span className="small muted">{v.phase === 'chooseStart' ? '시작 타일 색을 고르면 여기에 놓여요' : '타일이 없어요'}</span>}
|
||||
@@ -403,7 +545,23 @@ function MyRow({
|
||||
);
|
||||
}
|
||||
|
||||
function Center({ view: v, me, players, act, pending, myTurn }: { view: DavinciView; me: string | null; players: Record<string, PublicUser>; act: (a: unknown) => void; pending: boolean; myTurn: boolean }) {
|
||||
function Center({
|
||||
view: v,
|
||||
me,
|
||||
players,
|
||||
act,
|
||||
pending,
|
||||
myTurn,
|
||||
pendFx,
|
||||
}: {
|
||||
view: DavinciView;
|
||||
me: string | null;
|
||||
players: Record<string, PublicUser>;
|
||||
act: (a: unknown) => void;
|
||||
pending: boolean;
|
||||
myTurn: boolean;
|
||||
pendFx: Fx | null;
|
||||
}) {
|
||||
const drawing = myTurn && v.phase === 'draw' && !pending;
|
||||
const total = v.pool.black + v.pool.white;
|
||||
const last = v.history[v.history.length - 1];
|
||||
@@ -434,7 +592,7 @@ function Center({ view: v, me, players, act, pending, myTurn }: { view: DavinciV
|
||||
)}
|
||||
</span>
|
||||
<span>
|
||||
{COLOR_SHORT[c]} {v.pool[c]}개
|
||||
{COLOR_SHORT[c]} <Bump value={v.pool[c]}>{v.pool[c]}</Bump>개
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
@@ -444,13 +602,13 @@ function Center({ view: v, me, players, act, pending, myTurn }: { view: DavinciV
|
||||
<button type="button" className={`dv-pile${drawing ? ' can' : ''}`} disabled={!drawing} aria-label={`타일 가져오기, ${total}개 남음`} onClick={() => act({ type: 'draw' })}>
|
||||
<span>타일 가져오기</span>
|
||||
<span className="small">
|
||||
남은 타일 {total}개 (검정 {v.pool.black} · 흰색 {v.pool.white})
|
||||
남은 타일 <Bump value={total}>{total}</Bump>개 (검정 {v.pool.black} · 흰색 {v.pool.white})
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
{v.pending ? (
|
||||
<div className="dv-pending">
|
||||
<Tile color={v.pending.color} n={v.pending.n} revealed={false} mine={v.current === me} />
|
||||
<Tile color={v.pending.color} n={v.pending.n} revealed={false} mine={v.current === me} fx={pendFx ?? undefined} />
|
||||
<span>
|
||||
{v.current === me ? '내가 가져온 타일' : `${nick(players, v.current)}님이 가져온 타일`}
|
||||
<br />
|
||||
@@ -633,7 +791,10 @@ function NumberPad({
|
||||
className={`${x === 'joker' ? 'joker' : ''}${(v.options.deductionHelper || seen.has(`${tile.color}:${x}`)) && impossible(x) ? ' unlikely' : ''}`}
|
||||
aria-pressed={val === x}
|
||||
aria-label={x === 'joker' ? '조커' : String(x)}
|
||||
onClick={() => setVal(x)}
|
||||
onClick={() => {
|
||||
sfx.click();
|
||||
setVal(x);
|
||||
}}
|
||||
>
|
||||
{x === 'joker' ? '조커 (−)' : x}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user