129 lines
5.3 KiB
TypeScript
129 lines
5.3 KiB
TypeScript
/** 윷놀이 30초 규칙 요약 (docs/07 §5). */
|
|
import type { ReactNode } from 'react';
|
|
import type { QuickCard } from '../types';
|
|
|
|
/** One 윷가락: 배(flat, light) or 등(round, dark with marks). */
|
|
function Stick({ x, flat }: { x: number; flat: boolean }) {
|
|
return (
|
|
<g>
|
|
<rect x={x} y={8} width={18} height={64} rx={9} fill={flat ? '#f6e4b8' : '#a86b2d'} stroke={flat ? '#9a7432' : '#5c3713'} strokeWidth={2} />
|
|
{flat ? (
|
|
<line x1={x + 9} y1={16} x2={x + 9} y2={64} stroke="#d9bd83" strokeWidth={1.5} />
|
|
) : (
|
|
[20, 32, 44, 56].map((y) => <line key={y} x1={x + 5} y1={y} x2={x + 13} y2={y} stroke="#f6e4b8" strokeWidth={2} strokeLinecap="round" opacity={0.7} />)
|
|
)}
|
|
</g>
|
|
);
|
|
}
|
|
|
|
function SticksPic() {
|
|
const groups: [boolean[], string][] = [
|
|
[[true, true, true, false], '걸 · 3칸'],
|
|
[[true, true, true, true], '윷 · 4칸+1번'],
|
|
];
|
|
return (
|
|
<svg viewBox="0 0 260 110" width={250} height={106} aria-hidden>
|
|
{groups.map(([flats, label], g) => (
|
|
<g key={g} transform={`translate(${g * 135} 0)`}>
|
|
{flats.map((f, i) => (
|
|
<Stick key={i} x={6 + i * 28} flat={f} />
|
|
))}
|
|
<text x={60} y={98} textAnchor="middle" fontSize={17} fontWeight={800} fill="#3b2a12">
|
|
{label}
|
|
</text>
|
|
</g>
|
|
))}
|
|
</svg>
|
|
);
|
|
}
|
|
|
|
// Board geometry like the game screen: 참먹이 bottom-right, pieces go anticlockwise.
|
|
const LO = 8;
|
|
const HI = 92;
|
|
const GAP = (HI - LO) / 5;
|
|
const POS: [number, number][] = (() => {
|
|
const p: [number, number][] = [];
|
|
p[0] = [HI, HI];
|
|
for (let i = 1; i <= 4; i++) p[i] = [HI, HI - GAP * i];
|
|
p[5] = [HI, LO];
|
|
for (let i = 6; i <= 9; i++) p[i] = [HI - GAP * (i - 5), LO];
|
|
p[10] = [LO, LO];
|
|
for (let i = 11; i <= 14; i++) p[i] = [LO, LO + GAP * (i - 10)];
|
|
p[15] = [LO, HI];
|
|
for (let i = 16; i <= 19; i++) p[i] = [LO + GAP * (i - 15), HI];
|
|
const lerp = (a: [number, number], b: [number, number], t: number): [number, number] => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
[20, 21, 22, 23, 24].forEach((n, k) => (p[n] = lerp(p[5]!, p[15]!, (k + 1) / 6)));
|
|
[25, 26].forEach((n, k) => (p[n] = lerp(p[10]!, p[0]!, (k + 1) / 6)));
|
|
[27, 28].forEach((n, k) => (p[n] = lerp(p[10]!, p[0]!, (k + 4) / 6)));
|
|
return p;
|
|
})();
|
|
const LINES: [number, number][] = [
|
|
...Array.from({ length: 20 }, (_, i) => [i, (i + 1) % 20] as [number, number]),
|
|
[5, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 15],
|
|
[10, 25], [25, 26], [26, 22], [22, 27], [27, 28], [28, 0],
|
|
];
|
|
const BIG = new Set([0, 5, 10, 15, 22]);
|
|
|
|
function Board({ children, path }: { children?: ReactNode; path?: number[] }) {
|
|
return (
|
|
<svg viewBox="0 0 100 100" width={160} height={160} aria-hidden style={{ background: '#e9c98f', borderRadius: 12 }}>
|
|
{LINES.map(([a, b]) => (
|
|
<line key={`${a}-${b}`} x1={POS[a]![0]} y1={POS[a]![1]} x2={POS[b]![0]} y2={POS[b]![1]} stroke="#8a6232" strokeWidth={0.9} opacity={0.7} />
|
|
))}
|
|
{path && <polyline points={path.map((n) => POS[n]!.join(',')).join(' ')} fill="none" stroke="#2563eb" strokeWidth={2.4} strokeDasharray="3 2" />}
|
|
{POS.map(([x, y], n) => (
|
|
<circle key={n} cx={x} cy={y} r={BIG.has(n) ? 6 : 4.2} fill="#fffdf8" stroke="#8a6232" strokeWidth={0.7} />
|
|
))}
|
|
{children}
|
|
</svg>
|
|
);
|
|
}
|
|
|
|
const Red = ({ n, dx = 0, dy = 0 }: { n: number; dx?: number; dy?: number }) => (
|
|
<circle cx={POS[n]![0] + dx} cy={POS[n]![1] + dy} r={4.6} fill="#dc2626" stroke="#fff" strokeWidth={0.8} />
|
|
);
|
|
const Blue = ({ n }: { n: number }) => {
|
|
const [x, y] = POS[n]!;
|
|
return <polygon points={`${x},${y - 5} ${x + 5},${y + 3.6} ${x - 5},${y + 3.6}`} fill="#2563eb" stroke="#fff" strokeWidth={0.8} />;
|
|
};
|
|
const Label = ({ n, text, dy = -9 }: { n: number; text: string; dy?: number }) => (
|
|
<text x={POS[n]![0]} y={POS[n]![1] + dy} textAnchor="middle" fontSize={7} fontWeight={900} fill="#b91c1c" stroke="#fff" strokeWidth={0.6} paintOrder="stroke">
|
|
{text}
|
|
</text>
|
|
);
|
|
|
|
export const quickStart: QuickCard[] = [
|
|
{
|
|
pic: <SticksPic />,
|
|
alt: '윷가락 네 개: 세 개가 배면 걸 3칸, 네 개 모두 배면 윷 4칸과 한 번 더',
|
|
title: '윷 던지고 말 옮겨요',
|
|
text: '도 1칸, 개 2칸, 걸 3칸, 윷 4칸, 모 5칸. 윷·모가 나오면 한 번 더 던지고, 나온 결과로 말을 움직여요.',
|
|
},
|
|
{
|
|
pic: (
|
|
<Board>
|
|
<Blue n={3} />
|
|
<Red n={3} dx={1.5} dy={-1.5} />
|
|
<Label n={3} text="잡기!" />
|
|
<Red n={8} dx={-1.2} dy={1.2} />
|
|
<Red n={8} dx={1.2} dy={-1.2} />
|
|
<Label n={8} text="업기" dy={10} />
|
|
</Board>
|
|
),
|
|
alt: '빨간 말이 파란 말을 잡고, 다른 빨간 말 두 개는 업혀 있는 윷판',
|
|
title: '잡기와 업기',
|
|
text: '상대 말이 있는 자리에 멈추면 잡아서 처음으로 보내고 한 번 더 던져요. 내 말 자리에 멈추면 업혀서 같이 가요.',
|
|
},
|
|
{
|
|
pic: (
|
|
<Board path={[5, 20, 21, 22, 27, 28, 0]}>
|
|
<Red n={5} />
|
|
<Label n={22} text="방" dy={-7} />
|
|
</Board>
|
|
),
|
|
alt: '오른쪽 위 모서리에서 가운데 방을 지나 출발점으로 가는 지름길',
|
|
title: '지름길로 빨리 나가요',
|
|
text: '모서리나 가운데 방에 멈췄다가 출발하면 안쪽 지름길로 가요. 내 말을 모두 먼저 판 밖으로 내보내면 이겨요.',
|
|
},
|
|
];
|