할리갈리·도블·사과 게임: 뒤집기 시간 무제한·사과 게임 무제한(여기까지), 소리·움직임
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,7 @@ export function helpNow(v: HalliGalliView, me: string | null, players: Record<st
|
||||
if (v.options.autoFlip) lines.push('내 차례예요. 이 방은 카드가 자동으로 뒤집혀요.');
|
||||
else if (v.pendingFlip) lines.push('내 차례예요. 뒤집기를 눌렀어요. 곧 카드가 펼쳐져요.');
|
||||
else if (mine.deck === 0) lines.push('내 차례인데 내 덱(뒤집을 카드 더미)이 비었어요.');
|
||||
else if (v.flipTotalMs === null) lines.push('내 차례예요. 아래 [뒤집기]를 눌러 카드를 한 장 펼쳐요. 시간 제한은 없어요.');
|
||||
else lines.push(`내 차례예요. 아래 [뒤집기]를 눌러 카드를 한 장 펼쳐요. ${v.flipTotalMs / 1000}초가 지나면 자동으로 뒤집혀요.`);
|
||||
} else {
|
||||
lines.push(`${nick(v.turn)}님이 뒤집을 차례예요. 차례가 아니어도 종은 언제든 누를 수 있어요.`);
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Fruit, FruitCount, HalliGalliOptions, HalliGalliView, LogEntry, Se
|
||||
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 { socket, useRoom } from '../../net/socket';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
@@ -19,6 +19,21 @@ const userOf = (players: Record<string, PublicUser>, id: string): PublicUser =>
|
||||
players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' };
|
||||
const cardName = (c: Pick<TopCard, 'fruit' | 'count'>) => `${FRUIT_KO[c.fruit]} ${c.count}개`;
|
||||
|
||||
/** Game sounds on top of the shared palette (site volume applies). */
|
||||
const hgSound = {
|
||||
/** Countdown 3·2·1 and the start beep. */
|
||||
count: () => tone(660, 90, 'triangle', 0.12),
|
||||
go: () => {
|
||||
tone(988, 120, 'triangle', 0.14);
|
||||
tone(1318, 200, 'triangle', 0.12, 90);
|
||||
},
|
||||
/** Every face-up card swept to the winner. */
|
||||
sweep: (cards: number) => {
|
||||
sfx.whoosh();
|
||||
sfx.deal(Math.min(6, Math.max(2, Math.ceil(cards / 3))), 45);
|
||||
},
|
||||
};
|
||||
|
||||
const CSS = `
|
||||
.hg { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 10px; align-self: center; }
|
||||
.hg-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; justify-content: space-between; font-weight: 700; }
|
||||
@@ -82,6 +97,12 @@ const CSS = `
|
||||
.hg-panel { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; }
|
||||
.hg-log { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; max-height: 220px; overflow: auto; }
|
||||
.hg-fruit-ic { width: 26px; height: 26px; display: inline-block; vertical-align: middle; }
|
||||
.hg-seat[data-shake='true'] .hg-pile { animation: anim-shake .45s ease; }
|
||||
.hg-seat[data-out='true'] .hg-pile { filter: grayscale(.7); transition: filter .4s ease; }
|
||||
.hg-meta .gain { display: inline-block; }
|
||||
.hg-count b { display: block; animation: hg-count .9s ease-out both; }
|
||||
.hg-flipbtn.anim-glow { animation-duration: 1.1s; }
|
||||
@keyframes hg-count { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .85; } }
|
||||
@keyframes hg-blink { 0%,100% { box-shadow: 0 0 0 0 rgba(253,224,71,.0); } 50% { box-shadow: 0 0 0 6px rgba(253,224,71,.55); } }
|
||||
@keyframes hg-flip { from { transform: rotateY(85deg) scale(.9); } to { transform: none; } }
|
||||
@keyframes hg-pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 70% { transform: translateX(-50%) scale(1.06); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }
|
||||
@@ -96,7 +117,7 @@ const CSS = `
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.hg-seat[data-turn='true'] { animation: none; box-shadow: 0 0 0 4px rgba(253,224,71,.55); }
|
||||
.hg-pile .face, .hg-bell .art[data-ring='true'], .hg-bubble { animation: none; }
|
||||
.hg-pile .face, .hg-bell .art[data-ring='true'], .hg-bubble, .hg-count b, .hg-seat[data-shake='true'] .hg-pile { animation: none; }
|
||||
.hg-ghost { display: none; }
|
||||
}
|
||||
`;
|
||||
@@ -296,14 +317,22 @@ function seatLabel(s: SeatView, players: Record<string, PublicUser>, me: string
|
||||
return parts.join(', ');
|
||||
}
|
||||
|
||||
function Seat({ s, v, pos, players, me, now }: { s: SeatView; v: HalliGalliView; pos: Pos; players: Record<string, PublicUser>; me: string | null; now: number }) {
|
||||
function Seat({ s, v, pos, players, me, now, shake }: { s: SeatView; v: HalliGalliView; pos: Pos; players: Record<string, PublicUser>; me: string | null; now: number; shake: boolean }) {
|
||||
const u = userOf(players, s.id);
|
||||
const locked = s.lockedUntil > now && s.status === 'playing';
|
||||
// The deck count bumps when it grows (cards won with the bell or given as a penalty).
|
||||
const lastDeck = useRef(s.deck);
|
||||
const [gain, setGain] = useState(0);
|
||||
useEffect(() => {
|
||||
if (s.deck > lastDeck.current) setGain((g) => g + 1);
|
||||
lastDeck.current = s.deck;
|
||||
}, [s.deck]);
|
||||
return (
|
||||
<li
|
||||
className="hg-seat"
|
||||
data-turn={s.isTurn && v.phase === 'playing'}
|
||||
data-out={s.status !== 'playing'}
|
||||
data-shake={shake}
|
||||
data-me={s.id === me}
|
||||
data-seat={s.id}
|
||||
style={{ left: pos.left, top: pos.top }}
|
||||
@@ -322,10 +351,10 @@ function Seat({ s, v, pos, players, me, now }: { s: SeatView; v: HalliGalliView;
|
||||
) : (
|
||||
<span className="empty" />
|
||||
)}
|
||||
{s.isTurn && v.phase === 'playing' && <Gauge start={v.turnStartedAt} end={v.turnDeadline} now={now} />}
|
||||
{s.isTurn && v.phase === 'playing' && v.turnDeadline !== null && <Gauge start={v.turnStartedAt} end={v.turnDeadline} now={now} />}
|
||||
</div>
|
||||
<div className="hg-meta" aria-hidden>
|
||||
<span>
|
||||
<span key={gain} className={gain > 0 ? 'gain anim-bump' : 'gain'}>
|
||||
<i className="hg-back" /> {s.deck}
|
||||
</span>
|
||||
{s.status === 'out' && (
|
||||
@@ -384,6 +413,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
const [bubble, setBubble] = useState<Bubble | null>(null);
|
||||
const [ghosts, setGhosts] = useState<Ghost[]>([]);
|
||||
const [hit, setHit] = useState(0);
|
||||
const [shake, setShake] = useState<{ id: string; seq: number } | null>(null);
|
||||
const [announce, setAnnounce] = useState('');
|
||||
const sentFor = useRef<number | null>(null);
|
||||
const prev = useRef<HalliGalliView | null>(null);
|
||||
@@ -406,10 +436,11 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
const ring = () => {
|
||||
if (!canRing || sentFor.current === v.tableVersion) return;
|
||||
sentFor.current = v.tableVersion;
|
||||
// Send first: the sound and the bell wobble must not delay the press by a frame.
|
||||
act({ type: 'ring', version: v.tableVersion, ...(v.options.latencyComp === 'light' && rtt !== null ? { rtt } : {}) });
|
||||
setHit((h) => h + 1);
|
||||
sounds.ding();
|
||||
haptic(30);
|
||||
act({ type: 'ring', version: v.tableVersion, ...(v.options.latencyComp === 'light' && rtt !== null ? { rtt } : {}) });
|
||||
};
|
||||
const flip = () => {
|
||||
if (!canFlip) return;
|
||||
@@ -469,13 +500,17 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
}
|
||||
const to = posOf(b.player);
|
||||
const fly: Ghost[] = [];
|
||||
// Someone else's bell wobbles too (mine already did on the press).
|
||||
if (b.player !== me) setHit((h) => h + 1);
|
||||
if (b.correct) {
|
||||
if (b.player !== me) sounds.ding();
|
||||
else haptic([40, 30, 80]);
|
||||
hgSound.sweep(b.cards);
|
||||
p.seats.forEach((s, i) => s.top && fly.push({ key: `g${b.seq}-${s.id}`, from: posOf(s.id), to, card: s.top, delay: i * 40 }));
|
||||
if (p.pot > 0) fly.push({ key: `g${b.seq}-pot`, from: CENTER, to, card: null, delay: 0 });
|
||||
} else {
|
||||
sounds.buzz();
|
||||
setShake({ id: b.player, seq: b.seq });
|
||||
if (b.player === me) haptic([90, 50, 90]);
|
||||
const from = posOf(b.player);
|
||||
const targets = v.options.wrongToPot ? [CENTER] : p.seats.filter((s) => s.id !== b.player && s.status === 'playing').map((s) => posOf(s.id));
|
||||
@@ -484,8 +519,10 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
setGhosts(fly);
|
||||
return;
|
||||
}
|
||||
const outNow = v.seats.filter((s) => s.status !== 'playing' && p.seats.find((x) => x.id === s.id)?.status === 'playing');
|
||||
if (outNow.length && v.phase !== 'ended') sfx.capture();
|
||||
if (v.tableVersion !== p.tableVersion && v.lastFlipBy) {
|
||||
sounds.stone();
|
||||
sfx.cardFlip();
|
||||
const s = v.seats.find((x) => x.id === v.lastFlipBy);
|
||||
if (s?.top) setAnnounce(`${s.id === me ? '내가' : `${nick(players, s.id)}님이`} ${cardName(s.top)}를 뒤집었어요`);
|
||||
}
|
||||
@@ -503,6 +540,12 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
return () => clearTimeout(t);
|
||||
}, [ghosts]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!shake) return;
|
||||
const t = setTimeout(() => setShake(null), 500);
|
||||
return () => clearTimeout(t);
|
||||
}, [shake]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!bubble) return;
|
||||
const t = setTimeout(() => setBubble(null), bubble.kind === 'late' ? 1300 : 1900);
|
||||
@@ -514,6 +557,19 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
const totals = FRUITS.map((f) => ({ f, n: v.seats.reduce((a, s) => a + (s.top && s.top.fruit === f ? s.top.count : 0), 0) }));
|
||||
const timeLeft = v.endsAt !== null ? Math.max(0, v.endsAt - Math.max(now, v.countdownEndsAt)) : null;
|
||||
const ping = rtt;
|
||||
// 3·2·1 beeps, a start beep, and ticks in the last 10 seconds of the game clock.
|
||||
const beep = v.phase === 'countdown' ? countdown : -1;
|
||||
const lastSec = playing && timeLeft !== null && timeLeft > 0 && timeLeft <= 10_000 ? Math.ceil(timeLeft / 1000) : 0;
|
||||
const sounded = useRef({ beep: -1, lastSec: 0 });
|
||||
useEffect(() => {
|
||||
const was = sounded.current;
|
||||
if (beep !== was.beep) {
|
||||
if (beep > 0) hgSound.count();
|
||||
else if (beep === -1 && was.beep >= 0 && playing) hgSound.go();
|
||||
}
|
||||
if (lastSec && lastSec !== was.lastSec) sfx.tick();
|
||||
sounded.current = { beep, lastSec };
|
||||
}, [beep, lastSec, playing]);
|
||||
|
||||
return (
|
||||
<div className="hg">
|
||||
@@ -546,7 +602,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
>
|
||||
<ul style={{ listStyle: 'none', margin: 0, padding: 0 }} aria-label="사람들의 펼친 카드">
|
||||
{rot.map((s, i) => (
|
||||
<Seat key={s.id} s={s} v={v} pos={pos[i]!} players={players} me={me} now={now} />
|
||||
<Seat key={s.id} s={s} v={v} pos={pos[i]!} players={players} me={me} now={now} shake={shake?.id === s.id} />
|
||||
))}
|
||||
</ul>
|
||||
<div className="hg-center">
|
||||
@@ -603,7 +659,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
)}
|
||||
{countdown > 0 && (
|
||||
<div className="hg-count" aria-hidden>
|
||||
{countdown}
|
||||
<b key={countdown}>{countdown}</b>
|
||||
<small>과일이 딱 5개가 되면 종을 쳐요!</small>
|
||||
</div>
|
||||
)}
|
||||
@@ -617,7 +673,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps<Hall
|
||||
<i className="hg-back" /> {mine.deck}장
|
||||
</b>
|
||||
</div>
|
||||
<button type="button" className={`btn ${myTurn ? 'btn-primary' : 'btn-secondary'} hg-flipbtn`} disabled={!canFlip} onClick={flip} aria-keyshortcuts="Enter">
|
||||
<button type="button" className={`btn ${myTurn ? 'btn-primary' : 'btn-secondary'} hg-flipbtn${canFlip ? ' anim-glow' : ''}`} disabled={!canFlip} onClick={flip} aria-keyshortcuts="Enter">
|
||||
{v.options.autoFlip ? (myTurn ? '곧 자동으로 뒤집혀요' : '자동 뒤집기') : v.pendingFlip && myTurn ? '곧 뒤집혀요…' : myTurn ? '뒤집기' : `${v.turn ? nick(players, v.turn) : ''}님 차례`}
|
||||
</button>
|
||||
</div>
|
||||
@@ -667,7 +723,8 @@ function logText(e: LogEntry, players: Record<string, PublicUser>, me: string |
|
||||
|
||||
function rulesLine(o: HalliGalliOptions): string {
|
||||
const parts = [o.endMode === 'official' ? '2명 남으면 다음 종에서 끝' : '한 명 남을 때까지', o.timeLimitMin ? `${o.timeLimitMin}분 제한` : '시간 제한 없음'];
|
||||
parts.push(o.autoFlip ? `자동 뒤집기 ${o.kidMode ? 8 : o.flipSeconds}초` : `뒤집기 ${o.kidMode ? 8 : o.flipSeconds}초`);
|
||||
const sec = o.flipSeconds === null ? (o.autoFlip ? (o.kidMode ? 8 : 3) : null) : o.kidMode ? 8 : o.flipSeconds;
|
||||
parts.push(o.autoFlip ? `자동 뒤집기 ${sec}초` : sec === null ? '뒤집기 시간 무제한' : `뒤집기 ${sec}초`);
|
||||
if (o.wrongRingLockoutMs) parts.push(`틀리면 종 ${o.wrongRingLockoutMs / 1000}초 잠금`);
|
||||
if (o.penaltyEscalation) parts.push('벌칙 점점 늘어남');
|
||||
if (o.wrongToPot) parts.push('벌칙은 종 밑으로');
|
||||
@@ -815,7 +872,10 @@ function Options({ value: o, onChange }: OptionsProps<HalliGalliOptions>) {
|
||||
onChange={(timeLimitMin) => set({ timeLimitMin })}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="뒤집기 제한 시간" help="시간 안에 안 뒤집으면 자동으로 뒤집혀요.">
|
||||
<Field
|
||||
label="뒤집기 제한 시간"
|
||||
help={o.flipSeconds === null ? (o.autoFlip ? '자동 뒤집기에서는 3초(어린이 모드 8초)마다 뒤집혀요.' : '차례인 사람이 직접 뒤집을 때까지 기다려요.') : '시간 안에 안 뒤집으면 자동으로 뒤집혀요.'}
|
||||
>
|
||||
<Seg
|
||||
label="뒤집기 제한 시간"
|
||||
value={o.flipSeconds}
|
||||
@@ -824,11 +884,12 @@ function Options({ value: o, onChange }: OptionsProps<HalliGalliOptions>) {
|
||||
[3, '3초'],
|
||||
[5, '5초'],
|
||||
[8, '8초'],
|
||||
[null, '무제한'],
|
||||
]}
|
||||
onChange={(flipSeconds) => set({ flipSeconds })}
|
||||
/>
|
||||
</Field>
|
||||
<Field label="어린이 모드" help="8초 뒤집기, 과일 합계 막대를 보여 줘요.">
|
||||
<Field label="어린이 모드" help={o.flipSeconds === null && !o.autoFlip ? '과일 합계 막대를 보여 줘요(뒤집기 시간은 무제한 그대로).' : '8초 뒤집기, 과일 합계 막대를 보여 줘요.'}>
|
||||
<Seg label="어린이 모드" value={o.kidMode} options={onOff} onChange={(kidMode) => set({ kidMode })} />
|
||||
</Field>
|
||||
<button type="button" className="btn btn-ghost" onClick={() => setMore(!more)} aria-expanded={more}>
|
||||
|
||||
Reference in New Issue
Block a user