오목·사목·오델로·바둑 소리·움직임, 바둑 사석 확인 무제한

- 공통(보드게임 8종용) board-motion: 직전 판 비교(useMoveDiff), 끝난 잔상 치우기(useAnimOver), 내려앉기·미끄러지기·사라지기·고리·반짝임 클래스
- 오목: 돌 내려앉기, 마지막 수 고리, 무르기 돌 사라짐, 승리 줄 차례로 반짝임, 금수 누르면 작은 소리, 돌 그림자
- 사목: 바닥에 닿아 한 번 튀기, 닿는 순간에 맞춘 "탁" 소리, 마지막 수 점은 닿은 뒤, 이긴 줄 차례로 깜빡임
- 오델로: 놓은 돌 먼저 내려앉고 뒤집기(들리며 뒤집힘), 뒤집힐 때마다 딸깍, 패스·무르기 소리, 마지막 수 고리
- 바둑: 돌 내려앉기, 따낸 돌 한 알씩 사라짐+딸깍, 패스 소리, 무르기 되돌림, 사석 표시 바뀜 소리
- 바둑 사석 확인 제한 시간에 무제한(0) 추가(기본 3분 그대로), 테스트·문서
- 숨은 탭 내 차례 소리는 방 화면이 이미 내므로 게임 쪽 중복 제거
- games E2E에 오목 기본 계획 추가

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-13 04:21:25 +09:00
parent f12cf12b84
commit 5e1e74da18
12 changed files with 280 additions and 68 deletions

View File

