루미큐브·다빈치 코드·마작·라스베가스·부루마불·요트 다이스 소리·애니메이션: 상대·컴퓨터 행동도 화면 변화로 한 번만 울림(처음 들어올 때·재접속은 조용), 타일 놓기·뒤집기, 주사위 굴림, 말 한 칸씩 이동, 점수 통 튀기, 큰 순간 배너
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/** 라스베가스 화면 (docs/games/las-vegas.md §9). Bills are play points of this room only (docs/04 §6). */
|
||||
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react';
|
||||
import type { LasVegasChoice, LasVegasOptions, LasVegasPayoutView, LasVegasView } from '@bg/games/las-vegas';
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar, ConfirmSheet } from '../../components/ui';
|
||||
import { TurnTimer } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { haptic, noise, sfx, tone } from '../../lib/feedback';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -33,6 +33,65 @@ const reducedMotion = () => typeof matchMedia !== 'undefined' && matchMedia('(pr
|
||||
const seatColor = (v: LasVegasView, owner: string) => (owner === HOUSE ? '#ffffff' : (COLORS[v.seats.indexOf(owner)] ?? '#888'));
|
||||
const initial = (players: Record<string, PublicUser>, id: string) => (id === HOUSE ? '흰' : ([...nick(players, id)][0] ?? '?'));
|
||||
|
||||
// ---------------------------------------------------------------- sounds (docs/games/las-vegas.md §9 소리·움직임)
|
||||
|
||||
/** A handful of dice shaken, then clacking down as the tumble animation ends. */
|
||||
function rollSound(n: number, animated: boolean) {
|
||||
if (!animated) return sfx.dice();
|
||||
for (let i = 0; i < 8; i++) noise(30, 0.1, i * 48, 'bandpass', 1500 + (i % 3) * 380, 3);
|
||||
const land = ROLL_MS - 120;
|
||||
for (let i = 0; i < Math.min(n, 6); i++) {
|
||||
noise(40, 0.12, land + i * 24, 'lowpass', 1100);
|
||||
tone(640 + i * 60, 28, 'triangle', 0.05, land + i * 24);
|
||||
}
|
||||
}
|
||||
/** Dice pushed onto a casino card, one soft knock each. */
|
||||
function placeSound(n: number) {
|
||||
for (let i = 0; i < Math.min(n, 6); i++) {
|
||||
tone(820 - i * 30, 40, 'triangle', 0.1, i * 55);
|
||||
noise(40, 0.09, i * 55, 'lowpass', 1300);
|
||||
}
|
||||
}
|
||||
/** "Uh-oh": the placement made a tie on that casino. */
|
||||
function tieSound(delay: number) {
|
||||
tone(330, 90, 'square', 0.05, delay);
|
||||
tone(294, 150, 'square', 0.05, delay + 110);
|
||||
}
|
||||
/** Round settlement: ties knocked out, bills handed out (count only, never amounts), a cash chime if I was paid. */
|
||||
function settleSound(delay: number, ties: number, bills: number, mine: boolean, refill: boolean) {
|
||||
let t = delay;
|
||||
if (ties) {
|
||||
tone(600, 80, 'square', 0.06, t);
|
||||
tone(300, 140, 'triangle', 0.12, t + 60);
|
||||
noise(120, 0.1, t, 'lowpass', 700);
|
||||
t += 260;
|
||||
}
|
||||
const n = Math.min(bills, 6);
|
||||
for (let i = 0; i < n; i++) noise(80, 0.12, t + i * 80, 'bandpass', 2000 + (i % 3) * 300, 0.8);
|
||||
t += n * 80;
|
||||
if (mine) for (let i = 0; i < 6; i++) tone(2200 + i * 140, 50, 'triangle', 0.05, t + i * 45);
|
||||
// New bills dealt onto the casinos for the next round.
|
||||
if (refill) for (let i = 0; i < 6; i++) noise(60, 0.08, t + 500 + i * 60, 'bandpass', 2400, 0.8);
|
||||
}
|
||||
/** "Your turn" chime (the room page already plays one when the tab is hidden). */
|
||||
function turnCue(delay: number) {
|
||||
tone(660, 120, 'sine', 0.13, delay);
|
||||
tone(880, 160, 'sine', 0.13, delay + 120);
|
||||
}
|
||||
|
||||
/** Wraps a number that should bump when it changes (not on the first render). */
|
||||
function Bump({ value, children }: { value: number | null; children: ReactNode }) {
|
||||
const r = useRef({ v: value, n: 0 });
|
||||
if (r.current.v !== value) r.current = { v: value, n: r.current.n + 1 };
|
||||
return (
|
||||
<span key={r.current.n} className={r.current.n ? 'anim-bump' : undefined} style={{ display: 'inline-block' }}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
const vars = (o: Record<string, string>) => o as CSSProperties;
|
||||
|
||||
const CSS = `
|
||||
.lv-wrap { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 10px; }
|
||||
.lv-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; }
|
||||
@@ -69,6 +128,7 @@ button.lv-casino:hover { border-color: var(--primary); }
|
||||
.lv-tag.none { background: var(--surface-2); color: var(--text-sub); border: 1px solid var(--border); }
|
||||
@keyframes lv-hit { 0% { transform: scale(1); } 40% { transform: scale(1.05); box-shadow: 0 0 0 6px var(--primary-soft); } 100% { transform: scale(1); } }
|
||||
.lv-casino.hit { animation: lv-hit .55s ease-out; }
|
||||
.lv-casino.hit.clash { animation: anim-shake .45s ease; border-color: var(--warning); }
|
||||
.lv-lower { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; align-items: start; }
|
||||
.lv-tray { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
|
||||
.lv-groups { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
|
||||
@@ -99,7 +159,12 @@ button.lv-casino:hover { border-color: var(--primary); }
|
||||
.lv-tieout { display: inline-flex; align-items: center; gap: 3px; color: var(--warning); font-weight: 800; }
|
||||
.lv-tieout .lv-dot { opacity: .55; }
|
||||
@keyframes lv-poof { 0% { transform: scale(1.4); opacity: 0; } 50% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
|
||||
.lv-fresh .lv-tieout, .lv-fresh .lv-chip { animation: lv-poof .6s ease-out both; }
|
||||
.lv-fresh .lv-tieout { animation: lv-poof .3s ease-out both, anim-shake .45s ease .3s; animation-delay: var(--anim-delay, 0ms), calc(var(--anim-delay, 0ms) + .3s); }
|
||||
.lv-fresh .lv-pbody > .lv-chip { --from-y: -36px; animation: anim-deal .38s cubic-bezier(0.2, 0.8, 0.3, 1.15) both; animation-delay: var(--anim-delay, 0ms); }
|
||||
.lv-banner { position: fixed; inset: 0; z-index: 30; pointer-events: none; display: flex; align-items: center; justify-content: center; padding-bottom: 18vh; }
|
||||
.lv-banner > div { font-size: clamp(1.8rem, 7vw, 2.8rem); font-weight: 900; line-height: 1.15; text-align: center; white-space: nowrap;
|
||||
color: #fde047; text-shadow: 0 4px 12px rgba(0,0,0,.55), 0 0 2px #854d0e; }
|
||||
.lv-banner small { display: block; font-size: .5em; color: #fff; }
|
||||
.lv-pname { max-width: 84px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
|
||||
.lv-final { padding: 12px; }
|
||||
.lv-final table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
|
||||
@@ -127,7 +192,7 @@ button.lv-casino:hover { border-color: var(--primary); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lv-casino, .lv-casino.sel { transition: none; transform: none; }
|
||||
.lv-casino.hit, .lv-die.rolling, .lv-fresh .lv-tieout, .lv-fresh .lv-chip { animation: none; }
|
||||
.lv-casino.hit, .lv-casino.hit.clash, .lv-die.rolling, .lv-fresh .lv-tieout, .lv-fresh .lv-pbody > .lv-chip, .lv-banner .anim-banner { animation: none; }
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -158,23 +223,24 @@ function Die({ value, color, size = '', rolling = false }: { value: number; colo
|
||||
);
|
||||
}
|
||||
|
||||
function Bill({ note, small }: { note: number | null; small?: boolean }) {
|
||||
function Bill({ note, small, anim, style }: { note: number | null; small?: boolean; anim?: string; style?: CSSProperties }) {
|
||||
const extra = `${small ? ' sm' : ''}${anim ? ` ${anim}` : ''}`;
|
||||
if (note === null)
|
||||
return (
|
||||
<span className={`lv-bill hidden${small ? ' sm' : ''}`} aria-label="금액 비공개 지폐">
|
||||
<span className={`lv-bill hidden${extra}`} style={style} aria-label="금액 비공개 지폐">
|
||||
?
|
||||
</span>
|
||||
);
|
||||
const [bg, fg] = BILL[note] ?? ['#eee', '#111'];
|
||||
return (
|
||||
<span className={`lv-bill${small ? ' sm' : ''}`} style={{ background: bg, color: fg }} aria-label={`지폐 ${note}점`}>
|
||||
<span className={`lv-bill${extra}`} style={{ ...style, background: bg, color: fg }} aria-label={`지폐 ${note}점`}>
|
||||
{note}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function Dot({ color }: { color: string }) {
|
||||
return <span className="lv-dot" style={{ background: color }} aria-hidden />;
|
||||
function Dot({ color, anim, style }: { color: string; anim?: string; style?: CSSProperties }) {
|
||||
return <span className={`lv-dot${anim ? ` ${anim}` : ''}`} style={{ ...style, background: color }} aria-hidden />;
|
||||
}
|
||||
|
||||
function OwnerChip({ v, players, owner, me }: { v: LasVegasView; players: Record<string, PublicUser>; owner: string; me: string | null }) {
|
||||
@@ -209,11 +275,15 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
const [sel, setSel] = useState<number | null>(null);
|
||||
const [rolling, setRolling] = useState(false);
|
||||
const [flick, setFlick] = useState<number[] | null>(null);
|
||||
const [hit, setHit] = useState<{ value: number; key: number } | null>(null);
|
||||
const [hit, setHit] = useState<{ value: number; key: number; clash: boolean } | null>(null);
|
||||
/** Dice that just landed on a casino (drawn flying in for a moment). */
|
||||
const [drop, setDrop] = useState<{ value: number; owner: string; own: number; neutral: number; key: number } | null>(null);
|
||||
/** Round whose fresh bills are being dealt onto the casinos. */
|
||||
const [dealt, setDealt] = useState<number | null>(null);
|
||||
const [banner, setBanner] = useState<{ text: string; sub?: string; key: number } | null>(null);
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const prevRoll = useRef(v.rollSeq);
|
||||
const prevTurn = useRef(v.turnSeq);
|
||||
const prevRounds = useRef(v.roundResults.length);
|
||||
const prevView = useRef(v);
|
||||
|
||||
// New roll: tumble animation + screen-reader text.
|
||||
useLayoutEffect(() => {
|
||||
@@ -226,11 +296,9 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
const who = v.current === me ? '내가' : `${nick(players, v.current ?? '')}님이`;
|
||||
const all = [...v.lastRoll.own, ...v.lastRoll.neutral].sort((a, b) => a - b);
|
||||
setAnnounce(`${who} 주사위 ${all.length}개를 굴렸어요: ${all.join(', ')}`);
|
||||
if (reducedMotion()) {
|
||||
sounds.stone();
|
||||
return;
|
||||
}
|
||||
setRolling(true);
|
||||
const animated = !reducedMotion();
|
||||
rollSound(all.length, animated);
|
||||
if (animated) setRolling(true);
|
||||
}, [v.rollSeq]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
@@ -240,7 +308,6 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
const end = setTimeout(() => {
|
||||
setRolling(false);
|
||||
setFlick(null);
|
||||
sounds.stone();
|
||||
}, ROLL_MS);
|
||||
return () => {
|
||||
clearInterval(t);
|
||||
@@ -248,39 +315,94 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
};
|
||||
}, [rolling]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Turn changes: placement flash, round settlement and my-turn cue.
|
||||
// Anyone's placement, round settlement and my-turn cue, found by comparing with the previous view.
|
||||
useEffect(() => {
|
||||
if (v.turnSeq === prevTurn.current) return;
|
||||
prevTurn.current = v.turnSeq;
|
||||
setSel(null);
|
||||
const pv = prevView.current;
|
||||
prevView.current = v;
|
||||
if (pv === v) return;
|
||||
const turnChanged = v.turnSeq !== pv.turnSeq;
|
||||
const settled = v.roundResults.length > pv.roundResults.length;
|
||||
const finished = v.phase === 'finished' && pv.phase !== 'finished';
|
||||
if (!turnChanged && !settled && !finished) return;
|
||||
if (turnChanged) setSel(null);
|
||||
const parts: string[] = [];
|
||||
const lp = v.lastPlace;
|
||||
if (lp) {
|
||||
setHit({ value: lp.value, key: v.turnSeq });
|
||||
// A real placement (not a concede that also moved the turn on): the mover was placing and no new roll came in between.
|
||||
const placed = !!lp && pv.phase === 'place' && pv.current === lp.player && v.rollSeq === pv.rollSeq && v.conceded.length === pv.conceded.length;
|
||||
let delay = 0;
|
||||
if (lp && placed) {
|
||||
const who = lp.player === me ? '내가' : `${nick(players, lp.player)}님이`;
|
||||
parts.push(
|
||||
`${who} ${lp.value}번 카지노에 주사위 ${lp.own + lp.neutral}개를 놓았어요${lp.neutral ? `(흰 ${lp.neutral}개 포함)` : ''}${lp.auto ? ' (시간 초과로 자동)' : ''}.`,
|
||||
);
|
||||
placeSound(lp.own + lp.neutral);
|
||||
delay = Math.min(lp.own + lp.neutral, 6) * 55 + 120;
|
||||
let clash = false;
|
||||
if (!settled) {
|
||||
const dice = v.casinos[lp.value - 1]?.dice ?? {};
|
||||
const mover = lp.own > 0 ? lp.player : HOUSE;
|
||||
const mine = dice[mover] ?? 0;
|
||||
clash = Object.entries(dice).some(([o, n]) => o !== mover && n === mine);
|
||||
if (clash) {
|
||||
tieSound(delay);
|
||||
delay += 300;
|
||||
}
|
||||
setDrop({ value: lp.value, owner: lp.player, own: lp.own, neutral: lp.neutral, key: v.turnSeq });
|
||||
setHit({ value: lp.value, key: v.turnSeq, clash });
|
||||
}
|
||||
}
|
||||
if (v.roundResults.length > prevRounds.current) {
|
||||
prevRounds.current = v.roundResults.length;
|
||||
if (settled) {
|
||||
const rr = v.roundResults[v.roundResults.length - 1]!;
|
||||
const ties = rr.payouts.filter((p) => p.removedTies.length > 0).length;
|
||||
parts.push(`${rr.round}라운드 정산이 끝났어요.${ties ? ` 동점 무효가 ${ties}곳에서 나왔어요.` : ''}`);
|
||||
const awards = rr.payouts.flatMap((p) => p.awards).filter((a) => a.owner !== HOUSE);
|
||||
// Only my own bills: with hideMoney the others' amounts stay secret (the bill count is public anyway).
|
||||
const mineAw = me ? awards.filter((a) => a.owner === me) : [];
|
||||
const more = v.phase !== 'finished';
|
||||
settleSound(delay + 150, ties, awards.length, mineAw.length > 0, more);
|
||||
const seated = !!me && v.seats.includes(me) && !v.conceded.includes(me);
|
||||
const got = mineAw.reduce((t, a) => t + (a.note ?? 0), 0);
|
||||
setBanner({
|
||||
text: more ? `${rr.round}라운드 정산` : '최종 정산',
|
||||
sub: seated ? (mineAw.length ? `+${got}점 (${mineAw.length}장)` : '이번엔 못 받았어요') : undefined,
|
||||
key: v.roundResults.length,
|
||||
});
|
||||
if (more) setDealt(v.round);
|
||||
haptic([50, 30, 50]);
|
||||
}
|
||||
if (myTurn) {
|
||||
const mineNow = v.phase !== 'finished' && !!me && v.current === me;
|
||||
if (mineNow && turnChanged) {
|
||||
haptic(40);
|
||||
if (document.visibilityState === 'hidden') sounds.myTurn();
|
||||
// Only when the turn comes back from someone else; a hidden tab gets the room page's chime instead.
|
||||
if (pv.current !== me && document.visibilityState === 'visible') turnCue(settled ? 1400 : delay + 250);
|
||||
}
|
||||
if (parts.length) setAnnounce(parts.join(' '));
|
||||
}, [v.turnSeq]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
}, [v]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Short-lived effects: forget them so later re-renders (e.g. the casino turning into a button) don't replay them.
|
||||
useEffect(() => {
|
||||
if (!drop) return;
|
||||
const t = setTimeout(() => setDrop(null), 900);
|
||||
return () => clearTimeout(t);
|
||||
}, [drop]);
|
||||
useEffect(() => {
|
||||
if (dealt === null) return;
|
||||
const t = setTimeout(() => setDealt(null), 1500);
|
||||
return () => clearTimeout(t);
|
||||
}, [dealt]);
|
||||
useEffect(() => {
|
||||
if (!banner) return;
|
||||
const t = setTimeout(() => setBanner(null), 1700);
|
||||
return () => clearTimeout(t);
|
||||
}, [banner]);
|
||||
|
||||
const choices = v.phase === 'place' && !rolling ? v.choices : [];
|
||||
const selChoice = choices.find((c) => c.value === sel) ?? null;
|
||||
const canPick = myTurn && v.phase === 'place' && !pending && !rolling;
|
||||
const pick = (value: number) => {
|
||||
if (!canPick || !choices.some((c) => c.value === value)) return;
|
||||
if (sel === value) sfx.click();
|
||||
else sfx.select();
|
||||
setSel(sel === value ? null : value);
|
||||
};
|
||||
const place = () => {
|
||||
@@ -302,7 +424,7 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
<div className="card lv-head">
|
||||
<strong>{v.phase === 'finished' ? '게임 끝' : `${v.round} / ${v.rounds} 라운드`}</strong>
|
||||
{v.current && (
|
||||
<span className="row small" style={{ gap: 6, flexWrap: 'nowrap', minWidth: 0 }}>
|
||||
<span key={v.turnSeq} className="row small anim-slide-up" style={{ gap: 6, flexWrap: 'nowrap', minWidth: 0 }}>
|
||||
<Dot color={seatColor(v, v.current)} />
|
||||
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{curName} 차례</span>
|
||||
</span>
|
||||
@@ -335,7 +457,8 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
const label = `${c.value}번 카지노. 지폐 ${c.notes.length ? c.notes.map((n) => `${n}점`).join(', ') : '없음'}. 주사위 ${
|
||||
owners.length ? owners.map(([o, n]) => `${o === me ? '나' : nick(players, o)} ${n}개`).join(', ') : '없음'
|
||||
}${ch && isSel ? `. ${STANDING_TAG[ch.standing]}` : ''}`;
|
||||
const cls = `lv-casino${ch && canPick ? ' can' : ''}${isSel ? ` sel ${ch?.standing === 'first' ? 'first' : ch?.standing === 'tie' ? 'tie' : ''}` : ''}${hit?.value === c.value ? ' hit' : ''}`;
|
||||
const cls = `lv-casino${ch && canPick ? ' can' : ''}${isSel ? ` sel ${ch?.standing === 'first' ? 'first' : ch?.standing === 'tie' ? 'tie' : ''}` : ''}${hit?.value === c.value ? ` hit${hit.clash ? ' clash' : ''}` : ''}`;
|
||||
const ci = c.value - 1;
|
||||
const body = (
|
||||
<>
|
||||
<div className="lv-ctop">
|
||||
@@ -344,22 +467,45 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
<span className="lv-cname">번 카지노</span>
|
||||
</div>
|
||||
<div className="lv-bills">
|
||||
{c.notes.length ? c.notes.map((n, i) => <Bill key={i} note={n} />) : <span className="lv-nobill">지폐 없음</span>}
|
||||
{c.notes.length ? (
|
||||
c.notes.map((n, i) =>
|
||||
dealt === v.round ? (
|
||||
<Bill key={`d${dealt}-${i}`} note={n} anim="anim-deal" style={vars({ '--anim-delay': `${200 + ci * 70 + i * 50}ms`, '--from-y': '-50px' })} />
|
||||
) : (
|
||||
<Bill key={i} note={n} />
|
||||
),
|
||||
)
|
||||
) : (
|
||||
<span className="lv-nobill">지폐 없음</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="lv-stacks">
|
||||
{owners.map(([o, n]) => (
|
||||
<div key={o} className="lv-stack" title={nick(players, o)}>
|
||||
<span className="lv-pips">
|
||||
{Array.from({ length: Math.min(n!, 8) }, (_, i) => (
|
||||
<Dot key={i} color={seatColor(v, o)} />
|
||||
))}
|
||||
</span>
|
||||
<span>{n! > 8 ? `${n}` : ''}</span>
|
||||
<span className="muted" style={{ fontWeight: 700, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{initial(players, o)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
{owners.map(([o, n]) => {
|
||||
const shown = Math.min(n!, 8);
|
||||
const fresh = drop && drop.value === c.value ? (o === HOUSE ? drop.neutral : o === drop.owner ? drop.own : 0) : 0;
|
||||
return (
|
||||
<div key={o} className="lv-stack" title={nick(players, o)}>
|
||||
<span className="lv-pips">
|
||||
{Array.from({ length: shown }, (_, i) =>
|
||||
i >= shown - fresh ? (
|
||||
<Dot
|
||||
key={`p${drop!.key}-${i}`}
|
||||
color={seatColor(v, o)}
|
||||
anim="anim-deal"
|
||||
style={vars({ '--anim-delay': `${(i - (shown - fresh)) * 55}ms`, '--from-y': '90px' })}
|
||||
/>
|
||||
) : (
|
||||
<Dot key={i} color={seatColor(v, o)} />
|
||||
),
|
||||
)}
|
||||
</span>
|
||||
<span>{n! > 8 ? `${n}` : ''}</span>
|
||||
<span className="muted" style={{ fontWeight: 700, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{initial(players, o)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{ch && isSel && (
|
||||
<div className="lv-stack" style={{ opacity: 0.85 }}>
|
||||
<span className="lv-pips">
|
||||
@@ -450,7 +596,7 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
)}
|
||||
</>
|
||||
) : myTurn ? (
|
||||
<button className="btn btn-primary btn-block lv-roll" disabled={pending} onClick={roll}>
|
||||
<button className={`btn btn-primary btn-block lv-roll${pending ? '' : ' anim-glow'}`} disabled={pending} onClick={roll}>
|
||||
🎲 주사위 굴리기 ({(hand?.own ?? 0) + (hand?.neutral ?? 0)}개)
|
||||
</button>
|
||||
) : (
|
||||
@@ -484,6 +630,14 @@ function LasVegasBoard({ view: v, me, players, act, pending }: BoardProps<LasVeg
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{banner && (
|
||||
<div className="lv-banner" aria-hidden>
|
||||
<div key={banner.key} className="anim-banner">
|
||||
{banner.text}
|
||||
{banner.sub && <small>{banner.sub}</small>}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -501,12 +655,12 @@ function Settlement({
|
||||
me: string | null;
|
||||
players: Record<string, PublicUser>;
|
||||
}) {
|
||||
const fresh = v.phase !== 'finished' && round === v.round - 1;
|
||||
const fresh = round === v.roundResults[v.roundResults.length - 1]?.round;
|
||||
return (
|
||||
<section className={`card lv-settle${fresh ? ' lv-fresh' : ''}`} aria-label={`${round}라운드 정산`}>
|
||||
<h3>{round}라운드 정산</h3>
|
||||
{payouts.map((p) => (
|
||||
<div key={p.casino} className="lv-prow">
|
||||
{payouts.map((p, row) => (
|
||||
<div key={p.casino} className="lv-prow" style={vars({ '--anim-delay': `${row * 90}ms` })}>
|
||||
<strong>{p.casino}번</strong>
|
||||
<div className="lv-pbody">
|
||||
{p.removedTies.length > 0 && (
|
||||
@@ -518,7 +672,7 @@ function Settlement({
|
||||
</span>
|
||||
)}
|
||||
{p.awards.map((a, i) => (
|
||||
<span key={a.key ?? `${a.owner}-${i}`} className="lv-chip">
|
||||
<span key={a.key ?? `${a.owner}-${i}`} className="lv-chip" style={vars({ '--anim-delay': `${row * 90 + 150 + i * 70}ms` })}>
|
||||
<OwnerChip v={v} players={players} owner={a.owner} me={me} />
|
||||
<Bill note={a.note} small />
|
||||
{a.note === null && <span className="muted">1장</span>}
|
||||
@@ -592,7 +746,7 @@ function LasVegasSide({ view: v, me, players, act, deadline }: BoardProps<LasVeg
|
||||
return (
|
||||
<div
|
||||
key={p}
|
||||
className="row"
|
||||
className={`row${turn && playing ? ' anim-glow' : ''}`}
|
||||
style={{ gap: 10, flexWrap: 'nowrap', padding: '4px 6px', borderRadius: 10, border: `3px solid ${turn ? 'var(--focus)' : 'transparent'}` }}
|
||||
>
|
||||
<span aria-label={`${COLOR_NAMES[i]} 주사위`} role="img">
|
||||
@@ -617,8 +771,12 @@ function LasVegasSide({ view: v, me, players, act, deadline }: BoardProps<LasVeg
|
||||
style={{ textAlign: 'right', fontVariantNumeric: 'tabular-nums' }}
|
||||
aria-label={`${nick(players, p)} 지폐 ${m.count}장${m.total !== null ? `, ${m.total}점` : ''}`}
|
||||
>
|
||||
<strong style={{ fontSize: '1.2rem' }}>{m.total !== null ? `${m.total}점` : '?'}</strong>
|
||||
<div className="small muted">{m.count}장</div>
|
||||
<strong style={{ fontSize: '1.2rem' }}>
|
||||
<Bump value={m.total}>{m.total !== null ? `${m.total}점` : '?'}</Bump>
|
||||
</strong>
|
||||
<div className="small muted">
|
||||
<Bump value={m.count}>{m.count}장</Bump>
|
||||
</div>
|
||||
</span>
|
||||
{turn && playing && <TurnTimer deadline={deadline} totalMs={total} mine={p === me} size={40} />}
|
||||
</div>
|
||||
@@ -633,9 +791,7 @@ function LasVegasSide({ view: v, me, players, act, deadline }: BoardProps<LasVeg
|
||||
{mine.count}장 · {mine.total ?? 0}점
|
||||
</span>
|
||||
</div>
|
||||
<div className="lv-bills">
|
||||
{mine.notes && mine.notes.length ? mine.notes.map((n, i) => <Bill key={i} note={n} small />) : <span className="lv-nobill">아직 없어요</span>}
|
||||
</div>
|
||||
<MyBills notes={mine.notes ?? []} />
|
||||
{v.options.hideMoney && playing && (
|
||||
<p className="small muted" style={{ margin: 0 }}>
|
||||
다른 사람에게는 장 수만 보여요.
|
||||
@@ -662,6 +818,39 @@ function LasVegasSide({ view: v, me, players, act, deadline }: BoardProps<LasVeg
|
||||
);
|
||||
}
|
||||
|
||||
/** My bills; the ones just received fly in (my own amounts are always visible to me). */
|
||||
function MyBills({ notes }: { notes: number[] }) {
|
||||
const sig = notes.join(',');
|
||||
const r = useRef({ sig, fresh: [] as boolean[], n: 0 });
|
||||
if (r.current.sig !== sig) {
|
||||
const left = r.current.sig ? r.current.sig.split(',').map(Number) : [];
|
||||
const fresh = notes.map((x) => {
|
||||
const i = left.indexOf(x);
|
||||
if (i < 0) return true;
|
||||
left.splice(i, 1);
|
||||
return false;
|
||||
});
|
||||
r.current = { sig, fresh, n: r.current.n + 1 };
|
||||
}
|
||||
const { fresh, n } = r.current;
|
||||
let k = 0;
|
||||
return (
|
||||
<div className="lv-bills">
|
||||
{notes.length ? (
|
||||
notes.map((note, i) =>
|
||||
fresh[i] ? (
|
||||
<Bill key={`f${n}-${i}`} note={note} small anim="anim-deal" style={vars({ '--anim-delay': `${400 + k++ * 90}ms`, '--from-y': '-40px' })} />
|
||||
) : (
|
||||
<Bill key={i} note={note} small />
|
||||
),
|
||||
)
|
||||
) : (
|
||||
<span className="lv-nobill">아직 없어요</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- status
|
||||
|
||||
function isMyTurn(v: LasVegasView, me: string | null): boolean {
|
||||
@@ -762,7 +951,7 @@ function optionsSummary(o: LasVegasOptions): string {
|
||||
`${o.rounds}라운드`,
|
||||
o.neutralDice === 'auto' ? '흰 주사위 자동' : o.neutralDice === 'on' ? '흰 주사위 켜기' : '흰 주사위 끄기',
|
||||
o.hideMoney ? '금액 숨김' : '금액 공개',
|
||||
o.turnSeconds === null ? '시간 제한 없음' : `${o.turnSeconds}초`,
|
||||
o.turnSeconds === null ? '시간 무제한' : `${o.turnSeconds}초`,
|
||||
].join(' · ');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user