오목·사목·오델로·바둑 소리·움직임, 바둑 사석 확인 무제한
- 공통(보드게임 8종용) board-motion: 직전 판 비교(useMoveDiff), 끝난 잔상 치우기(useAnimOver), 내려앉기·미끄러지기·사라지기·고리·반짝임 클래스 - 오목: 돌 내려앉기, 마지막 수 고리, 무르기 돌 사라짐, 승리 줄 차례로 반짝임, 금수 누르면 작은 소리, 돌 그림자 - 사목: 바닥에 닿아 한 번 튀기, 닿는 순간에 맞춘 "탁" 소리, 마지막 수 점은 닿은 뒤, 이긴 줄 차례로 깜빡임 - 오델로: 놓은 돌 먼저 내려앉고 뒤집기(들리며 뒤집힘), 뒤집힐 때마다 딸깍, 패스·무르기 소리, 마지막 수 고리 - 바둑: 돌 내려앉기, 따낸 돌 한 알씩 사라짐+딸깍, 패스 소리, 무르기 되돌림, 사석 표시 바뀜 소리 - 바둑 사석 확인 제한 시간에 무제한(0) 추가(기본 3분 그대로), 테스트·문서 - 숨은 탭 내 차례 소리는 방 화면이 이미 내므로 게임 쪽 중복 제거 - games E2E에 오목 기본 계획 추가 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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>
|
||||
</>
|
||||
)}
|
||||
|
||||
62
apps/web/src/games/board-motion.ts
Normal file
62
apps/web/src/games/board-motion.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Shared movement for the two-player board games (오목·사목·오델로·체스·장기·바둑·쿼리도·윷놀이).
|
||||
* Everything reacts to the view changing, so the opponent's (and the computer's) moves get the same sound
|
||||
* and animation as mine. Animations are short and never take pointer events, so clicks are not slowed.
|
||||
* prefers-reduced-motion is handled by the global rule in styles/global.css.
|
||||
*/
|
||||
import { useRef, useState } from 'react';
|
||||
|
||||
/**
|
||||
* The snapshot from before the move counter last changed, and whether that change was a step forward.
|
||||
* `before` is null until the counter changes while the board is on screen, so a page load / reconnect shows
|
||||
* the position without replaying the last move. Computed during render (no extra frame without the piece).
|
||||
*/
|
||||
export function useMoveDiff<T>(snapshot: T, count: number): { before: T | null; forward: boolean } {
|
||||
const r = useRef<{ count: number; cur: T; before: T | null; forward: boolean }>({ count, cur: snapshot, before: null, forward: false });
|
||||
const s = r.current;
|
||||
if (count !== s.count) {
|
||||
s.before = s.cur;
|
||||
s.forward = count > s.count;
|
||||
s.count = count;
|
||||
}
|
||||
s.cur = snapshot;
|
||||
return { before: s.before, forward: s.forward };
|
||||
}
|
||||
|
||||
/**
|
||||
* For things shown only while they animate (captured / taken-back stones): `[over, end]`. Render them while
|
||||
* `over` is false and pass `end` to the last one's onAnimationEnd, so finished ghosts leave the DOM (and do not
|
||||
* count as pieces for tests or screen readers). A new `key` (move number) shows them again.
|
||||
*/
|
||||
export function useAnimOver(key: unknown): [boolean, () => void] {
|
||||
const [ended, setEnded] = useState<unknown>(undefined);
|
||||
return [ended === key, () => setEnded(key)];
|
||||
}
|
||||
|
||||
/**
|
||||
* SVG-friendly classes (scale around the element's own centre). Wrap the moving thing in its own `<g>` without a
|
||||
* `transform` attribute, because a CSS transform replaces the attribute while it runs.
|
||||
* - `bm-place`: a stone / piece set down (lands from a little above, slightly bigger, with a tiny settle).
|
||||
* - `bm-slide`: slides in from `--bm-dx/--bm-dy` (board units, e.g. `-2px` = two cells left) over `--bm-dur`.
|
||||
* - `bm-gone`: a captured piece shrinking and fading (key it by the move number; remove it with useAnimOver).
|
||||
* - `bm-ring`: one ripple ring around the last move.
|
||||
* - `bm-win`: winning line pulsing, staggered with `--bm-delay`.
|
||||
* - `bm-flash`: a quick bright flash (check / 장군).
|
||||
*/
|
||||
export const BOARD_MOTION_CSS = `
|
||||
.bm-place, .bm-gone, .bm-ring, .bm-win, .bm-flash { transform-box: fill-box; transform-origin: center; }
|
||||
.bm-place { animation: bm-place .26s cubic-bezier(.25, .9, .35, 1.25) both; pointer-events: none; }
|
||||
@keyframes bm-place { 0% { transform: translateY(-18%) scale(1.3); opacity: .15; } 70% { transform: translateY(0) scale(.97); opacity: 1; } 100% { transform: none; } }
|
||||
.bm-slide { animation: bm-slide var(--bm-dur, .24s) cubic-bezier(.3, .75, .35, 1) both; }
|
||||
@keyframes bm-slide { from { transform: translate(var(--bm-dx, 0px), var(--bm-dy, 0px)); } }
|
||||
.bm-gone { animation: bm-gone .42s ease-in forwards; pointer-events: none; }
|
||||
@keyframes bm-gone { 0% { opacity: 1; transform: scale(1); } 35% { opacity: .9; transform: scale(1.08); } 100% { opacity: 0; transform: scale(.35); } }
|
||||
.bm-ring { animation: bm-ring .55s ease-out .1s both; pointer-events: none; }
|
||||
@keyframes bm-ring { from { opacity: .85; transform: scale(.5); } to { opacity: 0; transform: scale(1.6); } }
|
||||
.bm-win { animation: bm-win 1.1s ease-in-out infinite; animation-delay: var(--bm-delay, 0ms); pointer-events: none; }
|
||||
@keyframes bm-win { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.12); } }
|
||||
.bm-flash { animation: bm-flash .7s ease-out both; pointer-events: none; }
|
||||
@keyframes bm-flash { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: .55; } }
|
||||
/* The global reduced-motion rule makes animations 0.01ms long; an endless pulse would then flicker. */
|
||||
@media (prefers-reduced-motion: reduce) { .bm-win { animation: none; } }
|
||||
`;
|
||||
@@ -4,7 +4,7 @@ import type { Color, ConnectFourOptions, ConnectFourView } from '@bg/games/conne
|
||||
import type { PublicUser } from '@bg/shared/lite';
|
||||
import { Avatar, ConfirmSheet } from '../../components/ui';
|
||||
import { TurnTimer, useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic, sounds } from '../../lib/feedback';
|
||||
import { haptic, noise, sfx, tone } from '../../lib/feedback';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -15,11 +15,20 @@ const SIZE_KO: Record<ConnectFourOptions['boardSize'], string> = { '7x6': '7×6'
|
||||
/** Row counted from the bottom, 1-based (what people say: "아래에서 두 번째 줄"). */
|
||||
const rowFromBottom = (v: ConnectFourView, y: number) => v.rows - y;
|
||||
|
||||
/** Falls with gravity, hits the bottom at LAND (fraction of the animation), bounces once a little and settles. */
|
||||
const LAND = 0.78;
|
||||
/** Fall time for a disc that lands in row `y` (0 = top). */
|
||||
const fallSec = (y: number) => (0.16 + 0.06 * (y + 1)) / LAND;
|
||||
const CSS = `
|
||||
@keyframes c4drop { from { transform: translateY(var(--c4-from)); } to { transform: translateY(0); } }
|
||||
.c4-drop { animation: c4drop var(--c4-dur) cubic-bezier(.5, 0, 1, 1) both; }
|
||||
@keyframes c4drop {
|
||||
0% { transform: translateY(var(--c4-from)); animation-timing-function: cubic-bezier(.5, 0, 1, 1); }
|
||||
${LAND * 100}% { transform: translateY(0); animation-timing-function: ease-out; }
|
||||
89% { transform: translateY(-0.13px); animation-timing-function: ease-in; }
|
||||
100% { transform: translateY(0); }
|
||||
}
|
||||
.c4-drop { animation: c4drop var(--c4-dur) linear both; }
|
||||
@keyframes c4glow { 50% { opacity: .35; } }
|
||||
.c4-win { animation: c4glow 1.1s ease-in-out infinite; }
|
||||
.c4-win { animation: c4glow 1.1s ease-in-out infinite; animation-delay: var(--c4-delay, 0ms); }
|
||||
.c4-svg { --c4-frame: #1d4ed8; --c4-frame-edge: #1e3a8a; }
|
||||
:root[data-theme='dark'] .c4-svg { --c4-frame: #1e40af; --c4-frame-edge: #172554; }
|
||||
@media (prefers-color-scheme: dark) { :root[data-theme='auto'] .c4-svg { --c4-frame: #1e40af; --c4-frame-edge: #172554; } }
|
||||
@@ -55,14 +64,16 @@ function C4Board({ view: v, act, pending, tapConfirm }: BoardProps<ConnectFourVi
|
||||
|
||||
useEffect(() => {
|
||||
if (v.moveCount > prevCount.current && v.lastMove) {
|
||||
sounds.stone();
|
||||
// A light rattle as it leaves the hand, then the plastic clack when it hits the bottom (and a small second tap).
|
||||
const land = fallSec(v.lastMove.y) * LAND * 1000;
|
||||
noise(Math.min(160, land), 0.04, 0, 'bandpass', 1800, 0.7);
|
||||
tone(620, 70, 'triangle', 0.2, land);
|
||||
noise(45, 0.12, land, 'lowpass', 1400);
|
||||
tone(760, 40, 'triangle', 0.07, land + 110);
|
||||
const m = v.moves[v.moves.length - 1]!;
|
||||
setAnnounce(`${COLOR_KO[m.color]}이 ${m.x + 1}열에 넣었어요. 아래에서 ${rowFromBottom(v, m.y)}번째 칸이에요.${m.auto ? ' (시간이 다 돼서 자동으로)' : ''}`);
|
||||
}
|
||||
if (v.phase === 'playing' && myTurn && prevTurn.current !== v.turn && v.moveCount !== prevCount.current) {
|
||||
haptic(40);
|
||||
if (document.visibilityState === 'hidden') sounds.myTurn();
|
||||
}
|
||||
if (v.phase === 'playing' && myTurn && prevTurn.current !== v.turn && v.moveCount !== prevCount.current) haptic(40);
|
||||
prevCount.current = v.moveCount;
|
||||
prevTurn.current = v.turn;
|
||||
setPreview(null);
|
||||
@@ -87,6 +98,7 @@ function C4Board({ view: v, act, pending, tapConfirm }: BoardProps<ConnectFourVi
|
||||
if (!myTurn) return;
|
||||
if (!open(c)) {
|
||||
haptic([30, 30, 30]);
|
||||
sfx.bad();
|
||||
setAnnounce(`${c + 1}열은 꽉 찼어요. 다른 열을 골라 주세요.`);
|
||||
return;
|
||||
}
|
||||
@@ -157,16 +169,38 @@ function C4Board({ view: v, act, pending, tapConfirm }: BoardProps<ConnectFourVi
|
||||
<g
|
||||
key={i}
|
||||
className={anim ? 'c4-drop' : undefined}
|
||||
style={anim ? ({ '--c4-from': `${-(y + 1.5)}px`, '--c4-dur': `${0.16 + 0.06 * (y + 1)}s` } as React.CSSProperties) : undefined}
|
||||
style={anim ? ({ '--c4-from': `${-(y + 1.5)}px`, '--c4-dur': `${fallSec(y)}s` } as React.CSSProperties) : undefined}
|
||||
>
|
||||
<Disc color={c === 1 ? 'red' : 'yellow'} cx={x + 0.5} cy={y + 0.5} r={0.41} />
|
||||
</g>
|
||||
);
|
||||
})}
|
||||
<rect x={-pad} y={-pad} width={cols + 2 * pad} height={rows + 2 * pad} rx={0.3} fill="var(--c4-frame)" stroke="var(--c4-frame-edge)" strokeWidth={0.05} mask={`url(#${maskId})`} />
|
||||
{last >= 0 && !winSet.size && <circle cx={(last % cols) + 0.5} cy={Math.floor(last / cols) + 0.5} r={0.09} fill="#fff" opacity={0.85} />}
|
||||
{[...winSet].map((i) => (
|
||||
<circle key={`w${i}`} className="c4-win" cx={(i % cols) + 0.5} cy={Math.floor(i / cols) + 0.5} r={0.36} fill="none" stroke="#fff" strokeWidth={0.1} />
|
||||
{last >= 0 && !winSet.size && (
|
||||
// Shown once the falling disc has landed.
|
||||
<circle
|
||||
key={`lm${v.moveCount}`}
|
||||
className={falling.current === v.moveCount ? 'anim-pop' : undefined}
|
||||
style={{ '--anim-delay': `${fallSec(Math.floor(last / cols)) * 1000}ms`, transformBox: 'fill-box', transformOrigin: 'center' } as React.CSSProperties}
|
||||
cx={(last % cols) + 0.5}
|
||||
cy={Math.floor(last / cols) + 0.5}
|
||||
r={0.09}
|
||||
fill="#fff"
|
||||
opacity={0.85}
|
||||
/>
|
||||
)}
|
||||
{(v.winLine ?? []).map((p, k) => (
|
||||
<circle
|
||||
key={`w${p.x}-${p.y}`}
|
||||
className="c4-win"
|
||||
style={{ '--c4-delay': `${k * 120}ms` } as React.CSSProperties}
|
||||
cx={p.x + 0.5}
|
||||
cy={p.y + 0.5}
|
||||
r={0.36}
|
||||
fill="none"
|
||||
stroke="#fff"
|
||||
strokeWidth={0.1}
|
||||
/>
|
||||
))}
|
||||
{ghostCol !== null && v.myColor && <Disc color={v.myColor} cx={ghostCol + 0.5} cy={-0.55} r={0.41} ghost={preview === null} />}
|
||||
{myTurn && kbd && <rect x={cursor + 0.04} y={-1.08} width={0.92} height={rows + 1.04} rx={0.12} fill="none" stroke="var(--focus)" strokeWidth={0.07} />}
|
||||
|
||||
@@ -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} />}
|
||||
|
||||
@@ -4,7 +4,8 @@ import type { OthelloLegalMove, OthelloOptions, OthelloView } from '@bg/games/ot
|
||||
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, tone } from '../../lib/feedback';
|
||||
import { BOARD_MOTION_CSS } from '../board-motion';
|
||||
import { toast } from '../../store/toast';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
@@ -20,19 +21,29 @@ const COLOR_KO: Record<Color, string> = { black: '흑', white: '백' };
|
||||
const other = (c: Color): Color => (c === 'black' ? 'white' : 'black');
|
||||
const label = (p: Pt) => `${'abcdefgh'[p.x]}${p.y + 1}`;
|
||||
const FLIP_MS = 240;
|
||||
/** The placed disc lands first; the flips start right after. */
|
||||
const PLACE_MS = 140;
|
||||
|
||||
const CSS = `
|
||||
@keyframes oth-flip { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.05); } 100% { transform: scaleX(1); } }
|
||||
/* A disc is lifted a little while it turns over (edge-on in the middle), then set back down. */
|
||||
@keyframes oth-flip { 0% { transform: scale(1); } 50% { transform: scale(0.05, 1.14) translateY(-6%); } 100% { transform: scale(1); } }
|
||||
@keyframes oth-old { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
|
||||
@keyframes oth-drop { 0% { transform: scale(0.4); opacity: 0.4; } 100% { transform: scale(1); opacity: 1; } }
|
||||
.oth-flip { transform-box: fill-box; transform-origin: center; animation: oth-flip ${FLIP_MS}ms ease-in-out both; }
|
||||
.oth-old { animation: oth-old ${FLIP_MS}ms linear both; }
|
||||
.oth-drop { transform-box: fill-box; transform-origin: center; animation: oth-drop 160ms ease-out both; }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.oth-flip, .oth-drop { animation: none; }
|
||||
.oth-flip { animation: none; }
|
||||
.oth-old { display: none; }
|
||||
}`;
|
||||
|
||||
/** Disc set down, then one light click per disc as it turns over (staggered like the animation). */
|
||||
function placeSound(flipDelays: number[]) {
|
||||
sfx.stone();
|
||||
flipDelays
|
||||
.sort((a, b) => a - b)
|
||||
.slice(0, 10)
|
||||
.forEach((d, k) => tone(1500 + (k % 4) * 90, 30, 'triangle', 0.06, d + FLIP_MS / 2));
|
||||
}
|
||||
|
||||
function Disc({ color, cx, cy, r = 0.4, ghost }: { color: Color; cx: number; cy: number; r?: number; ghost?: boolean }) {
|
||||
const black = color === 'black';
|
||||
return (
|
||||
@@ -74,6 +85,7 @@ function OthelloBoard({ view: v, act, pending, tapConfirm }: BoardProps<OthelloV
|
||||
prevCount.current = v.moveCount;
|
||||
setPreview(null);
|
||||
if (v.moveCount <= prev) {
|
||||
if (v.moveCount < prev) sfx.whoosh();
|
||||
setAnim(null);
|
||||
return;
|
||||
}
|
||||
@@ -95,16 +107,17 @@ function OthelloBoard({ view: v, act, pending, tapConfirm }: BoardProps<OthelloV
|
||||
setAnnounce(texts.join(' '));
|
||||
const lm = v.lastMove;
|
||||
if (lm && added.some((m) => m.kind === 'place')) {
|
||||
sounds.stone();
|
||||
const dist = (i: number) => Math.max(Math.abs((i % N) - lm.x), Math.abs(Math.floor(i / N) - lm.y));
|
||||
const maxD = Math.max(1, ...lm.flipped.map(dist));
|
||||
const step = maxD > 1 ? Math.min(60, (400 - FLIP_MS) / (maxD - 1)) : 0;
|
||||
setAnim({ key: v.moveCount, at: lm.y * N + lm.x, from: other(lm.color), delay: new Map(lm.flipped.map((i) => [i, (dist(i) - 1) * step])) });
|
||||
} else setAnim(null);
|
||||
if (v.phase === 'playing' && v.myColor === v.turn) {
|
||||
haptic(40);
|
||||
if (document.visibilityState === 'hidden') sounds.myTurn();
|
||||
const delay = new Map(lm.flipped.map((i) => [i, PLACE_MS + (dist(i) - 1) * step]));
|
||||
placeSound([...delay.values()]);
|
||||
setAnim({ key: v.moveCount, at: lm.y * N + lm.x, from: other(lm.color), delay });
|
||||
} else {
|
||||
if (added.length) sfx.whoosh();
|
||||
setAnim(null);
|
||||
}
|
||||
if (v.phase === 'playing' && v.myColor === v.turn) haptic(40);
|
||||
}, [v.moveCount]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const canPlace = (p: Pt) => myTurn && !pending && legal.has(p.y * N + p.x);
|
||||
@@ -178,7 +191,7 @@ function OthelloBoard({ view: v, act, pending, tapConfirm }: BoardProps<OthelloV
|
||||
|
||||
return (
|
||||
<div className="board-wrap stack" style={{ gap: 10 }}>
|
||||
<style>{CSS}</style>
|
||||
<style>{BOARD_MOTION_CSS + CSS}</style>
|
||||
<div
|
||||
aria-label={`돌 수: 흑 ${v.discs.black}개, 백 ${v.discs.white}개`}
|
||||
role="img"
|
||||
@@ -263,7 +276,7 @@ function OthelloBoard({ view: v, act, pending, tapConfirm }: BoardProps<OthelloV
|
||||
}
|
||||
if (anim && anim.at === i) {
|
||||
return (
|
||||
<g key={`a${anim.key}-${i}`} className="oth-drop">
|
||||
<g key={`a${anim.key}-${i}`} className="bm-place">
|
||||
<Disc color={color} cx={cx} cy={cy} />
|
||||
</g>
|
||||
);
|
||||
@@ -273,7 +286,12 @@ function OthelloBoard({ view: v, act, pending, tapConfirm }: BoardProps<OthelloV
|
||||
{[...flipSet].map((i) => (
|
||||
<circle key={`h${i}`} cx={(i % N) + 0.5} cy={Math.floor(i / N) + 0.5} r={0.44} fill="rgba(255, 224, 102, 0.45)" stroke="#ffd84d" strokeWidth={0.05} />
|
||||
))}
|
||||
{v.lastMove && <circle cx={v.lastMove.x + 0.5} cy={v.lastMove.y + 0.5} r={0.1} fill="#ef4444" stroke="#fff" strokeWidth={0.025} />}
|
||||
{v.lastMove && (
|
||||
<g key={`lm${v.moveCount}`}>
|
||||
{anim && anim.at === v.lastMove.y * N + v.lastMove.x && <circle className="bm-ring" cx={v.lastMove.x + 0.5} cy={v.lastMove.y + 0.5} r={0.48} fill="none" stroke="#ffd84d" strokeWidth={0.05} />}
|
||||
<circle cx={v.lastMove.x + 0.5} cy={v.lastMove.y + 0.5} r={0.1} fill="#ef4444" stroke="#fff" strokeWidth={0.025} />
|
||||
</g>
|
||||
)}
|
||||
{showGhost && target && v.myColor && <Disc color={v.myColor} cx={target.x + 0.5} cy={target.y + 0.5} ghost />}
|
||||
{myTurn && kbd && <rect x={cursor.x + 0.04} y={cursor.y + 0.04} width={0.92} height={0.92} rx={0.08} fill="none" stroke="var(--focus)" strokeWidth={0.07} />}
|
||||
</svg>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
| `undo` | 무르기 허용 횟수(1인당, 상대 동의) | `off` / `1` / `3` / `unlimited` | `3` |
|
||||
| `drawOffer` | 무승부(빅) 합의 제안 허용 | `true` / `false` | `true` |
|
||||
| `atariWarning` | **관리자 전용** 위협 가이드: 단수에 몰린 내 돌 표시(방장은 못 바꿈) | `true` / `false` | `false` |
|
||||
| `scoringDeadlineSec` | 사석 확인 단계 제한 시간 | 120 / 180 / 300 | 180 |
|
||||
| `scoringDeadlineSec` | 사석 확인 단계 제한 시간 | 120 / 180 / 300 / 0(무제한) | 180 |
|
||||
| `disconnectGraceSec` | 연결 끊김 유예 | 60 / 120 / 300 | 120 |
|
||||
|
||||
## 3. 구성물
|
||||
@@ -84,7 +84,7 @@
|
||||
3. 표시가 바뀌면 양쪽 `agreed`가 모두 해제된다. 현재 표시를 기준으로 계가 미리보기가 실시간으로 갱신된다.
|
||||
4. 두 플레이어가 같은 표시 상태에 대해 모두 "동의"하면 계가 확정 → 종료.
|
||||
5. 어느 한쪽이 "이의 – 대국 재개"를 누르면 표시를 모두 버리고 `playing`으로 복귀한다. 재개 후 첫 수는 재개를 요청한 사람의 상대가 둔다(일본기원 규약 제9조와 같은 방식). 재개 후 다시 연속 2패스가 나오면 5.5를 다시 진행한다.
|
||||
6. 사석 확인 단계에서 시계는 멈춘다. 대신 `scoringDeadlineSec` 제한이 있다(8.5).
|
||||
6. 사석 확인 단계에서 시계는 멈춘다. 대신 `scoringDeadlineSec` 제한이 있다(8.5). `0`(무제한)이면 마감 없이 두 사람이 동의할 때까지 기다린다(타이머 숨김, 자리를 떠난 사람은 `onLeave`로 처리).
|
||||
- 자동 제안 휴리스틱(단순·결정적): (a) 활로 1개인 연결 중 그 활로에 상대가 두면 따내지고 되따기도 불가능한 것, (b) 상대 영역(상대 돌로만 둘러싸인 빈 영역)에 완전히 갇혀 있고 그 영역 안에서 두 눈(서로 떨어진 두 개 이상의 단독 빈 영역)이 없는 연결. 오판이 있어도 플레이어가 고치면 되므로 단순하게 둔다. 향후 KataGo 같은 엔진 기반 추정은 별도 작업으로 분리.
|
||||
|
||||
### 5.6 공배와 빅(세키)
|
||||
@@ -202,7 +202,7 @@ interface BadukState {
|
||||
- `playing` + `byoyomi`: `turnStartedAt + mainMs[turn] + periodsLeft[turn] * periodSec*1000` (현재 회차를 다 쓰면 다음 회차가 이어지므로 이 합이 최종 시간패 시각)
|
||||
- `playing` + `fischer`: `turnStartedAt + mainMs[turn]`
|
||||
- `playing` + `none`: `null` — 시간 제한 없음은 정말 마감이 없다(무응답 시간패 없음). 연결이 끊긴 사람만 방의 접속 유예(`graceSec`) 뒤에 처리한다.
|
||||
- `scoring`: `scoringMarks.startedAt + scoringDeadlineSec*1000`
|
||||
- `scoring`: `scoringMarks.startedAt + scoringDeadlineSec*1000` (`0`이면 `null`)
|
||||
- `finished`: `null`
|
||||
- `activePlayers`: `playing`이면 차례인 1명. `scoring`이면 아직 `agreed`하지 않은 플레이어 전원(동시 행동 단계).
|
||||
- `onTimeout(state, player)` → `{ type: 'timeout' }`. `apply` 처리:
|
||||
@@ -231,6 +231,7 @@ interface BadukResult {
|
||||
- 모바일 세로: 상단 상대 정보(따낸 돌, 시계 + 초읽기 남은 횟수 점 3개), 가운데 정사각 판, 하단 내 정보와 버튼(패스, 무르기, 무승부, 기권, 규칙 보기).
|
||||
- 19줄은 교차점 간격이 약 18px라 "탭 → 미리보기 돌 + 확대 돋보기 → 확인 버튼" 2단계 착수가 기본. 9줄은 한 번 탭 착수 옵션 제공.
|
||||
- 마지막 수 표시, 따낸 돌 사라지는 애니메이션과 효과음(끌 수 있음), 단수 경고(옵션) 시 해당 연결 테두리 깜빡임.
|
||||
- 소리·움직임(2026-10-13): 새 돌은 살짝 위에서 내려앉고 마지막 수에 고리가 한 번 퍼진다("딱" = `sfx.stone`). 따낸 돌은 한 알씩 들어 올리듯 작아지며 사라지고, 그 수만큼(최대 6) 작은 "딸깍" 소리가 이어진다. 패스는 낮은 "톡", 무르기는 물린 돌이 사라지고 따냈던 돌이 다시 나타나며 `sfx.whoosh`. 사석 확인에서 표시가 바뀌면 `sfx.click`. 상대·컴퓨터의 수에도 똑같이 나오고, 새로 고침했을 땐 움직이지 않는다.
|
||||
- 패/자충 금지점을 탭하면 이유 말풍선.
|
||||
- 초읽기 진입 시 음성/효과음 카운트("10, 9, …")와 화면 테두리 색 변화(어르신 배려: 큰 숫자).
|
||||
- 패스 버튼은 실수 방지를 위해 확인 모달. 상대가 패스하면 "상대가 패스했어요. 끝내려면 패스하세요" 안내.
|
||||
|
||||
@@ -111,7 +111,8 @@ interface ConnectFourState {
|
||||
- 떨어지는 애니메이션: 새 원반만, 떨어지는 높이에 비례해 0.2~0.6초. `prefers-reduced-motion`이면 애니메이션 없음(이긴 줄 깜빡임도 끔). 처음 들어오거나 새로 고침했을 땐 애니메이션 없음.
|
||||
- 열 전체(미리 보기 줄 포함)가 터치 영역 — 7×6 판이 휴대폰 390px에서 열 너비 약 50px. 마우스는 한 번 누르면 바로 넣기(올려 두면 미리 보기). 터치는 "한 번 더 누르기 확인" 설정이 켜져 있으면 처음 누르면 미리 보기, 같은 열을 다시 누르거나 [N열에 넣기]로 확정.
|
||||
- 키보드: 판(`role="grid"`)에 초점 → ←·→로 열 고르기, Home·End로 끝 열, Enter·Space로 넣기. 꽉 찬 열이면 스크린리더에 "N열은 꽉 찼어요" 안내. 둘 때마다 "빨강이 4열에 넣었어요. 아래에서 2번째 칸이에요." 읽어 줌.
|
||||
- 마지막 수에 흰 점, 이긴 줄은 흰 고리로 강조(깜빡임).
|
||||
- 마지막 수에 흰 점(원반이 닿은 뒤 나타남), 이긴 줄은 흰 고리로 강조(줄 순서대로 번갈아 깜빡임).
|
||||
- 소리·움직임(2026-10-13): 원반은 떨어져 바닥에 닿은 뒤 한 번 살짝 튀고 멈춘다. 소리는 손을 떠날 때 작은 달그락, 바닥에 닿는 순간 플라스틱 "탁"과 작은 두 번째 탁(떨어지는 시간에 맞춤). 꽉 찬 열을 누르면 작은 `sfx.bad`. 상대·컴퓨터의 수에도 똑같이 나온다.
|
||||
- 오른쪽 패널(휴대폰은 판 아래): 두 사람(색, 먼저/나중, 남은 시간), 기권 버튼(확인 창), 기보("1. 🔴 4열", 자동 두기는 *).
|
||||
- 다크 모드: 틀 색을 조금 어둡게, 구멍은 배경색.
|
||||
- 30초 요약 3장: 열 골라 넣기 / 4개 이으면 승리 / 3개면 꼭 막기. [?] 도움말: 차례, 꽉 찬 열, 첫 수 가운데 팁, 3개 막기 팁.
|
||||
|
||||
@@ -289,6 +289,7 @@ interface OmokResult {
|
||||
- 모바일 세로: 상단에 상대 정보(닉네임, 돌 색, 남은 시간 바), 가운데 정사각 판(화면 폭 100%), 하단에 내 정보와 버튼 줄(무르기, 무승부, 기권, 규칙 보기). 15줄 판은 폰 폭 360px에서 교차점 간격이 약 23px라 48px 터치 기준을 못 맞추므로, 착수는 "탭 → 확대 미리보기 돌 표시 → 확인 버튼(48px 이상)" 2단계로 한다. 옵션으로 "한 번 탭으로 바로 두기"(PC 기본값).
|
||||
- 판 핀치 줌/드래그 지원(19줄 필수).
|
||||
- 마지막 수 표시(빨간 점), 승리 줄 강조 애니메이션.
|
||||
- 소리·움직임(2026-10-13): 새 돌은 살짝 위에서 내려앉고(0.26초) 마지막 수 자리에 고리가 한 번 퍼진다. 착수 소리는 공통 `sfx.stone`("딱"), 무르기는 물린 돌이 작아지며 사라지고 `sfx.whoosh`, 금수 자리를 누르면 작은 `sfx.bad`. 이긴 다섯 돌의 초록 고리는 줄 순서대로 번갈아 반짝인다. 상대·컴퓨터의 수에도 똑같이 나오고, 처음 들어오거나 새로 고침했을 땐 움직이지 않는다. 승패 소리는 결과 화면(공통)이 낸다.
|
||||
- 금수 자리는 흑 차례일 때 작은 ×표. 금수 자리 탭 시 이유를 말풍선으로 설명("여기는 쌍삼이라 둘 수 없어요").
|
||||
- 힌트 켜짐: 상대가 열린 삼/사를 만들면 해당 줄을 노란색으로 잠깐 표시.
|
||||
- 무르기/무승부 요청은 상대 화면에 큰 모달(수락/거절 버튼 각 48px 이상).
|
||||
|
||||
@@ -122,7 +122,8 @@ interface OthelloResult {
|
||||
## 9. UI/UX
|
||||
- 모바일 세로: 상단 상대(돌 수, 시계), 가운데 8×8 판(폰 360px에서 칸 약 44px — 칸 전체가 터치 영역, 48px에 근접하므로 한 번 탭 착수 허용), 하단 내 정보와 버튼.
|
||||
- 둘 수 있는 칸은 작은 반투명 점. `showFlipCount`면 숫자.
|
||||
- 착수 시 뒤집히는 돌을 놓은 돌에서 가까운 순서로 순차 회전 애니메이션(전체 400ms 이내).
|
||||
- 착수 시 뒤집히는 돌을 놓은 돌에서 가까운 순서로 순차 회전 애니메이션(전체 400ms 이내). 놓은 돌이 먼저 내려앉고(0.14초) 그다음 뒤집기가 시작되며, 뒤집히는 돌은 옆으로 서는 순간 살짝 들린다.
|
||||
- 소리(2026-10-13): 놓을 때 `sfx.stone`, 돌이 하나 뒤집힐 때마다 작은 "딸깍"(최대 10번, 애니메이션 순서에 맞춤), 패스·무르기는 `sfx.whoosh`. 마지막 수 자리에 노란 고리가 한 번 퍼진다. 상대·컴퓨터의 수에도 똑같이 나온다.
|
||||
- 자동 패스 시 "둘 곳이 없어서 차례가 넘어갔어요" 토스트(상대 화면에도).
|
||||
- 돌 수 막대(흑/백 비율)를 상단에 상시 표시.
|
||||
- 규칙 보기: 끼워서 뒤집기 3단계 그림, 패스 설명, 모서리 팁(선택).
|
||||
|
||||
@@ -1486,6 +1486,10 @@ const PLANS: Record<string, Plan> = {
|
||||
await finishHand(pages);
|
||||
},
|
||||
},
|
||||
omok: {
|
||||
// cursor starts at the centre: black plays there, white one point to the left (the full omok flow is e2e/omok.e2e.ts)
|
||||
moves: [['Enter'], ['ArrowLeft', 'Enter']],
|
||||
},
|
||||
othello: {
|
||||
// cursor starts at d4 (3,3): black d3 = up; then white c3 = up, left
|
||||
moves: [['ArrowUp', 'Enter'], ['ArrowUp', 'ArrowLeft', 'Enter']],
|
||||
|
||||
@@ -160,6 +160,17 @@ describe('passing and scoring phase (§5.4–5.5)', () => {
|
||||
expect(baduk.deadline!(s)).toBe(1000 + 180_000);
|
||||
});
|
||||
|
||||
test('사석 확인 무제한(scoringDeadlineSec 0): no deadline, no timer in the view, agreeing still finishes', () => {
|
||||
let s = playAll(make({ scoringDeadlineSec: 0, timeControl: { kind: 'none' } as BadukOptions['timeControl'] }), ['pass', 'pass']);
|
||||
expect(s.phase).toBe('scoring');
|
||||
expect(baduk.deadline!(s)).toBeNull();
|
||||
expect(baduk.view(s, 'A').scoring!.deadlineAt).toBeNull();
|
||||
expect(badukOptionsSchema.safeParse({ scoringDeadlineSec: 0 }).success).toBe(true);
|
||||
s = act(s, 'black', { type: 'agreeScore' });
|
||||
s = act(s, 'white', { type: 'agreeScore' });
|
||||
expect(s.phase).toBe('finished');
|
||||
});
|
||||
|
||||
test('toggling dead stones clears agreement; both agreeing finishes', () => {
|
||||
let s = playAll(make({}, { black: ['E4'], white: ['E6'] }), ['pass', 'pass']);
|
||||
s = act(s, 'black', { type: 'agreeScore' });
|
||||
|
||||
@@ -77,9 +77,9 @@ export const badukOptionsSchema = z
|
||||
drawReofferMoves: z.number().int().min(0).max(50).default(5).meta({ title: '무승부 다시 제안까지 둬야 하는 수' }),
|
||||
atariWarning: z.boolean().default(false).meta({ title: '위협 가이드(관리자 전용): 단수에 몰린 내 돌 표시' }),
|
||||
scoringDeadlineSec: z
|
||||
.union([z.literal(120), z.literal(180), z.literal(300)])
|
||||
.union([z.literal(120), z.literal(180), z.literal(300), z.literal(0)])
|
||||
.default(180)
|
||||
.meta({ title: '사석 확인 제한 시간', labels: { 120: '2분', 180: '3분', 300: '5분' } }),
|
||||
.meta({ title: '사석 확인 제한 시간', labels: { 120: '2분', 180: '3분', 300: '5분', 0: '무제한' } }),
|
||||
})
|
||||
.superRefine((o, ctx) => {
|
||||
if (o.boardSize === 9 && o.handicap > 5) ctx.addIssue({ code: 'custom', path: ['handicap'], message: '9줄 판은 접바둑 5점까지만 둘 수 있어요.' });
|
||||
@@ -202,7 +202,8 @@ export interface BadukView {
|
||||
/** Every point of seki-marked regions. */
|
||||
seki: Pt[];
|
||||
agreed: Record<Color, boolean>;
|
||||
deadlineAt: number;
|
||||
/** null = 무제한 (scoringDeadlineSec 0). */
|
||||
deadlineAt: number | null;
|
||||
durationMs: number;
|
||||
preview: ScoreBreakdown;
|
||||
} | null;
|
||||
@@ -788,7 +789,7 @@ export const baduk: GameDefinition<BadukState, BadukAction, BadukView, BadukOpti
|
||||
dead: m.dead.map((i) => toPt(i, s.size)),
|
||||
seki: sekiPoints(s).map((i) => toPt(i, s.size)),
|
||||
agreed: m.agreed,
|
||||
deadlineAt: m.startedAt + s.options.scoringDeadlineSec * 1000,
|
||||
deadlineAt: s.options.scoringDeadlineSec ? m.startedAt + s.options.scoringDeadlineSec * 1000 : null,
|
||||
durationMs: s.options.scoringDeadlineSec * 1000,
|
||||
preview: scoreOf(s),
|
||||
}
|
||||
@@ -807,7 +808,7 @@ export const baduk: GameDefinition<BadukState, BadukAction, BadukView, BadukOpti
|
||||
},
|
||||
|
||||
deadline(s) {
|
||||
if (s.phase === 'scoring') return s.scoringMarks!.startedAt + s.options.scoringDeadlineSec * 1000;
|
||||
if (s.phase === 'scoring') return s.options.scoringDeadlineSec ? s.scoringMarks!.startedAt + s.options.scoringDeadlineSec * 1000 : null;
|
||||
if (s.phase !== 'playing') return null;
|
||||
const tc = s.options.timeControl;
|
||||
const start = s.clock.turnStartedAt;
|
||||
|
||||
Reference in New Issue
Block a user