할리갈리·도블·사과 게임: 뒤집기 시간 무제한·사과 게임 무제한(여기까지), 소리·움직임
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ import type { CardView, ClaimPair, DobbleOptions, DobbleView, LogEntry, MiniGame
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar } from '../../components/ui';
|
||||
import { useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { haptic, sfx, sounds, tone } from '../../lib/feedback';
|
||||
import { useSeatRows } from '../../lib/seat-rows';
|
||||
import { socket, useRoom } from '../../net/socket';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
@@ -21,6 +21,22 @@ const userOf = (players: Record<string, PublicUser>, id: string): PublicUser =>
|
||||
players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' };
|
||||
const who = (players: Record<string, PublicUser>, me: string | null, id: string) => (id === me ? '내가' : `${nick(players, id)}님이`);
|
||||
|
||||
/** Game sounds on top of the shared palette (site volume applies). */
|
||||
const dbSound = {
|
||||
/** Soft tap the moment a symbol is pressed (the verdict comes from the server). */
|
||||
tap: () => tone(1500, 25, 'triangle', 0.06),
|
||||
/** "찾았다!" two-note chime, a little brighter than the shared one. */
|
||||
found: () => {
|
||||
tone(1047, 80, 'triangle', 0.15);
|
||||
tone(1568, 160, 'triangle', 0.13, 70);
|
||||
},
|
||||
count: () => tone(660, 90, 'triangle', 0.12),
|
||||
go: () => {
|
||||
tone(988, 120, 'triangle', 0.14);
|
||||
tone(1318, 200, 'triangle', 0.12, 90);
|
||||
},
|
||||
};
|
||||
|
||||
const CSS = `
|
||||
.db { width: 100%; max-width: 1060px; display: flex; flex-direction: column; gap: 10px; align-self: center; --cd: min(440px, 50vh, calc(50% - 14px)); }
|
||||
.db-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; justify-content: space-between; font-weight: 700; }
|
||||
@@ -47,6 +63,12 @@ button.db-seat { cursor: pointer; }
|
||||
.db-card { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; background: #fffdf6; border: 4px solid #d6c7a1; box-shadow: 0 6px 0 rgba(0,0,0,.18), 0 10px 22px rgba(0,0,0,.28); }
|
||||
.db-card.empty { background: rgba(255,255,255,.1); border: 3px dashed rgba(255,255,255,.55); box-shadow: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; text-align: center; padding: 18%; }
|
||||
.db-card[data-shake='true'] { animation: db-shake .4s ease; }
|
||||
.db-card.slap { animation: db-slap .2s ease-out; }
|
||||
.db-seat .meta .n { display: inline-block; }
|
||||
.db-seat[data-done='true'] { border-color: #16a34a; }
|
||||
.db-count b { display: block; animation: db-count .9s ease-out both; }
|
||||
@keyframes db-slap { from { transform: scale(1.07) rotate(-3deg); } }
|
||||
@keyframes db-count { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .85; } }
|
||||
.db-sym { position: absolute; border-radius: 50%; border: 0; padding: 0; margin: 0; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
|
||||
.db-sym:disabled { cursor: default; }
|
||||
@media (hover: hover) { .db-sym:hover:not(:disabled) { background: rgba(37, 99, 235, .08); } }
|
||||
@@ -101,7 +123,7 @@ button.db-seat { cursor: pointer; }
|
||||
.db-count { font-size: 4rem; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.db-card[data-shake='true'], .db-sym .ic.in, .db-bubble, .db-sym[data-hint='true'] { animation: none; }
|
||||
.db-card[data-shake='true'], .db-card.slap, .db-count b, .db-sym .ic.in, .db-bubble, .db-sym[data-hint='true'] { animation: none; }
|
||||
.db-sym[data-hit='true'] .ic { transition: none; }
|
||||
}
|
||||
`;
|
||||
@@ -144,7 +166,7 @@ function DobbleCard({
|
||||
children?: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="db-card" role="group" aria-label={label} data-card={side} data-key={card.key} data-shake={!!shake}>
|
||||
<div key={card.key} className="db-card slap" role="group" aria-label={label} data-card={side} data-key={card.key} data-shake={!!shake}>
|
||||
{card.items.map((it, i) => {
|
||||
const d = it.r * 100;
|
||||
return (
|
||||
@@ -286,7 +308,6 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
if (lockedLeft > 0) setBubble({ key: `lk${Date.now()}`, kind: 'late', text: `잠깐! ${Math.ceil(lockedLeft / 1000)}초 뒤에 다시 눌러요` });
|
||||
return;
|
||||
}
|
||||
haptic(15);
|
||||
act({
|
||||
type: 'claim',
|
||||
base: pair.base,
|
||||
@@ -295,6 +316,9 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
...(pair.mine !== null ? { mine: pair.mine } : {}),
|
||||
...(rtt !== null ? { rtt } : {}),
|
||||
});
|
||||
// After sending: feedback never delays the claim.
|
||||
haptic(15);
|
||||
dbSound.tap();
|
||||
};
|
||||
|
||||
// "늦었어요" rejects come back as `reject` messages.
|
||||
@@ -317,7 +341,8 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
const f = v.feedback;
|
||||
if (f && f.seq !== p.feedback?.seq) {
|
||||
if (f.kind === 'ok') {
|
||||
sounds.ding();
|
||||
dbSound.found();
|
||||
sfx.cardPlay();
|
||||
haptic([30, 30, 60]);
|
||||
setHitArt(f.art);
|
||||
const b: Bubble = { key: `f${f.seq}`, kind: 'ok', text: '찾았어요!', art: f.art };
|
||||
@@ -341,7 +366,8 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
}
|
||||
const h = v.lastHit;
|
||||
if (h && h.seq !== p.lastHit?.seq && h.player !== me) {
|
||||
sounds.stone();
|
||||
sfx.cardPlay();
|
||||
if (h.target === me && (mode === 'poisonedGift' || mode === 'hotPotato')) sfx.alarm();
|
||||
let text = `${nick(players, h.player)}님이 찾았어요`;
|
||||
if (mode === 'poisonedGift' && h.target === me) text = `${nick(players, h.player)}님이 나에게 카드를 줬어요`;
|
||||
if (mode === 'hotPotato' && h.target === me) text = `${nick(players, h.player)}님이 카드 묶음을 넘겼어요!`;
|
||||
@@ -353,7 +379,14 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
const text = r.loser ? `${r.round}라운드 끝! ${r.loser === me ? '내가' : `${nick(players, r.loser)}님이`} 카드 ${r.cards}장을 벌점으로 받아요` : `${r.round}라운드는 무효예요`;
|
||||
setBubble({ key: `r${r.round}`, kind: r.loser === me ? 'bad' : 'info', text });
|
||||
setAnnounce(text);
|
||||
if (r.loser === me) sfx.bad();
|
||||
else sfx.whoosh();
|
||||
}
|
||||
// Someone emptied their cards / escaped this round.
|
||||
const done = v.seats.filter((s) => (s.status === 'finished' || s.status === 'escaped') && p.seats.find((x) => x.id === s.id)?.status === 'playing');
|
||||
if (done.length && v.phase !== 'ended') sfx.good();
|
||||
// The stall hint just appeared.
|
||||
if (v.hint.length && v.hintUntil !== p.hintUntil && v.hintUntil > 0) sfx.select();
|
||||
}, [v]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
useEffect(() => {
|
||||
@@ -373,6 +406,16 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
}, [hitArt]);
|
||||
|
||||
const countdown = v.phase === 'countdown' || v.phase === 'roundEnd' ? Math.max(0, Math.ceil((v.phaseEndsAt - now) / 1000)) : 0;
|
||||
// 3·2·1 beeps before the cards open, a start beep when they do.
|
||||
const beep = v.phase === 'countdown' || v.phase === 'roundEnd' ? countdown : -1;
|
||||
const beeped = useRef(-1);
|
||||
useEffect(() => {
|
||||
const was = beeped.current;
|
||||
beeped.current = beep;
|
||||
if (beep === was) return;
|
||||
if (beep > 0 && beep <= 3) dbSound.count();
|
||||
else if (beep === -1 && was >= 0 && playing) dbSound.go();
|
||||
}, [beep, playing]);
|
||||
const hint = v.hintUntil > now ? v.hint : [];
|
||||
const tapper = canTap || (!!pair && playing && lockedLeft > 0) ? claim : null;
|
||||
|
||||
@@ -464,7 +507,9 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
<span style={{ overflow: 'hidden', textOverflow: 'ellipsis' }}>{nick(players, s.id)}</span>
|
||||
</span>
|
||||
<span className="meta">
|
||||
{countText(mode, s)}
|
||||
<span key={countText(mode, s)} className="n anim-bump">
|
||||
{countText(mode, s)}
|
||||
</span>
|
||||
{s.lockedUntil > now && s.status === 'playing' ? ' · 잠금' : ''}
|
||||
</span>
|
||||
{v.options.showRtt && <Rtt ms={s.rtt} />}
|
||||
@@ -486,7 +531,7 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
{inner}
|
||||
</button>
|
||||
) : (
|
||||
<div className="db-seat" data-seat={s.id} data-out={s.status !== 'playing'} aria-label={seatLabel(v, s, players, me)} aria-pressed={targetMode ? targetId === s.id : undefined}>
|
||||
<div className="db-seat" data-seat={s.id} data-out={s.status !== 'playing'} data-done={s.status === 'finished' || s.status === 'escaped'} aria-label={seatLabel(v, s, players, me)} aria-pressed={targetMode ? targetId === s.id : undefined}>
|
||||
{inner}
|
||||
</div>
|
||||
)}
|
||||
@@ -507,7 +552,7 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps<DobbleVi
|
||||
)}
|
||||
{countdown > 0 && (
|
||||
<div className="db-count" aria-hidden>
|
||||
{countdown}
|
||||
<b key={countdown}>{countdown}</b>
|
||||
<small>{v.phase === 'roundEnd' ? '다음 라운드를 준비해요' : '두 카드에 똑같이 있는 그림을 찾아요!'}</small>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user