새 게임 버건디의 성: 주사위 두 개로 육각 타일을 가져와 1번 공국을 채우는 2~4명 개인전 + 혼자 하기(2019년판 규칙), 시작 성 고르기·2011 수도원·추가 타일·여관·방패를 방 설정으로

- 데이터 packages/games/src/castles-of-burgundy/data.ts: 1번 공국 37칸(구역 13개 계산), 인원별 보급소 칸 색(3인 6번 보급소 B·D 광산), 타일 164장 + 추가 4장 + 여관 5장, 수도원 26+2종, 방패 18종, 점수표. 확인 안 된 데이터(가축 분포·검은 뒷면 수도원·장인 번호·2/3인 칸)는 UNCONFIRMED 주석으로 한 곳에
- 엔진(engine·moves·index): 페이즈 5 × 라운드 5, 일꾼 눈 바꾸기(6↔1, 수도원 8·9~12·방패 16), 가져오기·놓기·팔기·일꾼, 구역 완성·색 보너스·가축·건물 8종·배·성 연쇄를 pending 스택으로, 검은 보급소 구매(수도원 6번 2019/2011), 페이즈 끝 광산·방패 유지비·방패 14/15, 게임 끝 점수와 동점(빈칸 많은 사람 → 차례 트랙 뒤), 혼자 하기(강으로만 넓히기·목표 표시기·상품 5장 바꾸기·색 완성 보상), 시간 초과 자동 진행·자리 비움·기권
- 합법성은 actionError 하나, 합법 수는 후보를 그것으로 거름. view는 더미·다음 페이즈 상품·남의 판 상품 종류를 숨김
- 컴퓨터(bot.ts): 뷰를 상태로 되돌려 자기 차례를 미리 두고 주사위 A → B 묶음을 평가(1~20 한 수+잡음, 21~40 상위 3개, 41~60 상위 6개), 묶음은 차례 끝까지 기억. 한 수 평균 2~18ms
- 화면 apps/web/src/games/castles-of-burgundy/: PC는 가운데 판(보급소 1~6·검은 보급소·여관·남은 상품·색 보너스) + 내 공국 SVG + 오른쪽에 다른 사람 요약·작은 공국, 휴대폰은 [내 공국]/[보급소]/[다른 사람] 탭 + 아래 고정 주사위 줄. 주사위를 고르면 가져올 타일·놓을 칸·팔 상품이 빛나고 "일꾼 n" 배지, 버릴 칸·확인·내는 방법 시트, 성 보너스·배·건물·방패 등 대기 효과는 배너와 버튼. 소리·배너(구역 완성·색 완성·페이즈), 도움말·30초 요약·타일 효과 표
- 등록: GAMES·BOT_STRATEGIES·BOT_GAMES·CATALOG·GAME_UI·GAME_ICON·판·주사위 탭, docs/games/README.md, docs/games/castles-of-burgundy.md(§2 나중에 표시, §13 구현 결정)
- 나중에(데이터 필요): 팀전, 공국 2~10번(duchy), 흰 성, 무역로, 국경 초소
- 테스트: 규칙 48개(문서 §10), 무작위 대국 4가지 옵션(타일·상품 수 보존, JSON 왕복, 결정성) + 깊게 두기, 컴퓨터 3개(1단계 < 60단계), 방 통합 1개(연습 + 시간 넘김), e2e games.e2e.ts castles-of-burgundy(PC + 휴대폰 실제 행동 70번, 320px 넘침 없음, 기권으로 결과)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-10-16 00:06:00 +09:00
parent 8620c82ca8
commit c9f4b782e8
25 changed files with 5221 additions and 8 deletions

View File

