diff --git a/apps/server/src/rooms/apple.room.test.ts b/apps/server/src/rooms/apple.room.test.ts index 6203482..9b7883a 100644 --- a/apps/server/src/rooms/apple.room.test.ts +++ b/apps/server/src/rooms/apple.room.test.ts @@ -95,8 +95,40 @@ describe('사과 게임 room flow', () => { room.onTimer(); expect(s().phase).toBe('playing'); expect(s().status.B).toBe('playing'); - h.clock.advance(s().endsAt - h.clock.now()); + h.clock.advance(s().endsAt! - h.clock.now()); room.onTimer(); expect(room.game!.finished).toBe(true); }); + test('제한 시간 무제한: 타이머가 돌지 않고, 끊긴 사람은 유예 뒤 한 번만 여기까지 처리(바쁜 루프 없음), 남은 사람이 여기까지 하면 끝', () => { + const h = harness(); + const r = h.manager.create('A', 'apple', 'private'); + if (typeof r === 'string') throw new Error(r); + const room = r as Room; + rooms.push(room); + const a = h.conn('A'); + const b = h.conn('B'); + room.join(a, 'player'); + room.join(b, 'player'); + room.ready('B', true); + expect(room.configure('A', { options: { timeLimitSec: null } })).toBeNull(); + expect(room.start('A')).toBeNull(); + h.clock.advance(3000); + room.onTimer(); + const s = () => room.game!.state as AppleState; + expect(s().phase).toBe('playing'); + expect(s().endsAt).toBeNull(); + expect(room.effectiveDeadline()).toBeNull(); + room.disconnect(b); + const d = room.effectiveDeadline()!; + expect(d).toBeGreaterThan(h.clock.now()); + h.clock.advance(d - h.clock.now()); + room.onTimer(); + expect(s().status.B).toBe('done'); + expect(s().status.A).toBe('playing'); + // Nothing else is due: no timer fires again for B. + expect(room.effectiveDeadline()).toBeNull(); + room.act('A', 1, { type: 'stop' }); + expect(room.game!.finished).toBe(true); + expect(s().final!.summary).toContain('모두 끝냈어요'); + }); }); diff --git a/apps/server/src/rooms/catchmind.room.test.ts b/apps/server/src/rooms/catchmind.room.test.ts index 9b8234b..3500747 100644 --- a/apps/server/src/rooms/catchmind.room.test.ts +++ b/apps/server/src/rooms/catchmind.room.test.ts @@ -10,7 +10,7 @@ import { RoomStore } from './store'; type Msgs = ServerMessage[]; type StateMsg = Extract; -function harness(players: string[]) { +function harness(players: string[], options: Record = {}) { const db = openDb(':memory:'); const store = new RoomStore(db); let now = 1_000_000; @@ -19,7 +19,7 @@ function harness(players: string[]) { const deps = { store, games, users: { publicUser: (id: string) => ({ id, nickname: id, avatar: null, kind: 'guest' as const }) }, now: clock.now }; const config: RoomConfig = { gameId: 'catchmind', - options: games.catchmind.defaultOptions, + options: { ...games.catchmind.defaultOptions, ...options }, maxPlayers: players.length, visibility: 'private', allowSpectators: true, @@ -170,12 +170,29 @@ describe('그림 맞히기 room flow', () => { expect(state().away).toEqual([d]); }); + test('그리기 무제한: 연결된 출제자는 타이머 없음, 연결이 끊기면 10초 뒤 턴 종료', () => { + const { room, clock, conns, state, act } = harness(['A', 'B'], { drawSeconds: null, hints: 'basic' }); + const d = state().turn.drawer; + act(d, { type: 'chooseWord', index: 0 }); + expect(state().turn.endsAt).toBeNull(); + expect(room.effectiveDeadline()).toBeNull(); + clock.advance(600_000); + expect(state().turn.phase).toBe('drawing'); + room.disconnect(conns[d]!); + room.clearTimer(); + expect(room.effectiveDeadline()).toBe(clock.now() + 10_000); + clock.advance(10_000); + room.onTimer(); + room.clearTimer(); + expect(state().turn.endReason).toBe('drawerAway'); + }); + test('연결된 출제자는 힌트·시간 만료 때만 tick(10초 지나도 끝나지 않음)', () => { const { room, clock, state, act } = harness(['A', 'B']); const d = state().turn.drawer; act(d, { type: 'chooseWord', index: 0 }); const t0 = state().turn.startedAt; - const ends = state().turn.endsAt; + const ends = state().turn.endsAt!; expect(room.effectiveDeadline()).toBe(t0 + (ends - t0) / 2); clock.advance(20_000); room.onTimer(); diff --git a/apps/server/src/rooms/liar.room.test.ts b/apps/server/src/rooms/liar.room.test.ts index 7f06f7d..2a6ea25 100644 --- a/apps/server/src/rooms/liar.room.test.ts +++ b/apps/server/src/rooms/liar.room.test.ts @@ -114,4 +114,17 @@ describe('라이어 게임 room flow with computers', () => { expect(state().descriptions.filter((d) => d.from === 'A').every((d) => d.text === null)).toBe(true); expect(logs).toEqual([]); }); + + test('모든 시간 무제한: 컴퓨터는 알아서 하고, 연결이 끊긴 사람은 유예 시간 뒤 넘겨져 끝까지 가요', () => { + const { room, conn, run, state, logs } = practice(); + const none = { describeSeconds: null, discussionSeconds: null, voteSeconds: null, guessSeconds: null }; + expect(room.configure('A', { options: { ...(room.config.options as object), ...none } })).toBeNull(); + room.start('A'); + room.disconnect(conn); + run(); + expect(room.game!.finished).toBe(true); + expect(state().options.describeSeconds).toBeNull(); + expect(state().descriptions.filter((d) => d.from === 'A').every((d) => d.text === null)).toBe(true); + expect(logs).toEqual([]); + }); }); diff --git a/apps/server/src/rooms/mafia.room.test.ts b/apps/server/src/rooms/mafia.room.test.ts index d77bc74..d0a7406 100644 --- a/apps/server/src/rooms/mafia.room.test.ts +++ b/apps/server/src/rooms/mafia.room.test.ts @@ -7,7 +7,7 @@ import { openDb } from '../db'; import { Room, type Conn, type RoomConfig } from './room'; import { RoomStore } from './store'; -function harness(players: string[]) { +function harness(players: string[], options: Record = {}) { const db = openDb(':memory:'); const store = new RoomStore(db); let now = 1_000_000; @@ -16,7 +16,7 @@ function harness(players: string[]) { const deps = { store, games, users: { publicUser: (id: string) => ({ id, nickname: id, avatar: null, kind: 'guest' as const }) }, now: clock.now }; const config: RoomConfig = { gameId: 'mafia', - options: { ...games.mafia.defaultOptions, firstPhase: 'night' }, + options: { ...games.mafia.defaultOptions, firstPhase: 'night', ...options }, maxPlayers: players.length, visibility: 'private', allowSpectators: true, @@ -67,4 +67,23 @@ describe('마피아 room flow', () => { expect(state().phase.kind).toBe('discussion'); expect(state().day).toBe(2); }); + + test('밤 시간 무제한: 타이머 없이 모두 밤 마치기를 누를 때까지, 연결이 끊긴 사람은 유예 시간 뒤 넘김', () => { + const { room, clock, conns, state } = harness(['A', 'B', 'C', 'D'], { nightSeconds: null }); + expect(room.start('A')).toBeNull(); + clock.advance(8_000); + room.onTimer(); + expect(state().phase.kind).toBe('night'); + expect(room.effectiveDeadline()).toBeNull(); + let cs = 10; + for (const p of ['A', 'B', 'C']) room.act(p, ++cs, { type: 'readyEarly' }); + clock.advance(3_600_000); + room.onTimer(); + expect(state().phase.kind).toBe('night'); + room.disconnect(conns.D!); + expect(room.effectiveDeadline()).toBe(clock.now() + 60_000); + clock.advance(60_000); + room.onTimer(); + expect(state().phase.kind).toBe('discussion'); + }); }); diff --git a/apps/web/src/games/apple/help.test.ts b/apps/web/src/games/apple/help.test.ts index 276e3f0..5ca0f34 100644 --- a/apps/web/src/games/apple/help.test.ts +++ b/apps/web/src/games/apple/help.test.ts @@ -40,3 +40,14 @@ test('사과 게임: 막힘 / 나감 / 끝', () => { s.final = { endReason: 'time', ranking: [], summary: '시간이 다 됐어요. 사과를 가장 많이 지운 사람이 이겼어요' }; expect(helpNow(view(s, 'A'), 'A', users)).toContain('시간이 다 됐어요'); }); + +test('사과 게임: 제한 시간 무제한 / 여기까지', () => { + const { state: s0 } = setupGame('apple', 3, { timeLimitSec: null }); + expect(helpNow(view(s0, 'A'), 'A', users)).toContain('제한 시간은 없어요'); + const s = playing({ timeLimitSec: null }); + expect(helpNow(view(s, 'A'), 'A', users)).toContain('[여기까지 할래요]'); + expect(helpNow(view(s, null), null, users)).toContain('모두 끝냈을 때'); + s.status.A = 'done'; + s.score.A = 30; + expect(helpNow(view(s, 'A'), 'A', users)).toContain('여기까지 했어요. 사과 30개'); +}); diff --git a/apps/web/src/games/apple/help.ts b/apps/web/src/games/apple/help.ts index 9c3da14..b2c6922 100644 --- a/apps/web/src/games/apple/help.ts +++ b/apps/web/src/games/apple/help.ts @@ -17,17 +17,20 @@ function leaders(v: AppleView, players: Record, me: string | export function helpNow(v: AppleView, me: string | null, players: Record): string { if (v.phase === 'ended') return `게임이 끝났어요. ${v.result?.summary ?? ''}`.trim() + '\n최종 순위에서 각자 지운 사과 개수를 볼 수 있어요.'; const secs = v.options.timeLimitSec; - const limit = secs % 60 === 0 ? `${secs / 60}분` : `${secs}초`; - if (v.phase === 'countdown') return `곧 시작해요. 모두 똑같은 사과 판을 각자 풀어요. 제한 시간은 ${limit}이에요.\n${HOW}`; + const limitLine = secs === null ? '제한 시간은 없어요. 모두 끝낼 때까지 해요.' : `제한 시간은 ${secs % 60 === 0 ? `${secs / 60}분` : `${secs}초`}이에요.`; + if (v.phase === 'countdown') return `곧 시작해요. 모두 똑같은 사과 판을 각자 풀어요. ${limitLine}\n${HOW}`; const mine = v.seats.find((s) => s.id === me) ?? null; const lead = leaders(v, players, me); - if (!mine) return `모두 똑같은 판을 각자 풀고 있어요. 시간이 끝났을 때 사과를 가장 많이 지운 사람이 이겨요.${lead ? `\n${lead}` : ''}`; + const winLine = secs === null ? '모두 끝냈을 때' : '시간이 끝났을 때'; + if (!mine) return `모두 똑같은 판을 각자 풀고 있어요. ${winLine} 사과를 가장 많이 지운 사람이 이겨요.${lead ? `\n${lead}` : ''}`; if (mine.status === 'left') return '게임에서 나갔어요. 남은 사람들이 끝날 때까지 기다려 주세요.'; if (mine.status === 'stuck') { - return `내 판에는 이제 합이 10이 되는 사과 묶음이 없어요. 사과 ${mine.score}개를 지웠어요. 시간이 끝나거나 모두 막히면 순위가 나와요.${lead ? `\n${lead}` : ''}`; + return `내 판에는 이제 합이 10이 되는 사과 묶음이 없어요. 사과 ${mine.score}개를 지웠어요. ${secs === null ? '모두 끝내면' : '시간이 끝나거나 모두 막히면'} 순위가 나와요.${lead ? `\n${lead}` : ''}`; } + if (mine.status === 'done') return `여기까지 했어요. 사과 ${mine.score}개를 지웠어요. 모두 끝내면 순위가 나와요.${lead ? `\n${lead}` : ''}`; const lines = [HOW, '빈 칸은 합에 들어가지 않아서, 사이가 비어 있어도 멀리 있는 사과끼리 묶을 수 있어요.', `지금 내 점수는 사과 ${mine.score}개예요.`]; if (lead) lines.push(lead); + if (secs === null) lines.push('제한 시간이 없어요. 그만하고 싶으면 아래 [여기까지 할래요]를 두 번 눌러요.'); lines.push(KEYS); return lines.join('\n'); } diff --git a/apps/web/src/games/apple/index.tsx b/apps/web/src/games/apple/index.tsx index 10a882b..fece8c3 100644 --- a/apps/web/src/games/apple/index.tsx +++ b/apps/web/src/games/apple/index.tsx @@ -1,10 +1,10 @@ /** 사과 게임 화면 (docs/games/apple.md §9). */ -import { useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react'; +import { useEffect, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent as ReactPointerEvent, type ReactNode } from 'react'; import type { AppleOptions, AppleView, SeatView } from '@bg/games/apple'; 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, tone } from '../../lib/feedback'; import { socket } from '../../net/socket'; import type { BoardProps, GameUI, OptionsProps } from '../types'; import { helpNow } from './help'; @@ -49,7 +49,26 @@ const clock = (ms: number) => { const s = Math.ceil(Math.max(0, ms) / 1000); return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`; }; -const limitLabel = (sec: number) => (sec % 60 === 0 ? `${sec / 60}분` : `${sec}초`); +const limitLabel = (sec: number | null) => (sec === null ? '무제한' : sec % 60 === 0 ? `${sec / 60}분` : `${sec}초`); + +/** Game sounds on top of the shared palette (site volume applies). */ +const apSound = { + /** Apples popping: one rising pop per apple (up to 5), quick enough to finish while they vanish. */ + clear: (n: number) => { + for (let i = 0; i < Math.min(5, n); i++) tone(520 + i * 110, 80, 'sine', 0.16, i * 38, { slideTo: 1100 + i * 160 }); + }, + /** Let go on a sum that is not 10: a soft "thud", no penalty. */ + miss: () => tone(230, 90, 'triangle', 0.09, 0, { slideTo: 180 }), + /** The box being dragged just added up to 10. */ + ten: () => tone(1320, 45, 'triangle', 0.07), + count: () => tone(660, 90, 'triangle', 0.12), + go: () => { + tone(988, 120, 'triangle', 0.14); + tone(1318, 200, 'triangle', 0.12, 90); + }, +}; + +const statusSuffix = (s: SeatView) => (s.status === 'stuck' ? ', 더 지울 사과 없음' : s.status === 'done' ? ', 여기까지 함' : s.status === 'left' ? ', 나감' : ''); /** Ranks by score (ties share), players who left last. */ function ranked(seats: SeatView[]): (SeatView & { rank: number })[] { @@ -89,6 +108,11 @@ const CSS = ` :root[data-theme='dark'] .ap-board { background: #3b2f22; box-shadow: var(--shadow), inset 0 0 0 3px #6b4f2a; } @media (prefers-color-scheme: dark) { :root[data-theme='auto'] .ap-board { background: #3b2f22; box-shadow: var(--shadow), inset 0 0 0 3px #6b4f2a; } } .ap-pop { animation: ap-pop .42s ease-out forwards; transform-box: fill-box; transform-origin: center; pointer-events: none; } +.ap-burst { animation: ap-burst .45s ease-out forwards; transform-box: fill-box; transform-origin: center; pointer-events: none; } +.ap-in { animation: ap-in .34s cubic-bezier(.3,1.5,.5,1) both; animation-delay: var(--d, 0ms); transform-box: fill-box; transform-origin: center; } +.ap-pill b, .ap-others li b { display: inline-block; } +.ap-over.count b { display: block; animation: ap-count .9s ease-out both; } +.ap-stop { min-height: 40px; } .ap-over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; pointer-events: none; border-radius: 14px; text-align: center; padding: 12px; } .ap-over.count { background: rgba(0,0,0,.35); color: #fff; font-size: 5rem; font-weight: 900; text-shadow: 0 3px 8px rgba(0,0,0,.5); } @@ -99,9 +123,12 @@ const CSS = ` .ap-flash.ok { color: var(--success); border: 3px solid var(--success); } .ap-flash.bad { color: var(--text-sub); border: 3px solid var(--border); } .ap-keys { color: var(--text-sub); font-size: .85rem; font-weight: 600; text-align: center; margin: 0; } +@keyframes ap-burst { 0% { transform: scale(.5); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } } +@keyframes ap-in { from { transform: scale(0); opacity: 0; } } +@keyframes ap-count { 0% { transform: scale(1.8); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { transform: scale(.85); opacity: .85; } } @keyframes ap-pop { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.25); opacity: .9; } 100% { transform: scale(.2) translateY(-30px); opacity: 0; } } @keyframes ap-flash { 0% { opacity: 0; transform: translateX(-50%) scale(.8); } 15% { opacity: 1; transform: translateX(-50%) scale(1.05); } 70% { opacity: 1; } 100% { opacity: 0; } } -@media (prefers-reduced-motion: reduce) { .ap-pop { animation-duration: .01s; } .ap-flash { animation: none; } } +@media (prefers-reduced-motion: reduce) { .ap-pop { animation-duration: .01s; } .ap-flash, .ap-in, .ap-burst, .ap-over.count b { animation: none; } .ap-burst { display: none; } } `; // ---------------------------------------------------------------- art @@ -125,13 +152,19 @@ function AppleDefs() { ); } -function AppleCell({ x, y, n }: { x: number; y: number; n: number }) { - return ( - +function AppleCell({ x, y, n, introDelay }: { x: number; y: number; n: number; introDelay?: number }) { + const apple = ( + <> {n} + + ); + return ( + + {/* The CSS animation goes on an inner group: it would replace the SVG translate on the outer one. */} + {introDelay === undefined ? apple : {apple}} ); } @@ -185,7 +218,27 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { const seq = useRef(0); const mine = v.seats.find((s) => s.id === me) ?? null; - const canPlay = !!mine && mine.status === 'playing' && v.phase === 'playing' && !!v.cells && now < v.endsAt; + const canPlay = !!mine && mine.status === 'playing' && v.phase === 'playing' && !!v.cells && (v.endsAt === null || now < v.endsAt); + const unlimited = v.endsAt === null; + const [stopAsk, setStopAsk] = useState(false); + // The board appearing (after the countdown, or when I open the room) pops the apples in, row by row. + const [intro, setIntro] = useState(false); + const hadCells = useRef(null); + useEffect(() => { + const has = !!v.cells; + if (hadCells.current === false && has) setIntro(true); + hadCells.current = has; + }, [v.cells]); + useEffect(() => { + if (!intro) return; + const t = setTimeout(() => setIntro(false), 900); + return () => clearTimeout(t); + }, [intro]); + useEffect(() => { + if (!stopAsk) return; + const t = setTimeout(() => setStopAsk(false), 3000); + return () => clearTimeout(t); + }, [stopAsk]); // My board as I see it: the server's, minus the apples I just cleared and the server has not confirmed yet. const cells = useMemo(() => { @@ -240,17 +293,18 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { } if (sum !== 10) { if (idx.length >= 2 || fromKey) { + apSound.miss(); setFlash({ key: ++seq.current, ok: false, text: `합 ${sum} · 10이 아니에요` }); say(`합이 ${sum}이에요. 딱 10이 되게 골라 주세요.`); } return; } + act({ type: 'select', ...rect }); setGone((g) => [...g, ...idx]); setPops((p) => [...p, { key: ++seq.current, cells: idx.map((i) => ({ i, n: cells.charCodeAt(i) - 48 })) }]); setFlash({ key: ++seq.current, ok: true, text: `+${idx.length}` }); - sounds.stone(); + apSound.clear(idx.length); haptic(15); - act({ type: 'select', ...rect }); say(`사과 ${idx.length}개를 지웠어요.`); }; @@ -316,9 +370,24 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { } }; - const left = Math.max(0, v.endsAt - Math.max(now, v.countdownEndsAt)); + const left = v.endsAt === null ? null : Math.max(0, v.endsAt - Math.max(now, v.countdownEndsAt)); const countdown = v.phase === 'countdown' ? Math.max(1, Math.ceil((v.countdownEndsAt - now) / 1000)) : 0; const sumState = !sel || sel.idx.length === 0 ? 'idle' : sel.sum === 10 ? 'ok' : sel.sum > 10 ? 'over' : 'under'; + // Sounds that follow the clock and the state: 3·2·1, start, last 10 seconds, "10!" while dragging, finished. + const lastSec = v.phase === 'playing' && left !== null && left > 0 && left <= 10_000 ? Math.ceil(left / 1000) : 0; + const heard = useRef({ countdown: 0, lastSec: 0, sum: 'idle', status: mine?.status ?? null }); + useEffect(() => { + const was = heard.current; + if (countdown !== was.countdown) { + if (countdown > 0) apSound.count(); + else if (was.countdown > 0 && v.phase === 'playing') apSound.go(); + } + if (lastSec && lastSec !== was.lastSec) sfx.tick(); + if (sumState === 'ok' && was.sum !== 'ok') apSound.ten(); + const st = mine?.status ?? null; + if (st !== was.status && was.status === 'playing' && (st === 'stuck' || st === 'done') && v.phase === 'playing') sfx.good(); + heard.current = { countdown, lastSec, sum: sumState, status: st }; + }); const others = ranked(v.seats); // Selection rectangle in display coordinates. @@ -348,12 +417,21 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) {
- - ⏱ {clock(left)} - + {left === null ? ( + + ⏱ 무제한 + + ) : ( + + ⏱ {clock(left)} + + )} {mine && ( - 🍎 {mine.score} + 🍎{' '} + + {mine.score} + )} {mine && v.phase !== 'ended' && ( @@ -365,11 +443,13 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { {v.seats.length > 1 && (
    {others.map((s) => ( -
  1. +
  2. {s.id === me ? '나' : nick(players, s.id)} - {s.score} - {s.status === 'stuck' && ✔} + + {s.score} + + {(s.status === 'stuck' || s.status === 'done') && ✔}
  3. ))}
@@ -403,14 +483,17 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { const n = ch.charCodeAt(0) - 48; if (n <= 0) return null; const [dr, dc] = toDisp([Math.floor(i / COLS), i % COLS]); - return ; + return ; })} {pops.map((p) => p.cells.map(({ i, n }) => { const [dr, dc] = toDisp([Math.floor(i / COLS), i % COLS]); return ( - - + + + + + ); }), @@ -425,7 +508,7 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { )} {countdown > 0 && (
- {countdown} + {countdown} 합이 10이 되게 사과를 묶어요!
)} @@ -434,9 +517,27 @@ function AppleBoard({ view: v, me, players, act }: BoardProps) { 더 지울 수 있는 사과가 없어요! 사과 {mine.score}개 · 끝날 때까지 기다려요
)} + {mine && mine.status === 'done' && v.phase === 'playing' && ( +
+ 여기까지 했어요! 사과 {mine.score}개 · 모두 끝날 때까지 기다려요 +
+ )} {mine && mine.status === 'left' && v.phase !== 'ended' &&
게임에서 나갔어요.
} {!mine && v.phase !== 'ended' &&
관전 중이에요 · 위에서 점수를 볼 수 있어요
}
+ {unlimited && canPlay && ( + + )} {!phone && mine && v.phase !== 'ended' &&

마우스로 드래그해서 합이 10이면 손을 떼요 · 키보드: 화살표 + 스페이스(시작점·끝점), Esc 취소

}

{announce} @@ -454,14 +555,14 @@ function AppleSide({ view: v, me, players }: BoardProps) {

사과 게임{v.phase === 'ended' ? ' · 게임 끝' : ''} - 17×10 판 · 제한 시간 {limitLabel(v.options.timeLimitSec)} · 모두 같은 판 + 17×10 판 · 제한 시간 {limitLabel(v.options.timeLimitSec)}{v.options.timeLimitSec === null ? '(모두 끝낼 때까지)' : ''} · 모두 같은 판
    {rows.map((s) => (
  1. {s.rank}등 @@ -470,7 +571,7 @@ function AppleSide({ view: v, me, players }: BoardProps) { {nick(players, s.id)} {s.id === me ? ' (나)' : ''} - {s.status === 'stuck' ? ' · 다 지움' : s.status === 'left' ? ' · 나감' : ''} + {s.status === 'stuck' ? ' · 다 지움' : s.status === 'done' ? ' · 여기까지' : s.status === 'left' ? ' · 나감' : ''} 🍎 {s.score} @@ -514,12 +615,13 @@ function statusText(v: AppleView, me: string | null, players: Record({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { +function Seg({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { return (
    {options.map(([k, l]) => ( @@ -543,10 +645,15 @@ function Options({ value: o, onChange }: OptionsProps) { [60, '1분'], [120, '2분'], [180, '3분'], + [null, '무제한'], ]} onChange={(timeLimitSec) => onChange({ ...o, timeLimitSec })} /> - 원래 게임은 2분이에요. 시간이 끝났을 때 사과를 가장 많이 지운 사람이 이겨요. + + {o.timeLimitSec === null + ? '시간 제한 없이 각자 더 지울 사과가 없거나 [여기까지 할래요]를 누를 때까지 해요. 모두 끝나면 가장 많이 지운 사람이 이겨요.' + : '원래 게임은 2분이에요. 시간이 끝났을 때 사과를 가장 많이 지운 사람이 이겨요.'} +
); @@ -559,7 +666,8 @@ function optionsSummary(o: AppleOptions): string { // ---------------------------------------------------------------- rules function Rules({ options }: { options?: AppleOptions }) { - const limit = limitLabel(options?.timeLimitSec ?? 120); + const limitSec = options ? options.timeLimitSec : 120; + const limit = limitLabel(limitSec); return (

@@ -576,7 +684,10 @@ function Rules({ options }: { options?: AppleOptions }) { 일어나지 않고 벌칙도 없어요. 지운 자리는 빈 칸이 되고 빈 칸은 합에 들어가지 않아서, 사이가 비면 멀리 있는 사과끼리도 묶을 수 있어요.

- 제한 시간은 {limit}이에요. 시간이 끝나면 사과를 가장 많이 지운 사람이 이기고, 개수가 같으면 같은 순위예요. 모두 더 지울 수 있는 묶음이 없으면 조금 일찍 끝나요. 혼자서도 할 수 있어요. + {limitSec === null + ? '이 방은 제한 시간이 없어요. 각자 더 지울 수 있는 묶음이 없거나 [여기까지 할래요]를 누르면 끝나고, 모두 끝나면 사과를 가장 많이 지운 사람이 이겨요. 개수가 같으면 같은 순위예요. 연결이 끊긴 채 오래 돌아오지 않으면 그때까지 점수로 끝낸 것으로 봐요.' + : `제한 시간은 ${limit}이에요. 시간이 끝나면 사과를 가장 많이 지운 사람이 이기고, 개수가 같으면 같은 순위예요. 모두 더 지울 수 있는 묶음이 없으면 조금 일찍 끝나요.`}{' '} + 혼자서도 할 수 있어요.

휴대폰에서는 판을 세로로 돌려서 보여 줘요. 키보드로는 화살표로 칸을 옮기고 스페이스(또는 Enter)로 시작점, 한 번 더 눌러 끝점을 정해요. Esc는 취소예요. diff --git a/apps/web/src/games/catchmind/help.test.ts b/apps/web/src/games/catchmind/help.test.ts index 0cd2d60..b4206d6 100644 --- a/apps/web/src/games/catchmind/help.test.ts +++ b/apps/web/src/games/catchmind/help.test.ts @@ -57,3 +57,13 @@ test('그림 맞히기: 공개 / 끝', () => { s.final = { ranking: [], turns: [], summary: '호랑이님 우승!' }; expect(helpNow(view(s, null), null, users)).toContain('호랑이님 우승!'); }); + +test('그림 맞히기: 그리기 무제한이면 출제자에게 정답 공개 안내', async () => { + const { setupGame, usersOf } = await import('../help-kit.test-util'); + const { GAMES } = await import('@bg/games'); + const users = usersOf(['A', 'B', 'C']); + const { state } = setupGame('catchmind', 3, { drawSeconds: null, wordChoice: false }); + const d: string = state.turn.drawer; + const t = helpNow(GAMES.catchmind!.view(state, d) as never, d, users); + expect(t).toContain('[정답 공개하고 넘기기]'); +}); diff --git a/apps/web/src/games/catchmind/help.ts b/apps/web/src/games/catchmind/help.ts index 1a7f729..8d99bc4 100644 --- a/apps/web/src/games/catchmind/help.ts +++ b/apps/web/src/games/catchmind/help.ts @@ -32,7 +32,7 @@ export function helpNow(v: CatchmindView, me: string | null, players: Record, id: string) => players[id]?.nickname ?? '나간 사람'; const userOf = (players: Record, id: string): PublicUser => players[id] ?? { id, nickname: '나간 사람', avatar: null, kind: 'guest' }; +/** Game sounds on top of the shared palette (site volume applies). */ +const cmSound = { + /** Pencil touching the paper (drawer's own strokes only). */ + scribble: () => noise(50, 0.05, 0, 'highpass', 4500), + /** A hint letter turned over. */ + hint: () => { + tone(880, 70, 'triangle', 0.1); + tone(1320, 110, 'triangle', 0.08, 60); + }, + /** Somebody else got it. */ + otherCorrect: () => tone(1175, 120, 'triangle', 0.1), + /** "아까워요!" (only the sender sees it). */ + close: () => tone(700, 90, 'triangle', 0.1, 0, { slideTo: 600 }), + /** The drawer's reaction button (heard by the guessers). */ + react: () => tone(990, 60, 'sine', 0.08), +}; + const CSS = ` .cm { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 8px; align-self: center; } .cm-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: space-between; font-weight: 700; } @@ -139,6 +156,12 @@ const CSS = ` .cm-form { display: flex; gap: 6px; } .cm-form .input { flex: 1; min-height: 48px; font-size: 1.05rem; } .cm-close { color: var(--warning); font-weight: 900; font-size: .95rem; animation: cm-shake .4s ease; } +.cm-over { animation: fade .25s ease both; } +.cm-over .word { animation: cm-word .5s cubic-bezier(.3,1.6,.5,1) both; animation-delay: .1s; } +.cm-hint .ch.flip { animation: anim-flip .42s ease both; } +.cm-strip .p .sc, .cm-score strong { display: inline-block; } +.cm-unl { font-weight: 800; color: var(--text-sub); font-size: .92rem; } +@keyframes cm-word { from { transform: scale(.3) rotate(-6deg); opacity: 0; } } .cm-away { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; background: var(--warning-soft); color: var(--text); border-radius: 12px; padding: 8px 12px; } @keyframes cm-pop { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 0; } 70% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } } @keyframes cm-shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } } @@ -156,7 +179,7 @@ const CSS = ` .cm-hint .ch { min-width: 34px; height: 40px; font-size: 1.35rem; } } @media (prefers-reduced-motion: reduce) { - .cm-pop, .cm-close { animation: none; } + .cm-pop, .cm-close, .cm-over, .cm-over .word, .cm-hint .ch.flip { animation: none; } .cm-bar i { transition: none; } } `; @@ -507,6 +530,7 @@ function Paper({ v, me, act, players }: { v: CatchmindView; me: string | null; a sender.begin(t.c, t.w, ex, x, y); drawing.apply({ k: 'b', s: sender.stroke, c: t.c, w: t.w, e: ex }); drawing.addPoint(x, y); + cmSound.scribble(); }; const onMove = (e: React.PointerEvent) => { if (active.current !== e.pointerId) return; @@ -606,6 +630,7 @@ function Paper({ v, me, act, players }: { v: CatchmindView; me: string | null; a ))}

+ {v.options.drawSeconds === null && } {!wide && 그리는 동안에는 채팅 대신 반응 버튼만 쓸 수 있어요.} )} @@ -613,6 +638,29 @@ function Paper({ v, me, act, players }: { v: CatchmindView; me: string | null; a ); } +/** 무제한 drawings: the drawer may open the answer (press twice). */ +function GiveUp({ act }: { act: (a: unknown) => void }) { + const [ask, setAsk] = useState(false); + useEffect(() => { + if (!ask) return; + const t = setTimeout(() => setAsk(false), 3000); + return () => clearTimeout(t); + }, [ask]); + return ( + + ); +} + const END_TEXT: Record = { time: '시간이 다 됐어요', allSolved: '모두 맞혔어요!', @@ -620,6 +668,7 @@ const END_TEXT: Record = { report: '글자를 썼다는 신고로 끝났어요(출제자 0점)', drawerAway: '출제자의 연결이 끊겼어요', drawerLeft: '출제자가 나갔어요', + giveUp: '출제자가 정답을 공개했어요', }; function Overlay({ v, me, act, players, onSave }: { v: CatchmindView; me: string | null; act: (a: unknown) => void; players: Record; onSave: () => void }) { @@ -663,7 +712,12 @@ function OverlayMain({ v, act, players, onSave }: { v: CatchmindView; act: (a: u

그릴 단어를 골라 주세요

{v.choices.map((c, i) => ( -
@@ -807,7 +875,7 @@ function ScoreList({ v, me, players }: { v: CatchmindView; me: string | null; pl ✓ 맞힘 )} - + {v.scores[id] ?? 0}점 @@ -917,7 +985,7 @@ function GuessPanel({ v, me, players, act, pending }: { v: CatchmindView; me: st {v.chat.map((m) => { const { cls, body } = chatLine(m, me, players, v.drawer); return ( -
  • +
  • {body}
  • ); @@ -983,8 +1051,40 @@ function AwayBanner({ v, me, act }: { v: CatchmindView; me: string | null; act: ); } +/** Sounds for what happens on the table (my own "정답!" is played by the overlay). */ +function useTableSounds(v: CatchmindView, me: string | null): void { + const prev = useRef(v); + useEffect(() => { + const p = prev.current; + prev.current = v; + if (p === v) return; + const turnChanged = p.turnNo !== v.turnNo; + if (turnChanged && v.phase === 'choosing') { + if (v.drawer === me) { + sounds.myTurn(); + sfx.deal(v.choices?.length ?? 1); + } else sfx.whoosh(); + } + if (v.phase === 'drawing' && (p.phase !== 'drawing' || turnChanged)) sfx.whoosh(); + if (!turnChanged && v.phase === 'drawing' && v.hintStage > p.hintStage) cmSound.hint(); + // New chat lines: someone else got it, the drawer reacted, my "아까워요". + const seen = p.chat.at(-1)?.id ?? 0; + const fresh = v.chat.filter((m) => m.id > seen); + if (fresh.some((m) => m.kind === 'correct' && m.from !== me)) cmSound.otherCorrect(); + if (v.role !== 'drawer' && fresh.some((m) => m.kind === 'reaction')) cmSound.react(); + if (fresh.some((m) => m.kind === 'close' && m.from === me)) cmSound.close(); + if (!turnChanged && p.phase === 'drawing' && v.phase === 'reveal') { + if (v.endReason === 'report') sfx.alarm(); + else if (v.endReason === 'allSolved') sfx.fanfare(); + else if (v.solvers.length === 0) sfx.bad(); + else sfx.cardFlip(); + } + }, [v]); // eslint-disable-line react-hooks/exhaustive-deps +} + function CatchmindBoard({ view: v, me, players, act, pending }: BoardProps) { const wide = useWide(); + useTableSounds(v, me); return (
    @@ -1068,7 +1168,7 @@ function statusText(v: CatchmindView, me: string | null, players: Record({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { +function Seg({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { return (
    {options.map(([k, l]) => ( @@ -1137,9 +1237,11 @@ function Options({ value: o, onChange }: OptionsProps) { [80, '80초'], [100, '100초'], [120, '120초'], + [null, '무제한'], ]} onChange={(drawSeconds) => set({ drawSeconds })} /> + {o.drawSeconds === null && 맞힐 때까지 그려요. 아무도 못 맞히면 출제자가 [정답 공개하고 넘기기]로 넘겨요. 힌트는 80초 기준으로 나와요.} ) { function optionsSummary(o: CatchmindOptions): string { const hint = o.hints === 'full' ? '힌트 많이' : o.hints === 'basic' ? '글자 수 힌트' : '힌트 없음'; const diff = o.difficulty === 'easy' ? '쉬운 단어' : o.difficulty === 'normal' ? '보통 단어' : ''; - return [o.guessMode === 'multi' ? '여러 명 맞히기' : '첫 정답자만', `${o.rounds}라운드`, `${o.drawSeconds}초`, hint, diff, o.customOnly ? '추가 단어만' : ''].filter(Boolean).join(' · '); + return [o.guessMode === 'multi' ? '여러 명 맞히기' : '첫 정답자만', `${o.rounds}라운드`, o.drawSeconds === null ? '그리기 무제한' : `${o.drawSeconds}초`, hint, diff, o.customOnly ? '추가 단어만' : ''].filter(Boolean).join(' · '); } // ---------------------------------------------------------------- rules @@ -1223,7 +1325,7 @@ function Rules({ options }: { options?: CatchmindOptions }) {

    한 사람(출제자)이 제시어를 그림으로 그리고, 나머지는 그림을 보며 채팅으로 정답을 맞혀요. 차례대로 돌아가며 모두 한 번씩 그리면 1라운드예요 - {o ? `(이 방은 ${o.rounds}라운드, 그리기 ${o.drawSeconds}초)` : ''}. + {o ? `(이 방은 ${o.rounds}라운드, 그리기 ${o.drawSeconds === null ? '시간 무제한' : `${o.drawSeconds}초`})` : ''}.

    출제자는 단어 3개 중 하나를 10초 안에 골라요. 그리는 동안에는 글자를 쓰면 안 되고, 채팅 대신 "거의 다 왔어요" 같은 반응 버튼만 쓸 수 있어요. 글자를 쓰면 맞히는 사람들이 신고할 수 있어요. @@ -1234,7 +1336,10 @@ function Rules({ options }: { options?: CatchmindOptions }) { : '먼저 맞힐수록 점수가 커요: 10점, 8점, 6점, 그다음부터 4점. 출제자는 맞힌 사람 1명마다 2점(최대 12점)을 받아요.'}{' '} 띄어쓰기·문장부호는 무시하고, "사과요"처럼 끝에 붙인 말도 정답으로 봐요. 거의 맞히면 나에게만 "아까워요!"가 떠요.

    -

    시간이 지나면 힌트가 나와요: 처음엔 글자 수, 절반이 지나면 초성, 3/4이 지나면 한 글자. 점수가 같으면 많이 맞힌 사람이 앞서요.

    +

    + 시간이 지나면 힌트가 나와요: 처음엔 글자 수, 절반이 지나면 초성, 3/4이 지나면 한 글자.{' '} + {o?.drawSeconds === null ? '그리기 시간이 무제한이면 40초에 초성, 60초에 한 글자가 나오고, 아무도 못 맞히면 출제자가 정답을 공개하고 넘길 수 있어요. ' : ''}점수가 같으면 많이 맞힌 사람이 앞서요. +

    ); } diff --git a/apps/web/src/games/clue/index.tsx b/apps/web/src/games/clue/index.tsx index fec2a03..5e63534 100644 --- a/apps/web/src/games/clue/index.tsx +++ b/apps/web/src/games/clue/index.tsx @@ -1,5 +1,5 @@ /** 클루 화면 (docs/games/clue.md §9). */ -import { useEffect, useMemo, useRef, useState } from 'react'; +import { useEffect, useMemo, useRef, useState, type CSSProperties } from 'react'; import type { ClueOptions, ClueView, SuggestionView } from '@bg/games/clue'; import { PASSAGES, @@ -23,7 +23,7 @@ import { 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, sfx, sounds, tone } from '../../lib/feedback'; import type { BoardProps, GameUI, OptionsProps } from '../types'; import { helpNow } from './help'; import { quickStart } from './quick'; @@ -55,12 +55,29 @@ const ro = (word: string) => { }; const lastOf = (xs: readonly T[]): T | undefined => xs[xs.length - 1]; +/** Clock length for the timer ring (무제한 has no deadline, so the ring only shows for away players' grace). */ function totalMsOf(v: ClueView): number { if (v.phase.kind === 'refute') return 20_000; if ((v.idle[v.current] ?? 0) >= 3) return 10_000; - return v.options.turnSeconds * 1000; + return (v.options.turnSeconds ?? 60) * 1000; } +/** Game sounds on top of the shared palette (site volume applies). */ +const clSound = { + /** "그건 바로…!" a suggestion is made: a low questioning motif. */ + suggest: () => [330, 392, 466].forEach((f, i) => tone(f, 150, 'triangle', 0.1, i * 110)), + /** Nobody could show a card: a suspenseful low "dun-dun". */ + noneShown: () => { + tone(196, 260, 'sawtooth', 0.05); + tone(185, 420, 'sawtooth', 0.05, 280); + }, + /** Walking a few squares in the hallway. */ + steps: (n: number) => { + for (let i = 0; i < Math.min(4, n); i++) tone(i % 2 ? 520 : 440, 45, 'triangle', 0.09, i * 120); + }, +}; +const posKey = (p: Pos) => JSON.stringify(p); + /** The player the game waits on (refuter while a card is being chosen). */ const waitingOn = (v: ClueView): string => (v.phase.kind === 'refute' ? v.phase.refuter : v.current); @@ -81,7 +98,7 @@ function knownCards(v: ClueView): Map { } const CSS = ` -.cl-board { width: 100%; max-width: 1040px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; } +.cl-board { position: relative; width: 100%; max-width: 1040px; max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px; } .cl-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; align-items: start; } .cl-map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(4, minmax(84px, auto)); grid-template-areas: "k b c" "d m bi" "d m li" "lo h s"; gap: 6px; background: var(--wood); padding: 8px; border-radius: var(--radius-lg); box-shadow: var(--shadow); } @@ -133,7 +150,15 @@ button.cl-room:disabled { cursor: default; } button.cl-card { cursor: pointer; font: inherit; font-weight: 800; font-size: .8rem; } button.cl-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; } button.cl-card.can { box-shadow: 0 0 0 3px var(--primary); } -.cl-card.new { animation: cl-pop .6s ease-out; } +.cl-card.new { animation: cl-pop .6s ease-out; animation-delay: var(--anim-delay, 0ms); animation-fill-mode: both; } +.cl-dice span { display: inline-block; } +.cl-room.landed { animation: cl-land .7s ease-out; } +.cl-banner { position: absolute; left: 50%; top: 30%; translate: -50% 0; z-index: 8; pointer-events: none; border-radius: 18px; padding: 12px 22px; font-weight: 900; font-size: 1.35rem; + background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.35); text-align: center; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; } +.cl-banner.ok { border: 4px solid var(--success); color: var(--success); } +.cl-banner.bad { border: 4px solid var(--danger); color: var(--danger); } +.cl-banner.info { border: 4px solid var(--primary); color: var(--text); } +@keyframes cl-land { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--focus) 80%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } } @keyframes cl-pop { 0% { transform: scale(.6) rotate(-8deg); opacity: .2; } 100% { transform: none; opacity: 1; } } .cl-sec { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; } .cl-note { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; } @@ -166,20 +191,20 @@ 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; } } -@media (prefers-reduced-motion: reduce) { .cl-card.new { animation: none; } } +@media (prefers-reduced-motion: reduce) { .cl-card.new, .cl-room.landed { animation: none; } } `; // ---------------------------------------------------------------- small pieces -function Token({ x, me }: { x: Suspect; me?: boolean }) { +function Token({ x, me, pop }: { x: Suspect; me?: boolean; pop?: boolean }) { return ( - + {SUSPECT_SHORT[x]} ); } -function Card({ id, onClick, can, fresh, label }: { id: string; onClick?: () => void; can?: boolean; fresh?: boolean; label?: string }) { +function Card({ id, onClick, can, fresh, label, delay }: { id: string; onClick?: () => void; can?: boolean; fresh?: boolean; label?: string; delay?: number }) { const x = itemOf(id); const cat = categoryOf(x); const body = ( @@ -199,7 +224,7 @@ function Card({ id, onClick, can, fresh, label }: { id: string; onClick?: () => ); return ( - + {body} ); @@ -214,9 +239,67 @@ function ClueBoard({ view: v, me, players, act, pending }: BoardProps) const [announce, setAnnounce] = useState(''); const prevTurn = useRef(`${v.current}|${v.turnNo}`); const prevSg = useRef(JSON.stringify(lastOf(v.suggestions) ?? null)); + const prevView = useRef(v); + const [banner, setBanner] = useState<{ key: string; kind: 'ok' | 'bad' | 'info'; text: string } | null>(null); + const [landed, setLanded] = useState<{ room: Room; key: number } | null>(null); useEffect(() => setSel(null), [v.phase.kind, v.current, v.turnNo]); + // Sounds and highlights for what anyone just did: dice, moves, passages, suggestions, answers, accusations. + useEffect(() => { + const p = prevView.current; + prevView.current = v; + if (p === v) return; + if (v.dice && (!p.dice || p.turnNo !== v.turnNo || p.dice[0] !== v.dice[0] || p.dice[1] !== v.dice[1])) sfx.dice(); + const mover = v.suspectOf[v.current]; + let moved = false; + for (const x of SUSPECTS) { + if (posKey(v.pos[x]) === posKey(p.pos[x])) continue; + moved = true; + const r = roomAt(v.pos[x]); + if (r && x === mover) setLanded({ room: r, key: Date.now() }); + } + const sgNew = v.suggestions.length > p.suggestions.length; + if (moved && !sgNew && mover) { + const from = roomAt(p.pos[mover]); + const to = roomAt(v.pos[mover]); + if (from && to && PASSAGES[from] === to && !v.dice) sfx.whoosh(); + else if (to) sfx.piece(); + else clSound.steps(v.dice ? v.dice[0] + v.dice[1] : 3); + } + if (sgNew) clSound.suggest(); + const lastNow = lastOf(v.suggestions); + const lastPrev = lastOf(p.suggestions); + 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(); + } + 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(); + if (v.accusations.length > p.accusations.length) { + const a = v.accusations[v.accusations.length - 1]!; + const who = a.by === me ? '내' : `${nick(players, a.by)}님의`; + if (a.correct) { + // The game ends here: the room plays win / lose. + setBanner({ key: `a${v.accusations.length}`, kind: 'ok', text: `⚖️ ${who} 고발이 맞았어요!` }); + } else { + sfx.bad(); + setBanner({ key: `a${v.accusations.length}`, kind: 'bad', text: `⚖️ ${who} 고발이 틀렸어요 · 탈락` }); + } + } + }, [v]); // eslint-disable-line react-hooks/exhaustive-deps + + useEffect(() => { + if (!banner) return; + const t = setTimeout(() => setBanner(null), 1700); + return () => clearTimeout(t); + }, [banner]); + useEffect(() => { + if (!landed) return; + const t = setTimeout(() => setLanded(null), 800); + return () => clearTimeout(t); + }, [landed]); + useEffect(() => { const key = `${v.current}|${v.turnNo}`; if (key !== prevTurn.current && v.phase.kind !== 'finished') { @@ -250,11 +333,16 @@ function ClueBoard({ view: v, me, players, act, pending }: BoardProps)
    - +
    {amPlayer && } {amPlayer && } + {banner && ( +
    + {banner.text} +
    + )}

    {announce}

    @@ -262,7 +350,21 @@ function ClueBoard({ view: v, me, players, act, pending }: BoardProps) ); } -function Mansion({ view: v, me, myTurn, sel, setSel }: { view: ClueView; me: string | null; myTurn: boolean; sel: Room | null; setSel: (r: Room | null) => void }) { +function Mansion({ + view: v, + me, + myTurn, + sel, + setSel, + landed, +}: { + view: ClueView; + me: string | null; + myTurn: boolean; + sel: Room | null; + setSel: (r: Room | null) => void; + landed: Room | null; +}) { const mySuspect = me ? v.suspectOf[me] : undefined; const myPos = mySuspect ? v.pos[mySuspect] : null; const here = myPos ? roomAt(myPos) : null; @@ -282,7 +384,7 @@ function Mansion({ view: v, me, myTurn, sel, setSel }: { view: ClueView; me: str const can = picking && r !== here; const reach = can && (free || (d !== undefined && d <= sum)); const pass = PASSAGES[r]; - const cls = ['cl-room', can ? (reach ? 'reach' : 'far') : '', sel === r ? 'sel' : '', r === here ? 'here' : ''].filter(Boolean).join(' '); + const cls = ['cl-room', can ? (reach ? 'reach' : 'far') : '', sel === r ? 'sel' : '', r === here ? 'here' : '', landed === r ? 'landed' : ''].filter(Boolean).join(' '); const label = [ ROOM_KO[r], r === here ? '내가 있는 방' : '', @@ -302,10 +404,10 @@ function Mansion({ view: v, me, myTurn, sel, setSel }: { view: ClueView; me: str {can && !free && d !== undefined && {d}칸} {toks.map((x) => ( - + ))} {weaps.map((w) => ( - + {WEAPON_ICON[w]} ))} @@ -337,7 +439,7 @@ function Mansion({ view: v, me, myTurn, sel, setSel }: { view: ClueView; me: str const p = owner(x); return (
  • - + {hallwayText(v.pos[x])}
  • ); @@ -500,8 +602,8 @@ function ActionPanel({ {v.final?.summary} {v.solution && (
    - {[v.solution.suspect, v.solution.weapon, v.solution.room].map((x) => ( - + {[v.solution.suspect, v.solution.weapon, v.solution.room].map((x, i) => ( + ))}
    )} @@ -517,7 +619,7 @@ function ActionPanel({ {nick(players, sg.by)}님이 {ro(triple(sg))} 추리했어요 - 내 카드 중 하나를 골라 {nick(players, sg.by)}님에게만 보여 줘요. 다른 사람은 내가 보여 줬다는 것만 알아요. 20초 안에 안 고르면 자동으로 보여 줘요. + 내 카드 중 하나를 골라 {nick(players, sg.by)}님에게만 보여 줘요. 다른 사람은 내가 보여 줬다는 것만 알아요.{v.options.turnSeconds === null ? '' : ' 20초 안에 안 고르면 자동으로 보여 줘요.'}
    {(ph.canShow ?? []).map((c) => ( !pending && act({ type: 'show', card: c })} label={`${ITEM_KO[itemOf(c)]} 카드 보여 주기`} /> @@ -616,8 +718,12 @@ function ActionPanel({
    {v.dice && (
    - {DICE[v.dice[0]]} - {DICE[v.dice[1]]} + + {DICE[v.dice[0]]} + + + {DICE[v.dice[1]]} + = {sum}칸
    )} @@ -876,7 +982,7 @@ function statusText(v: ClueView, me: string | null, players: Record({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { +function Seg({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { return (
    {options.map(([k, l]) => ( @@ -914,16 +1020,18 @@ function Options({ value: o, onChange }: OptionsProps) { [45, '45초'], [60, '60초'], [90, '90초'], + [null, '무제한'], ]} onChange={(turnSeconds) => set({ turnSeconds })} /> + {o.turnSeconds === null && 차례와 카드 보여 주기에 시간 제한이 없어요. 연결이 끊긴 채 돌아오지 않는 사람만 자동으로 넘겨요.}
    ); } function optionsSummary(o: ClueOptions): string { - return [o.movement === 'free' ? '빠른 이동' : '주사위 이동', `차례 ${o.turnSeconds}초`].join(' · '); + return [o.movement === 'free' ? '빠른 이동' : '주사위 이동', o.turnSeconds === null ? '차례 시간 무제한' : `차례 ${o.turnSeconds}초`].join(' · '); } function Rules({ options }: { options?: ClueOptions }) { @@ -956,7 +1064,10 @@ function Rules({ options }: { options?: ClueOptions }) { 추리 노트: 화면 아래 노트에 내 카드, 공개 카드, 나에게 보여 준 카드가 자동으로 ✗ 표시돼요. 나머지는 직접 눌러 ✗·?·✓를 적어 두세요(이 기기에만 저장돼요).

    - 차례 시간이 지나면 가까운 방으로 움직이고 추리 없이 차례가 넘어가요. 카드를 보여 줄 때는 20초 안에 고르지 않으면 맞는 카드가 자동으로 보여져요. 게임 중에 나간 사람의 카드는 모두에게 공개돼요. + {options?.turnSeconds === null + ? '이 방은 차례 시간이 무제한이에요. 연결이 끊긴 채 돌아오지 않으면 가까운 방으로 움직이고 추리 없이 차례가 넘어가요(카드 보여 주기는 맞는 카드가 자동으로).' + : '차례 시간이 지나면 가까운 방으로 움직이고 추리 없이 차례가 넘어가요. 카드를 보여 줄 때는 20초 안에 고르지 않으면 맞는 카드가 자동으로 보여져요.'}{' '} + 게임 중에 나간 사람의 카드는 모두에게 공개돼요.

    ); diff --git a/apps/web/src/games/dobble/index.tsx b/apps/web/src/games/dobble/index.tsx index cbe3521..990b8c5 100644 --- a/apps/web/src/games/dobble/index.tsx +++ b/apps/web/src/games/dobble/index.tsx @@ -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, id: string): PublicUser => players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' }; const who = (players: Record, 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 ( -
    +
    {card.items.map((it, i) => { const d = it.r * 100; return ( @@ -286,7 +308,6 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps 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 (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 { + 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{nick(players, s.id)} - {countText(mode, s)} + + {countText(mode, s)} + {s.lockedUntil > now && s.status === 'playing' ? ' · 잠금' : ''} {v.options.showRtt && } @@ -486,7 +531,7 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps ) : ( -
    +
    {inner}
    )} @@ -507,7 +552,7 @@ function DobbleBoard({ view: v, me, players, act, pending }: BoardProps 0 && (
    - {countdown} + {countdown} {v.phase === 'roundEnd' ? '다음 라운드를 준비해요' : '두 카드에 똑같이 있는 그림을 찾아요!'}
    )} diff --git a/apps/web/src/games/halli-galli/help.ts b/apps/web/src/games/halli-galli/help.ts index 9298cf5..eb633dd 100644 --- a/apps/web/src/games/halli-galli/help.ts +++ b/apps/web/src/games/halli-galli/help.ts @@ -33,6 +33,7 @@ export function helpNow(v: HalliGalliView, me: string | null, players: Record, id: string): PublicUser => players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' }; const cardName = (c: Pick) => `${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, me: string return parts.join(', '); } -function Seat({ s, v, pos, players, me, now }: { s: SeatView; v: HalliGalliView; pos: Pos; players: Record; me: string | null; now: number }) { +function Seat({ s, v, pos, players, me, now, shake }: { s: SeatView; v: HalliGalliView; pos: Pos; players: Record; 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 (
  • )} - {s.isTurn && v.phase === 'playing' && } + {s.isTurn && v.phase === 'playing' && v.turnDeadline !== null && }
  • - + 0 ? 'gain anim-bump' : 'gain'}> {s.deck} {s.status === 'out' && ( @@ -384,6 +413,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps(null); const [ghosts, setGhosts] = useState([]); const [hit, setHit] = useState(0); + const [shake, setShake] = useState<{ id: string; seq: number } | null>(null); const [announce, setAnnounce] = useState(''); const sentFor = useRef(null); const prev = useRef(null); @@ -406,10 +436,11 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps { 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 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 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 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 ({ 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 (
    @@ -546,7 +602,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps
      {rot.map((s, i) => ( - + ))}
    @@ -603,7 +659,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps 0 && (
    - {countdown} + {countdown} 과일이 딱 5개가 되면 종을 쳐요!
    )} @@ -617,7 +673,7 @@ function HalliGalliBoard({ view: v, me, players, act, pending }: BoardProps {mine.deck}장
    -
    @@ -667,7 +723,8 @@ function logText(e: LogEntry, players: Record, 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) { onChange={(timeLimitMin) => set({ timeLimitMin })} /> - + ) { [3, '3초'], [5, '5초'], [8, '8초'], + [null, '무제한'], ]} onChange={(flipSeconds) => set({ flipSeconds })} /> - + set({ kidMode })} />
    - 모두 누르면 바로 투표로 넘어가요. + {ph.endsAt === null ? '토론 시간이 무제한이에요. ' : ''}모두 누르면 바로 투표로 넘어가요. ); } else if (ph.kind === 'vote') { @@ -583,7 +598,10 @@ function Actions({ v, players, me, act, pending }: { v: LiarView; players: Recor body = my.canGuess ? ( <>

    들켰어요! 제시어를 맞히면 그래도 이겨요

    - 주제는 {v.topicKo}이에요. {v.options.guessMode === 'choice' ? '목록에서 하나를 골라요. 기회는 한 번이에요.' : '띄어쓰기는 상관없어요. 기회는 한 번이에요.'} + + 주제는 {v.topicKo}이에요. {v.options.guessMode === 'choice' ? '목록에서 하나를 골라요. 기회는 한 번이에요.' : '띄어쓰기는 상관없어요. 기회는 한 번이에요.'} + {ph.endsAt === null ? ' 시간 제한은 없어요.' : ''} + ) : ( @@ -651,6 +669,36 @@ function FinalReveal({ v, players }: { v: LiarView; players: Record tone(660, 70, 'triangle', 0.09), + /** The accused really is the liar. */ + caught: () => [523, 784].forEach((f, i) => tone(f, 140, 'square', 0.07, i * 120)), +}; + +/** Sounds for what anyone did: descriptions, votes being cast, results (the room plays win / lose at the end). */ +function useLiarSounds(v: LiarView, me: string | null): void { + const prev = useRef(v); + useEffect(() => { + const p = prev.current; + prev.current = v; + if (p === v) return; + const last = p.events.at(-1)?.n ?? 0; + const fresh = v.events.filter((e) => e.n > last); + if (fresh.some((e) => e.t === 'end')) return; + const acc = fresh.find((e) => e.t === 'accused'); + if (acc && acc.t === 'accused') return acc.liar ? lgSound.caught() : sfx.bad(); + if (fresh.some((e) => e.t === 'vote')) return sfx.chips(3); + if (fresh.some((e) => e.t === 'left')) return sfx.whoosh(); + const newDesc = v.descriptions.slice(p.descriptions.length); + if (newDesc.some((d) => d.from !== me)) return newDesc.some((d) => d.text === null) ? sfx.tick() : lgSound.said(); + if (v.my?.vote !== p.my?.vote && v.my?.vote) return sfx.select(); + const same = v.phase.kind === p.phase.kind && v.phase.voteRound === p.phase.voteRound; + if (same && (v.phase.votedCount > p.phase.votedCount || v.phase.readyCount > p.phase.readyCount)) sfx.chip(); + }, [v]); // eslint-disable-line react-hooks/exhaustive-deps +} + function LiarBoard({ view: v, me, players, act, pending }: BoardProps) { const ph = v.phase; const my = v.my; @@ -668,6 +716,7 @@ function LiarBoard({ view: v, me, players, act, pending }: BoardProps) sounds.myTurn(); } }, [phaseKey]); // eslint-disable-line react-hooks/exhaustive-deps + useLiarSounds(v, me); const pick: Pick = my && ph.kind === 'vote' && my.voteTargets.length ? { ids: my.voteTargets, chosen: my.vote, onPick: (id) => act({ type: 'vote', target: id }) } : null; const hot = ph.kind === 'guess' || (ph.kind === 'describe' && !!my?.canDescribe); @@ -683,10 +732,12 @@ function LiarBoard({ view: v, me, players, act, pending }: BoardProps)
    🤥 라이어 게임 - {phaseTitle(v)} + + {phaseTitle(v)} + {sub} - + {my && }
    @@ -778,7 +829,7 @@ function statusText(v: LiarView, me: string | null, players: Record({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { +function Seg({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { return (
    {options.map(([k, l]) => ( @@ -804,7 +855,7 @@ const onOff: [boolean, string][] = [ [true, '켜기'], [false, '끄기'], ]; -const secs = (...v: T[]): [T, string][] => v.map((x) => [x, `${x}초`]); +const secs = (...v: T[]): [T | null, string][] => [...v.map((x): [T, string] => [x, `${x}초`]), [null, '무제한']]; function Options({ value: o, onChange }: OptionsProps) { const [more, setMore] = useState(false); @@ -844,18 +895,21 @@ function Options({ value: o, onChange }: OptionsProps) { {more && ( <> - + set({ describeSeconds })} /> - + set({ discussionSeconds })} /> - + set({ voteSeconds })} /> - + set({ guessSeconds })} /> + {[o.describeSeconds, o.discussionSeconds, o.voteSeconds, o.guessSeconds].includes(null) && ( + 무제한이어도 연결이 끊긴 채 돌아오지 않는 사람은 잠시 뒤 넘어가요(설명 넘김, 표 없음, 답 없음). + )} set({ kidSafeChat })} /> @@ -868,7 +922,7 @@ function Options({ value: o, onChange }: OptionsProps) { function optionsSummary(o: LiarOptions): string { const parts = [o.topic === 'random' ? '주제 무작위' : `주제 ${TOPIC_KO[o.topic]}`]; if (o.foolMode) parts.push('바보 모드'); - parts.push(o.rounds === 2 ? '두 바퀴' : '한 바퀴', `설명 ${o.describeSeconds}초`, `토론 ${o.discussionSeconds}초`, o.guessMode === 'choice' ? '정답은 목록에서' : '정답은 직접 적기'); + parts.push(o.rounds === 2 ? '두 바퀴' : '한 바퀴', o.describeSeconds === null ? '설명 무제한' : `설명 ${o.describeSeconds}초`, o.discussionSeconds === null ? '토론 무제한' : `토론 ${o.discussionSeconds}초`, o.guessMode === 'choice' ? '정답은 목록에서' : '정답은 직접 적기'); return parts.join(' · '); } @@ -889,6 +943,7 @@ function Rules() {
  • 라이어가 아닌 사람이 지목되면 라이어 승리. 라이어가 지목되면 제시어를 한 번 맞힐 수 있어요(띄어쓰기·대소문자 무시). 맞히면 라이어, 틀리면 시민 승리예요.
  • 점수: 시민이 이기면 시민마다 1점, 라이어가 이기면 라이어 2점.
  • 바보 모드: 라이어도 같은 주제의 다른 단어를 받고, 자기가 라이어인지 몰라요.
  • +
  • 시간 무제한: 설명·토론·투표·정답 맞히기 시간을 무제한으로 할 수 있어요. 그 단계는 할 일을 다 마칠 때까지 기다려요.
  • 내 제시어는 "내 제시어" 카드를 꾹 누르고 있을 때만 보여요. 게임 중에는 방 채팅 대신 게임 화면의 채팅을 써요.

    diff --git a/apps/web/src/games/mafia/help.test.ts b/apps/web/src/games/mafia/help.test.ts index 12ad7fb..033582b 100644 --- a/apps/web/src/games/mafia/help.test.ts +++ b/apps/web/src/games/mafia/help.test.ts @@ -55,3 +55,16 @@ test('마피아: 지목 투표 → 찬반 투표, 탈락한 사람', () => { const dead = { ...confirm, players: g.state.players.map((p: any) => (p.id === g.doctor ? { ...p, alive: false, diedDay: 1, diedBy: 'mafia' } : p)) }; expect(helpNow(view(dead, g.doctor), g.doctor, users)).toContain('[죽은 사람] 채팅'); }); + +test('마피아: 시간 무제한이면 [밤 마치기]·[반론 마치기]·모두 투표 안내', () => { + const g = game(); + const night = { kind: 'night', startedAt: T, endsAt: null, ready: [], mafiaTarget: null, mafiaPickedBy: null, investigate: null, heal: null, mediumPeek: null }; + const s = { ...g.state, day: 2, phase: night }; + const c = helpNow(view(s, g.citizen), g.citizen, users); + expect(c).toContain('[밤 마치기]'); + expect(c).toContain('(0/7)'); + const def = { ...g.state, day: 2, phase: { kind: 'defense', startedAt: T, endsAt: null, accused: g.citizen } }; + expect(helpNow(view(def, g.citizen), g.citizen, users)).toContain('[반론 마치기]를 눌러요'); + const vote = { ...g.state, day: 2, phase: { kind: 'vote', startedAt: T, endsAt: null, votes: {} } }; + expect(helpNow(view(vote, g.police), g.police, users)).toContain('모두 투표(기권 포함)하면 바로 결과가 나와요(0/7)'); +}); diff --git a/apps/web/src/games/mafia/help.ts b/apps/web/src/games/mafia/help.ts index a7a9ae3..e0e8ae8 100644 --- a/apps/web/src/games/mafia/help.ts +++ b/apps/web/src/games/mafia/help.ts @@ -50,6 +50,8 @@ export function helpNow(v: MafiaView, me: string | null, players: Record, string> }; const nick = (players: Record, id: string) => players[id]?.nickname ?? '알 수 없음'; + +/** Game sounds on top of the shared palette (site volume applies). */ +const mfSound = { + /** Night falls: a low falling hum. */ + night: () => { + tone(392, 520, 'sine', 0.1, 0, { slideTo: 196 }); + tone(294, 620, 'sine', 0.06, 180, { slideTo: 147 }); + }, + /** Morning: a small rising chime. */ + morning: () => [523, 659, 784].forEach((f, i) => tone(f, 160, 'triangle', 0.09, i * 110)), + /** Judge's gavel (executed). */ + gavel: () => { + noise(70, 0.35, 0, 'lowpass', 500); + tone(120, 160, 'square', 0.08); + noise(60, 0.25, 220, 'lowpass', 500); + }, + /** Someone was taken in the night. */ + death: () => { + tone(220, 380, 'sawtooth', 0.06, 0, { slideTo: 110 }); + tone(233, 380, 'sawtooth', 0.04, 40, { slideTo: 116 }); + }, +}; const userOf = (players: Record, id: string): PublicUser => players[id] ?? { id, nickname: '알 수 없음', avatar: null, kind: 'guest' }; const isNight = (v: MafiaView) => v.phase.kind === 'night' || v.phase.kind === 'roleReveal'; @@ -136,6 +158,11 @@ button.mf-tile { cursor: pointer; } .mf-log { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; max-height: 320px; overflow: auto; } .mf-rules td, .mf-rules th { padding: 4px 6px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); } @keyframes mf-pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } } +.mf-unl { font-size: 1.6rem; } +.mf-unl small { display: block; font-size: .7rem; font-weight: 800; } +.mf-tile[aria-pressed='true'] { animation: mf-pick .28s ease-out; } +@keyframes mf-pick { 50% { transform: scale(1.07); } } +.mf-rolecard[data-show='true'] { animation: anim-flip .35s ease both; } @keyframes mf-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } } @media (max-width: 1099px) { .mf { height: auto; } @@ -155,14 +182,20 @@ button.mf-tile { cursor: pointer; } } @media (prefers-reduced-motion: reduce) { .mf-banner { transition: none; } - .mf-news, .mf-bar .tr i { animation: none; } + .mf-news, .mf-bar .tr i, .mf-tile[aria-pressed='true'], .mf-rolecard[data-show='true'] { animation: none; } } `; // ---------------------------------------------------------------- small parts -function Clock({ endsAt }: { endsAt: number | null }) { +function Clock({ endsAt, unlimited }: { endsAt: number | null; unlimited: boolean }) { const now = useServerNow(500); + if (unlimited) + return ( + + ∞무제한 + + ); if (endsAt === null) return null; const sec = Math.max(0, Math.ceil((endsAt - now) / 1000)); const text = sec >= 60 ? `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, '0')}` : `${sec}`; @@ -547,7 +580,7 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco body = ( <>

    {ph.kind === 'greeting' ? '인사 시간이에요. 오늘은 투표가 없어요.' : '토론 시간이에요. 마피아가 누구일까요?'}

    - {ph.kind === 'discussion' && v.options.timeAdjust && ( + {ph.kind === 'discussion' && v.options.timeAdjust && ph.endsAt !== null && (
    )} - {ph.kind === 'discussion' && !my.canAdjust && v.options.timeAdjust && 시간 바꾸기는 하루에 한 번만 할 수 있어요.} + {ph.kind === 'discussion' && !my.canAdjust && v.options.timeAdjust && ph.endsAt !== null && 시간 바꾸기는 하루에 한 번만 할 수 있어요.}
    - 살아 있는 사람이 모두 누르면 바로 다음으로 넘어가요. + {ph.endsAt === null ? '토론 시간이 무제한이에요. ' : ''}살아 있는 사람이 모두 누르면 바로 다음으로 넘어가요. ); } else if (ph.kind === 'vote') { body = ( <>

    마피아로 의심되는 사람을 골라 주세요

    - 초록 테두리 사람을 누르면 지목해요. 시간 안에는 바꿀 수 있어요. - {my.vote === null ? '아직 고르지 않았어요 (안 고르면 기권)' : my.vote === 'abstain' ? '기권했어요' : `${n(my.vote)}을 지목했어요`} + + {ph.endsAt === null ? '초록 테두리 사람을 누르면 지목해요. 모두 투표하면 바로 결과가 나와요. ' : '초록 테두리 사람을 누르면 지목해요. 시간 안에는 바꿀 수 있어요.'} + {ph.endsAt === null && } + + {my.vote === null ? `아직 고르지 않았어요${ph.endsAt === null ? '' : ' (안 고르면 기권)'}` : my.vote === 'abstain' ? '기권했어요' : `${n(my.vote)}을 지목했어요`}
    +
    + )} + {ph.endsAt === null && 시간 제한이 없어요. {ph.accused === me ? '다 말했으면 [반론 마치기]를 눌러요.' : '지목된 사람이 [반론 마치기]를 누르면 찬반 투표로 넘어가요.'}} + + ); } else if (ph.kind === 'confirm') { body = my.canConfirm ? ( <> @@ -593,7 +641,16 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco 반대 (살리기)
    - {my.ballot ? `${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 시간 안에는 바꿀 수 있어요.` : '고르지 않으면 집계에서 빠져요.'} + + {ph.endsAt === null + ? my.ballot + ? `${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 모두 고르면 바로 결과가 나와요. ` + : '모두 고르면 바로 결과가 나와요. ' + : my.ballot + ? `${my.ballot === 'yes' ? '찬성' : '반대'}했어요. 시간 안에는 바꿀 수 있어요.` + : '고르지 않으면 집계에서 빠져요.'} + {ph.endsAt === null && } + ) : (

    다른 사람들이 찬반 투표를 하고 있어요.

    @@ -605,7 +662,7 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco

    {nv.prompt}

    {nv.action && nv.targets.length > 0 && ( <> - 초록 테두리 사람을 누르면 골라요. 밤이 끝날 때 고른 사람으로 정해져요. + 초록 테두리 사람을 누르면 골라요. 밤이 끝날 때 고른 사람으로 정해져요.{ph.endsAt === null ? ' 고른 다음 [밤 마치기]를 눌러요.' : ''} {nv.choice ? `고른 사람: ${n(nv.choice)}${nv.pickedBy && nv.pickedBy !== me ? ` (${n(nv.pickedBy)}이 골랐어요)` : ''}` : '아직 고르지 않았어요'} {nv.action === 'mafiaTarget' && nv.choice && (
    @@ -617,6 +674,16 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco )} {!nv.action && 밤이 지나면 아침 발표가 있어요.} + {ph.endsAt === null && ( + <> +
    + +
    + 밤 시간이 무제한이에요. 살아 있는 사람이 모두 누르면 아침이 와요. + + )} ); } @@ -639,6 +706,17 @@ function Actions({ v, players, me, act, pending }: { v: MafiaView; players: Reco ); } +/** "(3/5)": how many are done in this phase; bumps when it changes (someone else pressed / voted). */ +function Count({ v }: { v: MafiaView }) { + const { readyCount: c, readyNeeded: n } = v.phase; + if (!n) return null; + return ( + + ({c}/{n}) + + ); +} + function FinalReveal({ v, players }: { v: MafiaView; players: Record }) { const f = v.final!; return ( @@ -680,6 +758,39 @@ function FinalReveal({ v, players }: { v: MafiaView; players: Record { + const p = prev.current; + prev.current = v; + if (p === v) return; + const last = p.events.at(-1)?.n ?? 0; + const fresh = v.events.filter((e) => e.n > last); + let played = false; + const play = (f: () => void) => { + if (played) return; + played = true; + f(); + }; + // The most telling announcement wins (one sound per update); the room plays win / lose at the end. + if (fresh.some((e) => e.t === 'end')) return; + for (const e of fresh) { + if (e.t === 'death') play(e.by === 'mafia' ? mfSound.death : e.by === 'vote' ? mfSound.gavel : sfx.whoosh); + else if (e.t === 'confirm' && e.outcome !== 'executed') play(sfx.good); + else if (e.t === 'healed' || e.t === 'soldier') play(sfx.good); + } + if (fresh.some((e) => e.t === 'vote')) play(() => sfx.chips(3)); + if (fresh.some((e) => e.t === 'adjust')) play(sfx.tick); + if (fresh.length) return; + // Same phase: my own pick (vote, ballot, night target incl. a mafia mate's) or someone else being done. + const my = v.my; + const pm = p.my; + if (my && pm && (my.vote !== pm.vote || my.ballot !== pm.ballot || my.night?.choice !== pm.night?.choice)) return play(sfx.select); + if (v.phase.readyCount > p.phase.readyCount && v.phase.kind === p.phase.kind) play(sfx.chip); + }, [v]); +} + function MafiaBoard({ view: v, me, players, act, pending }: BoardProps) { const ph = v.phase; const my = v.my; @@ -692,11 +803,13 @@ function MafiaBoard({ view: v, me, players, act, pending }: BoardProps act({ type: 'vote', target: id }) }; @@ -721,10 +834,12 @@ function MafiaBoard({ view: v, me, players, act, pending }: BoardProps {time === 'night' ? '🌙' : time === 'end' ? '🏁' : '☀️'} {v.day}일차 - {PHASE_KO[ph.kind]} + + {PHASE_KO[ph.kind]} + {sub} - + {my && } @@ -834,7 +949,7 @@ function statusText(v: MafiaView, me: string | null, players: Record({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { +function Seg({ value, options, onChange, label }: { value: T; options: [T, string][]; onChange: (v: T) => void; label: string }) { return (
    {options.map(([k, l]) => ( @@ -861,6 +976,8 @@ const onOff: [boolean, string][] = [ [false, '끄기'], ]; const secs = (...v: T[]): [T, string][] => v.map((x) => [x, `${x}초`]); +/** Seconds plus 무제한 (null). */ +const secsU = (...v: T[]): [T | null, string][] => [...secs(...v), [null, '무제한']]; const EXTRA_KO: Record = { soldier: '군인', politician: '정치인', medium: '영매', lovers: '연인(2명)' }; function Options({ value: o, onChange }: OptionsProps) { @@ -903,7 +1020,8 @@ function Options({ value: o, onChange }: OptionsProps) { /> - set({ nightSeconds })} /> + set({ nightSeconds })} /> + {o.nightSeconds === null && 살아 있는 사람이 모두 [밤 마치기]를 누르면 아침이 와요(직업과 상관없이 모두 눌러요).} ) { {more && ( <> - set({ discussionPerAlive })} /> + set({ discussionPerAlive })} /> - - set({ discussionMin })} /> + {o.discussionPerAlive === null ? ( + 토론 시간이 무제한이에요. 살아 있는 사람이 모두 [토론 끝내기]를 누르면 투표로 넘어가요(최소·최대·±15초는 쓰지 않아요). + ) : ( + <> + + set({ discussionMin })} /> + + + set({ discussionMax })} /> + + + )} + + set({ voteSeconds })} /> - - set({ discussionMax })} /> + + set({ defenseSeconds })} /> - - set({ voteSeconds })} /> - - - set({ defenseSeconds })} /> - - - set({ confirmSeconds })} /> - - - set({ timeAdjust })} /> + + set({ confirmSeconds })} /> + {o.discussionPerAlive !== null && ( + + set({ timeAdjust })} /> + + )} set({ openVote })} /> @@ -985,7 +1111,8 @@ function optionsSummary(o: MafiaOptions): string { const extras = (Object.keys(EXTRA_KO) as (keyof MafiaOptions['extraRoles'])[]).filter((k) => o.extraRoles[k]).map((k) => EXTRA_KO[k]); const parts = [o.mafiaCount === 'auto' ? '마피아 자동' : `마피아 ${o.mafiaCount}명`]; if (extras.length) parts.push(`추가: ${extras.join('·')}`); - parts.push(o.firstPhase === 'day' ? '낮부터' : '밤부터', `밤 ${o.nightSeconds}초`, `투표 ${o.voteSeconds}초`); + parts.push(o.firstPhase === 'day' ? '낮부터' : '밤부터', o.nightSeconds === null ? '밤 무제한' : `밤 ${o.nightSeconds}초`, o.voteSeconds === null ? '투표 무제한' : `투표 ${o.voteSeconds}초`); + if (o.discussionPerAlive === null) parts.push('토론 무제한'); parts.push(o.deathReveal === 'none' ? '탈락자 비공개' : o.deathReveal === 'team' ? '탈락 시 마피아 여부 공개' : '탈락 시 직업 공개'); return parts.join(' · '); } @@ -1006,6 +1133,10 @@ function Rules() {

    밤에는 낮 채팅이 잠겨요. 마피아는 마피아 채팅으로, 연인은 연인 채팅으로 몰래 이야기해요. 탈락한 사람은 죽은 사람 채팅에서만 이야기할 수 있어요(영매는 밤에 함께해요).

    +

    + 시간 무제한: 단계마다 시간을 무제한으로 할 수 있어요. 그러면 토론은 모두 [토론 끝내기], 투표는 모두 투표, 반론은 지목된 사람이 [반론 마치기], 밤은 모두 [밤 마치기]를 누를 때 + 넘어가요. 연결이 끊긴 채 돌아오지 않는 사람은 잠시 뒤 기권·마침으로 처리돼요. +

    {ROLE_ORDER.map((r) => ( diff --git a/apps/web/src/games/magical-athlete/index.tsx b/apps/web/src/games/magical-athlete/index.tsx index 81ddccb..f66ba02 100644 --- a/apps/web/src/games/magical-athlete/index.tsx +++ b/apps/web/src/games/magical-athlete/index.tsx @@ -5,7 +5,7 @@ import { RACERS, type RacerId } from '@bg/games/magical-athlete/racers'; 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, sfx, sounds, tone } from '../../lib/feedback'; import type { BoardProps, GameUI, OptionsProps } from '../types'; import { helpNow } from './help'; import { quickStart } from './quick'; @@ -20,6 +20,27 @@ const seatColor = (v: MagicalAthleteView, p: string) => COLORS[v.seats.indexOf(p const rname = (id: RacerId) => `${RACERS[id].emoji} ${RACERS[id].name}`; const who = (players: Record, me: string | null, p: string) => (p === me ? '나' : nick(players, p)); +/** Game sounds on top of the shared palette (site volume applies); `d` = delay in ms (after the dice lands). */ +const maSound = { + /** Footsteps along the track. */ + steps: (d: number) => { + for (let i = 0; i < 3; i++) tone(i % 2 ? 560 : 470, 45, 'triangle', 0.09, d + i * 90); + }, + /** A racer's power: a quick sparkle up. */ + power: (d: number) => [880, 1175, 1568].forEach((f, i) => tone(f, 90, 'triangle', 0.08, d + i * 60)), + /** Star space (+1 point). */ + star: (d: number) => { + tone(1318, 70, 'square', 0.05, d); + tone(1976, 160, 'square', 0.05, d + 70); + }, + /** Rock space: tripped. */ + trip: (d: number) => tone(300, 200, 'sawtooth', 0.05, d, { slideTo: 150 }), + /** Arrow space: slide forward / back. */ + arrow: (d: number, up: boolean) => tone(up ? 500 : 900, 220, 'sine', 0.09, d, { slideTo: up ? 1000 : 450 }), + /** Crossing the finish line. */ + finish: (d: number) => [784, 988, 1318].forEach((f, i) => tone(f, 130, 'triangle', 0.1, d + i * 90)), +}; + const CSS = ` .ma-wrap { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 10px; } /* Taller than the play area on PC: start at the top (centring would cut the top off where nobody can scroll to). */ @@ -42,6 +63,10 @@ const CSS = ` .ma-tok circle { stroke: #1f2937; stroke-width: 2; } .ma-tok.cur circle { stroke: var(--focus); stroke-width: 4; } .ma-tok.trip { opacity: .55; } +.ma-hop { transform-box: fill-box; transform-origin: center; animation: ma-hop .45s ease-out; } +@keyframes ma-hop { 30% { transform: translateY(-10px) scale(1.12); } 60% { transform: translateY(0) scale(.96); } } +.ma-hop.tripped { animation: anim-shake .45s ease both; } +.ma-medal { transform-box: fill-box; transform-origin: center; animation: anim-pop .32s cubic-bezier(.3,1.6,.5,1) both; } .ma-emoji { font-size: 16px; } .ma-lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start; } .ma-panel { padding: 12px; display: flex; flex-direction: column; gap: 10px; } @@ -97,7 +122,7 @@ button.ma-card:hover:not(:disabled) { border-color: var(--primary); } } @media (prefers-reduced-motion: reduce) { .ma-tok { transition: none; } - .ma-die.rolling, .ma-news .fresh { animation: none; } + .ma-die.rolling, .ma-news .fresh, .ma-hop, .ma-medal { animation: none; } } `; @@ -209,12 +234,15 @@ function Track({ v, me, players }: { v: MagicalAthleteView; me: string | null; p const isCur = r.cur === x.id; return ( - - - {RACERS[x.id].emoji} - + {/* Remounted on every move / trip: a hop (or a stumble) while the token slides. */} + + + + {RACERS[x.id].emoji} + + {x.place && ( - + {x.place === 1 ? '🥇' : '🥈'} )} @@ -293,9 +321,11 @@ function RacePanel({ v, me, players, act, pending, rolling }: { v: MagicalAthlet ))} -

    - 시간이 지나면 {pr.timeoutText}. -

    + {v.options.turnSeconds !== null && ( +

    + 시간이 지나면 {pr.timeoutText}. +

    + )} ) : (

    @@ -325,7 +355,7 @@ function Draft({ v, me, players, act, pending }: { v: MagicalAthleteView; me: st

    {d.line.map((id) => ( -