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

- 공통(보드게임 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 { OmokOptions, OmokView, Pt } from '@bg/games/omok';
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, sfx } 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';
@@ -23,6 +24,7 @@ function stars(size: number): Pt[] {
function Stone({ color, cx, cy, r, ghost }: { color: Color; cx: number; cy: number; r: number; ghost?: boolean }) {
return (
<g opacity={ghost ? 0.55 : 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.06} />
{color === 'black' ? (
<circle cx={cx - r * 0.3} cy={cy - r * 0.3} r={r * 0.28} fill="#fff" opacity={0.15} />
@@ -46,18 +48,20 @@ function OmokBoard({ view: v, act, pending, tapConfirm }: BoardProps<OmokView>)
const prevTurn = useRef(v.turn);
const forbidden = useMemo(() => new Set(v.forbidden.map((p) => p.y * n + p.x)), [v.forbidden, n]);
// What the board was before the last change: a new stone sets down, stones taken back by 무르기 fade away.
const { before, forward } = useMoveDiff(v.board, v.moveCount);
const lifted = before && !forward ? before.flatMap((c, i) => (c !== 0 && v.board[i] === 0 ? [{ i, color: (c === 1 ? 'black' : 'white') as Color }] : [])) : [];
const fresh = !!before && forward;
const [liftedOver, liftedEnd] = useAnimOver(v.moveCount);
// Sounds, vibration and screen-reader announcements on new moves.
// Sounds, vibration and screen-reader announcements on new moves (mine, the opponent's and the computer's).
useEffect(() => {
if (v.moveCount > prevCount.current && v.lastMove) {
sounds.stone();
sfx.stone();
const who = v.moves[v.moves.length - 1]!.color;
setAnnounce(`${COLOR_KO[who]}이 ${label(n, v.lastMove)}에 두었어요.`);
}
if (v.phase === 'playing' && myTurn && (prevTurn.current !== v.turn || v.moveCount === 0) && v.moveCount !== prevCount.current) {
haptic(40);
if (document.visibilityState === 'hidden') sounds.myTurn();
}
} else if (v.moveCount < prevCount.current) sfx.whoosh();
if (v.phase === 'playing' && myTurn && (prevTurn.current !== v.turn || v.moveCount === 0) && v.moveCount !== prevCount.current) haptic(40);
prevCount.current = v.moveCount;
prevTurn.current = v.turn;
setPreview(null);
@@ -77,6 +81,7 @@ function OmokBoard({ view: v, act, pending, tapConfirm }: BoardProps<OmokView>)
if (!myTurn || v.board[p.y * n + p.x] !== 0) return;
if (forbidden.has(p.y * n + p.x)) {
haptic([30, 30, 30]);
sfx.bad();
setAnnounce('여기는 금수 자리라 둘 수 없어요.');
return;
}
@@ -113,11 +118,11 @@ function OmokBoard({ view: v, act, pending, tapConfirm }: BoardProps<OmokView>)
}
};
const winSet = new Set((v.winLine ?? []).map((p) => p.y * n + p.x));
const ghost = preview ?? (hover && canPlace(hover) ? hover : null);
const pad = 0.9;
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}`}
@@ -165,10 +170,40 @@ function OmokBoard({ view: v, act, pending, tapConfirm }: BoardProps<OmokView>)
<line x1={p.x + 0.2} y1={p.y - 0.2} x2={p.x - 0.2} y2={p.y + 0.2} />
</g>
))}
{v.board.map((c, i) => (c === 0 ? null : <Stone key={i} color={c === 1 ? 'black' : 'white'} cx={i % n} cy={Math.floor(i / n)} r={0.46} />))}
{v.lastMove && <circle cx={v.lastMove.x} cy={v.lastMove.y} r={0.13} fill="#ef4444" />}
{[...winSet].map((i) => (
<circle key={`win${i}`} cx={i % n} cy={Math.floor(i / n)} r={0.5} fill="none" stroke="#22c55e" strokeWidth={0.1} />
{v.board.map((c, i) => {
if (c === 0) return null;
// The newest stone is keyed by the move number so it sets down again even on a re-used point (after 무르기).
const isLast = fresh && v.lastMove !== null && i === v.lastMove.y * n + v.lastMove.x;
return (
<g key={isLast ? `m${v.moveCount}` : i} className={isLast ? 'bm-place' : undefined}>
<Stone color={c === 1 ? 'black' : 'white'} cx={i % n} cy={Math.floor(i / n)} r={0.46} />
</g>
);
})}
{!liftedOver &&
lifted.map(({ i, color }) => (
<g key={`u${v.moveCount}-${i}`} className="bm-gone" onAnimationEnd={liftedEnd}>
<Stone color={color} cx={i % n} cy={Math.floor(i / n)} r={0.46} />
</g>
))}
{v.lastMove && (
<g key={`lm${v.moveCount}`}>
{fresh && <circle className="bm-ring" cx={v.lastMove.x} cy={v.lastMove.y} r={0.5} fill="none" stroke="#ef4444" strokeWidth={0.06} />}
<circle className={fresh ? 'anim-pop' : undefined} style={{ animationDelay: '0.2s', transformBox: 'fill-box', transformOrigin: 'center' }} cx={v.lastMove.x} cy={v.lastMove.y} r={0.13} fill="#ef4444" />
</g>
)}
{(v.winLine ?? []).map((p, k) => (
<circle
key={`win${p.x}-${p.y}`}
className="bm-win"
style={{ '--bm-delay': `${k * 110}ms` } as React.CSSProperties}
cx={p.x}
cy={p.y}
r={0.5}
fill="none"
stroke="#22c55e"
strokeWidth={0.1}
/>
))}
{ghost && v.myColor && <Stone color={v.myColor} cx={ghost.x} cy={ghost.y} r={0.46} ghost />}
{myTurn && kbd && <rect x={cursor.x - 0.5} y={cursor.y - 0.5} width={1} height={1} fill="none" stroke="var(--focus)" strokeWidth={0.06} />}