움직임 더하기 2차: 루미큐브·마피아·라이어·바둑·클루·오목·포커
- 루미큐브: 옮긴 타일이 원래 자리에서 미끄러져 가고, 남이 바닥에 낸 타일은 그 사람 칸에서 날아옴. 가져온 타일은 남은 타일 더미에서 받침대로 날아오고, 남이 가져가면 뒤집힌 타일이 그 사람 칸으로 날아감. 배너를 공통 useBanner로 바꾸고 "루미큐브!"·"판 끝"·승리 배너 추가 - 마피아: 밤에는 화면이 남색으로 어두워지며 달, 아침에는 해가 떠오름. 득표 막대가 한 줄씩 자라고, 탈락한 사람 칸이 뒤집히며 흐려짐. 탈락·살았다·버텼다·조용한 밤·이긴 팀 배너를 차례로 - 라이어: 득표가 한 줄씩 나온 뒤 지목된 사람에게 스포트라이트와 흔들림, "잡았다!"/"헛다리!"·동점·정답/땡·승리 배너 - 바둑: 패스·계가 배너, 계가 때 집 표시가 차례로 나타나고 결과 점수가 0부터 올라감, 승리 배너 - 클루: 말과 흉기가 새 자리로 튀어 오르며 미끄러져 감, 추리한 세 장이 사건 봉투로 날아가고, 보여 준 카드는 뒤집히며(남에게는 뒷면 카드가 날아감) - 오목: 금수 자리를 누르면 빨간 ✕와 "금수" 글자, 판이 흔들림(키보드 Enter도 같은 안내). "오목!"·승패 배너 - 포커: 쇼다운·인디언 이마 카드가 뒷면이 돌아간 뒤 앞면이 돌아 나오는 진짜 뒤집기로 - 모두 누구의 행동이든 화면 변화에 반응하고, 클릭을 막지 않으며, 동작 줄이기 설정을 따름. 게임 문서 UI 절에 반영 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { Avatar, ConfirmSheet, Sheet } from '../../components/ui';
|
||||
import { TurnTimer, useServerNow } from '../../components/TurnTimer';
|
||||
import { haptic, noise, sfx, sounds, tone } from '../../lib/feedback';
|
||||
import { BOARD_MOTION_CSS, useAnimOver, useMoveDiff } from '../board-motion';
|
||||
import { reducedMotion, useBanner } from '../card-fx';
|
||||
import type { BoardProps, GameUI, OptionsProps } from '../types';
|
||||
import { helpNow } from './help';
|
||||
import { quickStart } from './quick';
|
||||
@@ -60,6 +61,34 @@ function Stone({ color, cx, cy, r, ghost }: { color: Color; cx: number; cy: numb
|
||||
|
||||
type MarkMode = 'dead' | 'seki';
|
||||
|
||||
/** Territory marks pop in from the top-left corner outwards when counting starts (scoring / the result). */
|
||||
const BADUK_CSS = `
|
||||
.bd-own { transform-box: fill-box; transform-origin: center; animation: bd-own .32s cubic-bezier(.3, 1.5, .5, 1) both; animation-delay: var(--d, 0ms); }
|
||||
@keyframes bd-own { from { opacity: 0; transform: scale(.2); } }
|
||||
`;
|
||||
|
||||
/**
|
||||
* A number counting up from 0 when `live` (the game ended on screen); the final value right away otherwise or with
|
||||
* reduced motion. Put it inside an aria-hidden element next to the final value for screen readers.
|
||||
*/
|
||||
function CountUp({ to, live }: { to: number; live: boolean }) {
|
||||
const animate = live && !reducedMotion();
|
||||
const [shown, setShown] = useState<number | null>(animate ? 0 : null);
|
||||
useEffect(() => {
|
||||
if (!animate) return setShown(null);
|
||||
let raf = 0;
|
||||
const t0 = performance.now();
|
||||
const step = (t: number) => {
|
||||
const k = Math.min(1, (t - t0) / 1000);
|
||||
setShown(k < 1 ? Math.floor(to * (1 - (1 - k) ** 3)) : null);
|
||||
if (k < 1) raf = requestAnimationFrame(step);
|
||||
};
|
||||
raf = requestAnimationFrame(step);
|
||||
return () => cancelAnimationFrame(raf);
|
||||
}, [to, animate]);
|
||||
return <>{shown ?? to}</>;
|
||||
}
|
||||
|
||||
function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>) {
|
||||
const n = v.size;
|
||||
const myTurn = v.phase === 'playing' && v.myColor === v.turn;
|
||||
@@ -75,6 +104,12 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
|
||||
const svgRef = useRef<SVGSVGElement>(null);
|
||||
const prevCount = useRef(v.moveCount);
|
||||
const prevDead = useRef<Set<number> | null>(null);
|
||||
const [banner, showBanner] = useBanner();
|
||||
// When counting started on screen (scoring or the result): the territory marks pop in for a moment after that.
|
||||
const counted = useRef<{ phase: string; at: number }>({ phase: v.phase, at: 0 });
|
||||
if (counted.current.phase !== v.phase) counted.current = { phase: v.phase, at: v.phase === 'playing' ? 0 : Date.now() };
|
||||
const ownAnim = counted.current.at > 0;
|
||||
const ownStagger = ownAnim && Date.now() - counted.current.at < 1500;
|
||||
|
||||
const illegal = useMemo(() => new Map(v.illegalPoints.map((p) => [p.y * n + p.x, p.reason])), [v.illegalPoints, n]);
|
||||
// Dead stones: the live marks while scoring, or (after the game) stones owned by the other colour.
|
||||
@@ -106,10 +141,11 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
|
||||
}
|
||||
setAnnounce(`${COLOR_KO[m.color]}이 ${label(n, m.pt)}에 두었어요.${m.captured ? ` 돌 ${m.captured}개를 따냈어요.` : ''}`);
|
||||
} else {
|
||||
// 패스: a soft knock on the board edge.
|
||||
// 패스: a soft knock on the board edge (the second pass shows the counting banner instead).
|
||||
tone(330, 90, 'sine', 0.1);
|
||||
noise(50, 0.05, 0, 'lowpass', 700);
|
||||
setAnnounce(`${COLOR_KO[m.color]}이 패스했어요.`);
|
||||
if (v.phase === 'playing') showBanner('패스', 'dark', `${COLOR_KO[m.color]}이 이번 차례를 쉬어요`);
|
||||
}
|
||||
if (myTurn) haptic(40);
|
||||
} else if (v.moveCount < prevCount.current) sfx.whoosh();
|
||||
@@ -118,6 +154,21 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
|
||||
setBubble(null);
|
||||
}, [v.moveCount]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Counting starts / the game ends (for both players and watchers).
|
||||
const prevPhase = useRef(v.phase);
|
||||
useEffect(() => {
|
||||
const before = prevPhase.current;
|
||||
prevPhase.current = v.phase;
|
||||
if (before === v.phase) return;
|
||||
if (v.phase === 'scoring') {
|
||||
showBanner('계가', 'blue', '두 사람 모두 패스했어요. 사석을 확인해요');
|
||||
sfx.whoosh();
|
||||
} else if (v.phase === 'finished' && v.result) {
|
||||
const w = v.result.winner;
|
||||
showBanner(w ? `${COLOR_KO[w]} 승리!` : '무승부', w ? (w === v.myColor ? 'gold' : v.myColor ? 'dark' : 'blue') : 'green', v.result.summaryKo);
|
||||
}
|
||||
}, [v.phase]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// Highlight groups whose dead/alive mark just changed (e.g. by the opponent).
|
||||
useEffect(() => {
|
||||
if (!v.scoring) {
|
||||
@@ -210,7 +261,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>
|
||||
<style>{BOARD_MOTION_CSS + BADUK_CSS}</style>
|
||||
<svg
|
||||
ref={svgRef}
|
||||
viewBox={`${-pad} ${-pad} ${n - 1 + 2 * pad} ${n - 1 + 2 * pad}`}
|
||||
@@ -300,7 +351,22 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
|
||||
{score &&
|
||||
score.ownership.map((o, i) => {
|
||||
if (o === 0 || (v.board[i] !== 0 && !dead.has(i))) return null;
|
||||
return <rect key={`o${i}`} x={(i % n) - 0.17} y={Math.floor(i / n) - 0.17} width={0.34} height={0.34} fill={o === 1 ? '#111' : '#fafafa'} stroke={o === 1 ? '#000' : '#555'} strokeWidth={0.03} />;
|
||||
const x = i % n;
|
||||
const y = Math.floor(i / n);
|
||||
return (
|
||||
<rect
|
||||
key={`o${i}`}
|
||||
className={ownAnim ? 'bd-own' : undefined}
|
||||
style={ownStagger ? ({ '--d': `${Math.min((x + y) * 24, 900)}ms` } as React.CSSProperties) : undefined}
|
||||
x={x - 0.17}
|
||||
y={y - 0.17}
|
||||
width={0.34}
|
||||
height={0.34}
|
||||
fill={o === 1 ? '#111' : '#fafafa'}
|
||||
stroke={o === 1 ? '#000' : '#555'}
|
||||
strokeWidth={0.03}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{[...seki].map((i) => (
|
||||
<path key={`seki${i}`} d={`M ${i % n} ${Math.floor(i / n) - 0.2} l 0.2 0.2 l -0.2 0.2 l -0.2 -0.2 z`} fill="#f59e0b" opacity={0.9} />
|
||||
@@ -336,6 +402,7 @@ function BadukBoard({ view: v, act, pending, tapConfirm }: BoardProps<BadukView>
|
||||
<p className="sr-only" aria-live="polite">
|
||||
{announce}
|
||||
</p>
|
||||
{banner}
|
||||
{bubble && (
|
||||
<div className="card" role="status" style={{ padding: '8px 12px', border: '2px solid var(--danger)', fontWeight: 600 }}>
|
||||
{label(n, bubble.p)}: {bubble.text}
|
||||
@@ -479,6 +546,9 @@ function BadukSide({ view: v, me, players, act, pending, deadline }: BoardProps<
|
||||
const myTurn = v.phase === 'playing' && v.myColor === v.turn;
|
||||
const last = v.moves[v.moves.length - 1];
|
||||
const oppPassed = myTurn && last && !last.pt && last.color !== v.myColor;
|
||||
// The final score counts up only when the game ended while this screen was open.
|
||||
const ended = useRef({ phase: v.phase, live: false });
|
||||
if (ended.current.phase !== v.phase) ended.current = { phase: v.phase, live: v.phase === 'finished' };
|
||||
return (
|
||||
<>
|
||||
<PlayerBar view={v} color={v.myColor ? opp : 'black'} players={players} deadline={deadline} me={me} />
|
||||
@@ -492,6 +562,12 @@ function BadukSide({ view: v, me, players, act, pending, deadline }: BoardProps<
|
||||
{v.phase === 'finished' && v.result?.score && (
|
||||
<div className="card stack" style={{ padding: 14, gap: 8 }}>
|
||||
<strong style={{ fontSize: '1.15rem' }}>{v.result.summaryKo}</strong>
|
||||
<div style={{ fontSize: '1.5rem', fontWeight: 800, textAlign: 'center', fontVariantNumeric: 'tabular-nums' }}>
|
||||
<span className="sr-only">{`흑 ${v.result.score.black.total} : 백 ${v.result.score.white.total}`}</span>
|
||||
<span aria-hidden>
|
||||
흑 <CountUp to={v.result.score.black.total} live={ended.current.live} /> : 백 <CountUp to={v.result.score.white.total} live={ended.current.live} />
|
||||
</span>
|
||||
</div>
|
||||
<ScoreTable score={v.result.score} heading />
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user