@@ -4,7 +4,8 @@ import type { BadukOptions, BadukView, Pt, ScoreBreakdown } from '@bg/games/badu
import type { PublicUser } from '@bg/shared/lite';
import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
import { TurnTimer, useServerNow } from '../../components/TurnTimer';
import { haptic, sounds } from '../../lib/feedback';
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
import { BOARD_MOTION_CSS, useAnimOver, useMoveDiff } from '../board-motion';
import type { BoardProps, GameUI, OptionsProps } from '../types';
import { helpNow } from './help';
import { quickStart } from './quick';
@@ -35,9 +36,18 @@ function fmtScore(n: number, method: 'territory' | 'area'): string {
return half ? (whole === 0 ? '반' : `${whole}.5`) : String(whole);
}
/** Stones taken off the board: a few small clicks as they are picked up into the lid. */
function captureSound(count: number) {
for (let k = 0; k < Math.min(count, 6); k++) {
tone(2100 + (k % 3) * 260, 28, 'triangle', 0.06, 150 + k * 55);
noise(25, 0.05, 150 + k * 55, 'highpass', 4500);
}
}
function Stone({ color, cx, cy, r, ghost }: { color: Color; cx: number; cy: number; r: number; ghost?: boolean }) {
return (
<g opacity={ghost ? 0.5 : 1}>
{!ghost && <ellipse cx={cx + r * 0.1} cy={cy + r * 0.16} rx={r} ry={r * 0.96} fill="#000" opacity={0.22} />}
<circle cx={cx} cy={cy} r={r} fill={color === 'black' ? '#151515' : '#fbfbf8'} stroke={color === 'black' ? '#000' : '#666'} strokeWidth={0.05} />
{color === 'black' ? (
<circle cx={cx - r * 0.3} cy={cy - r * 0.3} r={r * 0.28} fill="#fff" opacity={0.15} />
@@ -76,21 +86,33 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
return out;
}, [v.scoring, v.result, v.board, n]);
const seki = useMemo(() => new Set((v.scoring?.seki ?? []).map((p) => p.y * n + p.x)), [v.scoring?.seki, n]);
// Board before the last move: the new stone sets down and captures fade only for moves seen live;
// 무르기 lifts the taken-back stone and puts captured stones back.
const { before, forward } = useMoveDiff(v.board, v.moveCount);
const fresh = !!before && forward;
const undone = before && !forward ? before.flatMap((c, i) => (c !== 0 && v.board[i] === 0 ? [{ i, color: (c === 1 ? 'black' : 'white') as Color }] : [])) : [];
const [goneOver, goneEnd] = useAnimOver(v.moveCount);
const restored = new Set(before && !forward ? v.board.flatMap((c, i) => (c !== 0 && before[i] === 0 ? [i] : [])) : []);
// Move sounds and announcements.
// Move sounds and announcements (mine, the opponent's and the computer's).
useEffect(() => {
if (v.moveCount > prevCount.current) {
const m = v.moves[v.moves.length - 1]!;
if (m.pt) {
sounds.stone();
if (m.captured > 0) haptic(30);
sfx.stone();
if (m.captured > 0) {
captureSound(m.captured);
haptic(30);
}
setAnnounce(`${COLOR_KO[m.color]}이 ${label(n, m.pt)}에 두었어요.${m.captured ? ` 돌 ${m.captured}개를 따냈어요.` : ''}`);
} else setAnnounce(`${COLOR_KO[m.color]}이 패스했어요.`);
if (myTurn) {
haptic(40);
if (document.visibilityState === 'hidden') sounds.myTurn();
} else {
// 패스: a soft knock on the board edge.
tone(330, 90, 'sine', 0.1);
noise(50, 0.05, 0, 'lowpass', 700);
setAnnounce(`${COLOR_KO[m.color]}이 패스했어요.`);
}
}
if (myTurn) haptic(40);
} else if (v.moveCount < prevCount.current) sfx.whoosh();
prevCount.current = v.moveCount;
setPreview(null);
setBubble(null);
@@ -109,6 +131,7 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
for (const i of dead) if (!before.has(i)) diff.add(i);
for (const i of before) if (!dead.has(i)) diff.add(i);
if (diff.size === 0) return;
sfx.click();
setChanged(diff);
const t = setTimeout(() => setChanged(new Set()), 2500);
return () => clearTimeout(t);
@@ -142,6 +165,7 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
const why = illegal.get(p.y * n + p.x);
if (why) {
haptic([30, 30, 30]);
sfx.bad();
setBubble({ p, text: ILLEGAL_KO[why] });
setAnnounce(ILLEGAL_KO[why]);
return;
@@ -186,6 +210,7 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
const pad = 0.95;
return (
<div className="board-wrap stack" style={{ gap: 10 }}>
<style>{BOARD_MOTION_CSS}</style>
<svg
ref={svgRef}
viewBox={`${-pad} ${-pad} ${n - 1 + 2 * pad} ${n - 1 + 2 * pad}`}
@@ -242,20 +267,35 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
const x = i % n;
const y = Math.floor(i / n);
const isDead = dead.has(i);
const isLast = fresh && v.lastMove !== null && i === v.lastMove.y * n + v.lastMove.x;
return (
<g key={i} opacity={isDead ? 0.45 : 1}>
<Stone color={color} cx={x} cy={y} r={0.47} />
<g key={isLast ? `m${v.moveCount}` : i} opacity={isDead ? 0.45 : 1} style={{ transition: 'opacity 0.25s' }}>
<g className={isLast ? 'bm-place' : restored.has(i) ? 'anim-pop' : undefined}>
<Stone color={color} cx={x} cy={y} r={0.47} />
</g>
</g>
);
})}
{/* Stones just captured fade out. */}
{v.phase === 'playing' &&
v.lastCaptured.map((p) => (
<g key={`cap${v.moveCount}-${p.x}-${p.y}`} opacity={0}>
<animate attributeName="opacity" from={0.7} to={0} dur="0.6s" fill="freeze" />
{/* Stones just captured are lifted off one by one; a stone taken back by 무르기 fades. */}
{fresh &&
!goneOver &&
v.phase === 'playing' &&
v.lastCaptured.map((p, k, all) => (
<g
key={`cap${v.moveCount}-${p.x}-${p.y}`}
className="bm-gone"
style={{ animationDelay: `${150 + Math.min(k, 6) * 55}ms` }}
onAnimationEnd={k === all.length - 1 ? goneEnd : undefined}
>
<Stone color={lastColor ? other(lastColor) : 'white'} cx={p.x} cy={p.y} r={0.47} />
</g>
))}
{!goneOver &&
undone.map(({ i, color }) => (
<g key={`u${v.moveCount}-${i}`} className="bm-gone" onAnimationEnd={goneEnd}>
<Stone color={color} cx={i % n} cy={Math.floor(i / n)} r={0.47} />
</g>
))}
{/* Territory / area marks (small squares) and seki marks. */}
{score &&
score.ownership.map((o, i) => {
@@ -277,7 +317,10 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
</circle>
))}
{v.lastMove && lastColor && (
<circle cx={v.lastMove.x} cy={v.lastMove.y} r={0.2} fill="none" stroke={lastColor === 'black' ? '#fff' : '#111'} strokeWidth={0.08} />
<g key={`lm${v.moveCount}`}>
{fresh && <circle className="bm-ring" cx={v.lastMove.x} cy={v.lastMove.y} r={0.5} fill="none" stroke={lastColor === 'black' ? '#111' : '#fafafa'} strokeWidth={0.06} />}
<circle cx={v.lastMove.x} cy={v.lastMove.y} r={0.2} fill="none" stroke={lastColor === 'black' ? '#fff' : '#111'} strokeWidth={0.08} />
</g>
)}
{myTurn &&
v.atariWarnings.map((p) => (
@@ -787,7 +830,7 @@ function Options({ value: o, onChange }: OptionsProps<BadukOptions>) {
</div>
<div className="stack" style={{ gap: 6 }}>
<strong>사석 확인 제한 시간</strong>
<Seg value={o.scoringDeadlineSec} options={[[120, '2분'], [180, '3분'], [300, '5분']]} onChange={(scoringDeadlineSec) => set({ scoringDeadlineSec })} />
<Seg value={o.scoringDeadlineSec} options={[[120, '2분'], [180, '3분'], [300, '5분'], [0, '무제한']]} onChange={(scoringDeadlineSec) => set({ scoringDeadlineSec })} />
</div>
</>
)}