@@ -0,0 +1,59 @@
/** 버건디의 성 [?] "지금 할 수 있는 것" (docs/07 §5). Pure: only reads the client view. */
import type { CobView } from '@bg/games/castles-of-burgundy';
import type { PublicUser } from '@bg/shared/lite';
const PHASE = ['A', 'B', 'C', 'D', 'E'];
export function helpNow(v: CobView, me: string | null, players: Record<string, PublicUser>): string {
const name = (id: string) => `${players[id]?.nickname ?? '다른 사람'}님`;
const pv = me ? v.players[me] : undefined;
const where = `페이즈 ${PHASE[v.phase] ?? 'E'}, 라운드 ${Math.min(5, v.round + 1)}/5`;
if (v.stage === 'finished') {
if (v.solo) return v.endReason === 'soloWin' ? '성공했어요! 공국 37칸을 모두 채웠어요.' : '게임이 끝났어요. 25라운드 안에 공국을 다 채우지 못했어요.';
const rows = [...(v.final ?? [])].sort((a, b) => b.total - a.total);
const top = rows[0];
const mine = me ? rows.find((r) => r.player === me) : undefined;
return [`게임이 끝났어요.${top ? ` 1위는 ${name(top.player)}(${top.total}점)이에요.` : ''}`, mine ? `내 점수는 ${mine.total}점이에요(빈칸 ${mine.emptySpaces}칸).` : '', '같은 점수면 공국 빈칸이 더 많은 사람이 이겨요.']
.filter(Boolean)
.join('\n');
}
const waiting = v.waiting[0];
if (!pv || pv.conceded) {
const head = pv?.conceded ? '기권해서 구경하는 중이에요. ' : '';
return `${head}${where}. ${waiting ? `${name(waiting)} 차례예요.` : '잠시만 기다려 주세요.'}\n공국을 누르면 크게 볼 수 있어요.`;
}
const status = `내 점수 ${pv.vp}점 · 일꾼 ${pv.workers}개 · 은화 ${pv.silver}개 · 보관 칸 ${pv.storage.length}/3.`;
if (v.stage === 'castle') {
return v.my ? '시작 성을 놓을 성(진초록) 칸을 눌러 주세요. 첫 타일은 그 성 옆에 놓게 돼요.' : `${waiting ? name(waiting) : '다른 사람'}이 시작 성 칸을 고르는 중이에요.`;
}
if (!v.my) {
return [`${where}. ${waiting ? `${name(waiting)} 차례예요.` : ''} 기다리는 동안 다음 차례를 계획해 보세요.`, `내 주사위: ${pv.dice.join('·')} (모든 눈이 모두에게 보여요).`, status].join('\n');
}
const top = v.pending[v.pending.length - 1];
if (top) {
const tips: Record<string, string> = {
bonus: '성 보너스예요. 주사위 하나를 원하는 눈으로 쓴 것처럼 가져오기·놓기·팔기·일꾼 받기 중 하나를 해요(일꾼 필요 없음).',
ship: '배를 놓았어요. 상품을 모두 가져올 보급소를 골라 주세요. 상품 칸은 3종류까지예요. 차례 트랙에서 한 칸 앞으로 가요.',
depotTake: '건물 효과로 번호 보급소에서 정해진 색 타일 1장을 공짜로 가져와요. 빛나는 타일을 누르거나 건너뛰어요.',
warehouse: '창고: 가진 상품 한 종류를 주사위 없이 팔아요.',
townhall: '시청: 보관 칸 타일 1장을 숫자와 상관없이 놓아요(색과 맞닿음은 지켜요).',
crane: '기중기: 아무 건물 효과 하나를 골라요.',
geese: '거위: 같은 목초지의 가축 한 종류를 골라 그 점수를 더 받아요.',
shieldCopy: '방패 6번: 수도원 효과를 함께 쓸 사람을 골라요.',
upkeep: '페이즈 끝 방패 유지비: 남길 방패 1개당 은화 1개예요.',
phasePlace: '방패 효과: 타일 1장을 골라 공국에 바로 놓아요(숫자 조건 없음).',
soloTrade: '상품 5장을 내고 검은 보급소 타일 1장을 뒷면으로 받을 수 있어요. 뒷면 타일은 아무 색 칸에나 놓아요.',
soloBlack: '색을 모두 채운 보상: 검은 보급소 타일 1장을 공국에 바로 놓아요.',
};
return [tips[top.kind] ?? '위의 안내에 따라 골라 주세요.', status].join('\n');
}
const left = [pv.used[0] ? null : pv.dice[0], pv.used[1] ? null : pv.dice[1]].filter((x) => x !== null);
const lines = [`내 차례예요(${where}). 남은 주사위: ${left.length ? left.join('·') : '없음'}.`];
if (left.length) {
lines.push('주사위를 누르면 할 수 있는 일이 빛나요: 같은 번호 보급소에서 가져오기, 같은 색·숫자 칸에 놓기, 같은 번호 상품 팔기, 일꾼 2개 받기.');
lines.push('일꾼 1개로 눈을 ±1 바꿀 수 있어요(6과 1은 이어져요). 빛나는 칸의 "일꾼 n"이 드는 일꾼 수예요.');
} else lines.push('주사위를 다 썼어요. 살 것이 있으면 [🛒 구매], 아니면 [차례 끝]을 눌러요.');
if (!pv.bought && pv.silver >= 2) lines.push('은화 2개로 검은 보급소 타일 1장을 살 수 있어요(차례당 1장).');
lines.push(status);
return lines.join('\n');
}

View File

@@ -0,0 +1,158 @@
/** 버건디의 성 drawing helpers: own hex tile art (colour + symbol, no original artwork). */
import { ANIMAL_ICON, ANIMAL_KO, BUILDING_KO, COLOR_ICON, COLOR_KO, GOODS_KO, MONASTERIES, TILES, type Color, type Die } from '@bg/games/castles-of-burgundy/data';
export const FILL: Record<Color | 'inn' | 'any', string> = {
castle: '#2f6b3a',
mine: '#7c828c',
monastery: '#e2b93b',
building: '#d6b383',
livestock: '#8cc152',
ship: '#3f86d1',
inn: '#b45309',
any: '#4b5563',
};
export const SPACE: Record<Color, string> = {
castle: '#9cc7a3',
mine: '#c9ccd1',
monastery: '#f4e2a6',
building: '#efdfc6',
livestock: '#cfe8b4',
ship: '#b7d3f1',
};
export const INK: Record<Color | 'inn' | 'any', string> = {
castle: '#ffffff',
mine: '#ffffff',
monastery: '#3b2a00',
building: '#3b2a00',
livestock: '#1f3a0a',
ship: '#ffffff',
inn: '#ffffff',
any: '#ffffff',
};
export const GOODS_FILL: Record<Die, string> = { 1: '#7c3aed', 2: '#ca8a04', 3: '#db2777', 4: '#0891b2', 5: '#ea580c', 6: '#65a30d' };
const SQ3 = Math.sqrt(3);
export function hexPoints(cx: number, cy: number, r: number): string {
const pts: string[] = [];
for (let k = 0; k < 6; k++) {
const a = (Math.PI / 180) * (60 * k - 90);
pts.push(`${(cx + r * Math.cos(a)).toFixed(2)},${(cy + r * Math.sin(a)).toFixed(2)}`);
}
return pts.join(' ');
}
/** Axial (q, r) → pixel centre for pointy-top hexes of radius `size`. */
export const axial = (q: number, r: number, size: number): [number, number] => [size * SQ3 * (q + r / 2), size * 1.5 * r];
export const HEX_W = (size: number) => size * SQ3;
export function tileColor(id: string, facedown = false): Color | 'inn' | 'any' {
if (facedown) return 'any';
return TILES[id]?.color ?? 'any';
}
/** Short text inside a tile. */
export function tileShort(id: string, facedown = false): { icon: string; text: string } {
if (facedown) return { icon: '■', text: '뒷면' };
const t = TILES[id];
if (!t) return { icon: '?', text: '' };
if (t.color === 'inn') return { icon: '🛏', text: '여관' };
if (t.building) return { icon: '🏠', text: BUILDING_KO[t.building] };
if (t.animal) return { icon: ANIMAL_ICON[t.animal], text: `×${t.count}` };
if (t.monastery) return { icon: '📜', text: String(t.monastery) };
return { icon: COLOR_ICON[t.color as Color], text: '' };
}
/** Full Korean name of a tile ("시장(건물)", "양 3마리", "수도원 8 힘센 일꾼"). */
export function tileName(id: string, facedown = false): string {
if (facedown) return '뒷면 타일(아무 색)';
const t = TILES[id];
if (!t) return '타일';
if (t.color === 'inn') return '여관';
if (t.building) return `${BUILDING_KO[t.building]}(건물)`;
if (t.animal) return `${ANIMAL_KO[t.animal]} ${t.count}마리`;
if (t.monastery) return `수도원 ${t.monastery}번 ${monasteryName(t.monastery, t.craft)}`;
return COLOR_KO[t.color as Color];
}
export function monasteryName(n: number, craft?: string): string {
if (craft) return `${BUILDING_KO[craft as 'bank']} 장인`;
return MONASTERIES.find((m) => m.n === n)?.name ?? '';
}
export function monasteryText(n: number, craft?: string): string {
if (craft) return `게임 끝: 내 공국의 ${BUILDING_KO[craft as 'bank']} 1개당 4점`;
return MONASTERIES.find((m) => m.n === n)?.text ?? '';
}
export const goodsName = (d: Die) => `${d} ${GOODS_KO[d]}`;
/** One hex tile at (cx, cy). */
export function TileHex({ id, cx, cy, r, facedown, dim }: { id: string; cx: number; cy: number; r: number; facedown?: boolean; dim?: boolean }) {
const c = tileColor(id, facedown);
const { icon, text } = tileShort(id, facedown);
return (
<g opacity={dim ? 0.45 : 1}>
<polygon points={hexPoints(cx, cy, r)} fill={FILL[c]} stroke="rgba(0,0,0,.45)" strokeWidth={Math.max(1, r * 0.06)} />
<polygon points={hexPoints(cx, cy, r * 0.8)} fill="none" stroke="rgba(255,255,255,.35)" strokeWidth={Math.max(0.6, r * 0.04)} />
<text x={cx} y={text ? cy - r * 0.08 : cy + r * 0.12} textAnchor="middle" fontSize={r * (text ? 0.62 : 0.8)} dominantBaseline="middle">
{icon}
</text>
{text && (
<text x={cx} y={cy + r * 0.52} textAnchor="middle" fontSize={r * (text.length > 2 ? 0.34 : 0.42)} fontWeight={800} fill={INK[c]} dominantBaseline="middle">
{text}
</text>
)}
</g>
);
}
/** A die face with pips (for the dice bar and the duchy spaces). */
export function Pips({ n, cx, cy, s, color = '#1c1e21' }: { n: number; cx: number; cy: number; s: number; color?: string }) {
const o = s * 0.28;
const at: Record<number, [number, number][]> = {
1: [[0, 0]],
2: [
[-o, -o],
[o, o],
],
3: [
[-o, -o],
[0, 0],
[o, o],
],
4: [
[-o, -o],
[o, -o],
[-o, o],
[o, o],
],
5: [
[-o, -o],
[o, -o],
[0, 0],
[-o, o],
[o, o],
],
6: [
[-o, -o],
[o, -o],
[-o, 0],
[o, 0],
[-o, o],
[o, o],
],
};
return (
<g>
{(at[n] ?? []).map(([dx, dy], i) => (
<circle key={i} cx={cx + dx} cy={cy + dy} r={s * 0.09} fill={color} />
))}
</g>
);
}
export function DieFace({ n, size = 40, white, used, label }: { n: number; size?: number; white?: boolean; used?: boolean; label?: string }) {
return (
<svg width={size} height={size} viewBox="0 0 40 40" role="img" aria-label={label ?? `주사위 ${n}`} style={{ display: 'block', opacity: used ? 0.35 : 1 }}>
<rect x={2} y={2} width={36} height={36} rx={8} fill={white ? '#ffffff' : '#fde68a'} stroke="#1c1e21" strokeWidth={2} />
<Pips n={n} cx={20} cy={20} s={36} />
</svg>
);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
/** 버건디의 성 30초 규칙 요약 (docs/07 §5). */
import type { QuickCard } from '../types';
import { DieFace, FILL, SPACE, TileHex, hexPoints } from './hex';
export const quickStart: QuickCard[] = [
{
pic: (
<svg viewBox="0 0 250 120" width={250} height={120} aria-hidden>
<foreignObject x={10} y={36} width={44} height={44}>
<DieFace n={4} size={44} />
</foreignObject>
<text x={70} y={64} fontSize={22} fontWeight={900}>
=
</text>
<rect x={92} y={30} width={62} height={56} rx={8} fill="#efece4" stroke="#9ca3af" />
<text x={123} y={48} textAnchor="middle" fontSize={12} fontWeight={800}>
4번 보급소
</text>
<TileHex id="S-01" cx={123} cy={70} r={14} />
<text x={170} y={64} fontSize={22} fontWeight={900}>
=
</text>
<polygon points={hexPoints(215, 58, 24)} fill={SPACE.ship} stroke="#334155" strokeWidth={2} />
<text x={215} y={64} textAnchor="middle" fontSize={20} fontWeight={900}>
4
</text>
</svg>
),
alt: '주사위 4는 4번 보급소와 공국의 숫자 4 칸을 뜻해요',
title: '주사위 눈 = 번호',
text: '라운드마다 주사위 2개를 하나씩 써요. 눈과 같은 번호 보급소에서 타일을 가져오고, 같은 숫자 칸에 놓아요.',
},
{
pic: (
<svg viewBox="0 0 250 120" width={250} height={120} aria-hidden>
<polygon points={hexPoints(70, 60, 26)} fill={FILL.castle} stroke="#1f2937" strokeWidth={2} />
<text x={70} y={66} textAnchor="middle" fontSize={20}>
🏰
</text>
<TileHex id="B-market-1" cx={115} cy={34} r={25} />
<polygon points={hexPoints(115, 86, 25)} fill={SPACE.ship} stroke="#2563eb" strokeWidth={3} strokeDasharray="4 3" />
<text x={115} y={92} textAnchor="middle" fontSize={18} fontWeight={900}>
5
</text>
<text x={150} y={64} fontSize={13} fontWeight={800} fill="#15803d">
같은 색·숫자,
</text>
<text x={150} y={82} fontSize={13} fontWeight={800} fill="#15803d">
맞닿게 놓기
</text>
</svg>
),
alt: '성 옆에 시장 타일이 있고, 맞닿은 파란 5번 칸이 빛나요',
title: '공국에 맞닿게 놓기',
text: '보관 칸 타일을 같은 색·같은 숫자 빈칸에, 이미 놓인 타일과 맞닿게 놓아요. 색마다 효과가 달라요.',
},
{
pic: (
<svg viewBox="0 0 250 120" width={250} height={120} aria-hidden>
<TileHex id="M-01" cx={40} cy={50} r={24} />
<TileHex id="M-02" cx={82} cy={50} r={24} />
<TileHex id="M-03" cx={61} cy={86} r={24} />
<text x={115} y={58} fontSize={18} fontWeight={900} fill="#15803d">
구역 완성!
</text>
<text x={115} y={84} fontSize={14} fontWeight={800}>
3칸 6점 + A 페이즈 10점
</text>
</svg>
),
alt: '광산 3칸 구역을 다 채워 점수를 얻어요',
title: '구역을 채워 점수',
text: '같은 색 구역을 다 채우면 크기 점수와 페이즈 점수(이를수록 큼)를 받아요. 한 색을 전부 채우면 보너스!',
},
];

View File

@@ -9,7 +9,7 @@ import { assertCleanText, eachView, seatIds, usersOf } from './help-kit.test-uti
const IDS = Object.keys(GAME_UI);
test('모든 게임에 도움말이 있어요', () => {
expect(IDS).toHaveLength(34);
expect(IDS).toHaveLength(35);
for (const id of IDS) {
const src = readFileSync(join(import.meta.dir, id, 'index.tsx'), 'utf8');
expect(src, id).toMatch(/\bquickStart,/);

View File

@@ -36,6 +36,7 @@ export const GAME_UI: Record<string, () => Promise<{ default: GameUI }>> = {
liar: () => import('./liar'),
'magical-athlete': () => import('./magical-athlete'),
blackjack: () => import('./blackjack'),
'castles-of-burgundy': () => import('./castles-of-burgundy'),
};
const cache = new Map<string, GameUI>();

View File

@@ -33,6 +33,7 @@ export const GAME_ICON: Record<string, string> = {
liar: '🤥',
'magical-athlete': '🏃',
blackjack: '🂡',
'castles-of-burgundy': '🏰',
};
/** Shown on the home screen so users know what's coming (docs/12-roadmap.md). */
@@ -40,7 +41,7 @@ export const UPCOMING: string[] = [];
/** Tabs on the game picker (docs/07 §3.3). Games not listed here only show under 전체. */
export const GAME_GROUPS: { key: string; label: string; ids: string[] }[] = [
{ key: 'board', label: '판·주사위', ids: ['omok', 'connect-four', 'othello', 'chess', 'janggi', 'baduk', 'quoridor', 'yut', 'marble', 'yacht', 'las-vegas', 'magical-athlete', 'clue'] },
{ key: 'board', label: '판·주사위', ids: ['omok', 'connect-four', 'othello', 'chess', 'janggi', 'baduk', 'quoridor', 'yut', 'marble', 'yacht', 'las-vegas', 'magical-athlete', 'clue', 'castles-of-burgundy'] },
{ key: 'cards', label: '카드·패', ids: ['seotda', 'poker', 'blackjack', 'one-card', 'uno', 'gostop', 'dalmuti', 'splendor', 'cockroach-poker', 'ninety-nine', 'old-maid', 'mahjong', 'rummikub', 'davinci-code'] },
{ key: 'party', label: '여럿이 파티', ids: ['bang', 'halli-galli', 'dobble', 'catchmind', 'mafia', 'liar', 'apple'] },
];