- 후보 30개와 점수표·고른 까닭(docs/games/case-file-candidates.md), 사건 쓰는 법(case-file-writing-guide.md). 예스노 탐정·퀴즈 사립탐정·바다거북 수프에서 이상한 첫 장면, 퀴즈 한 방, 관점 바꾸기, 억지 금지(결정적 단서 두 겹)를 빌림 - 새 사건 c4~c13: 사진 속 그 문 앞 / 장날이 아닌 날 / 반짝이는 것만 사라진 집 (쉬움), 여름밤의 오리온 / 돌아온 두부 / 웬지 익숙한 시 / 건반 하나가 빠진 녹턴 (보통), 눈 그친 뒤의 발자국 / 틀린 답을 맞힌 우승자 / 시계방에서 사라진 7분 (어려움) - 사건마다 checks/<id>.ts(빠듯한 길·점검표)와 데이터에서 만든 설계 문서(case-file-cases/<id>.md, bun scripts/case-file-doc.ts). cases.test.ts가 새 사건 기준·빠듯한 길·문서 일치를 검사 - 정답 모르는 검토자 풀이(빠듯한 길만 / 전체)로 모순·다른 답·이른 노출을 찾아 고침 - CASE_IDS 13개, random은 13개 중 하나, 사건별 무작위 판 테스트, e2e에서 사건 고르기 상자 확인 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
5.1 KiB
TypeScript
104 lines
5.1 KiB
TypeScript
/**
|
||
* Renders a case's design doc (docs/games/case-file-cases/<id>.md) from its data plus its check file, so the doc and
|
||
* the data can never drift (cases.test.ts compares the file with this output; `bun scripts/case-file-doc.ts` rewrites it).
|
||
* Same section layout as the hand-written cases 1~3 in case-file-cases.md. Test/doc only: never imported by the game.
|
||
*/
|
||
import { CASE_LIST, type CaseData } from '../types';
|
||
|
||
/** Per-case check data (checks/<id>.ts): the doc number, the tight path tested by cases.test.ts and the timeline. */
|
||
export interface CaseCheck {
|
||
/** Section number in the docs ("사건 4"). */
|
||
n: number;
|
||
/** "빠듯한 길": leads read per day with 6 hours a day, no overtime, no magnifier, no hint. */
|
||
tight: string[][];
|
||
/** Markdown for "앞뒤 맞추기 점검표": timeline table + checks (no heading). */
|
||
timeline: string;
|
||
}
|
||
|
||
const NUM = ['①', '②', '③', '④', '⑤', '⑥', '⑦', '⑧', '⑨', '⑩'];
|
||
const short = (id: string) => id.replace(/^c\d+-/, '');
|
||
|
||
export function caseStats(c: CaseData) {
|
||
const max = c.questions.reduce((n, q) => n + q.points, 0);
|
||
const hours = c.leads.reduce((n, l) => n + l.hours, 0);
|
||
return { max, hours, leads: c.leads.length, questions: c.questions.length };
|
||
}
|
||
|
||
export function renderCaseDoc(c: CaseData, check: CaseCheck): string {
|
||
const n = check.n;
|
||
const s = caseStats(c);
|
||
const out: string[] = [];
|
||
const zoneName = (z: string) => c.zones.find((x) => x.id === z)?.name ?? z;
|
||
const placeName = (p: string) => c.places.find((x) => x.id === p)?.name ?? p;
|
||
const leadRef = (ids: string[]) => (ids.length === 0 ? '처음부터' : ids.map((x) => `\`${x}\``).join(' 또는 '));
|
||
|
||
out.push(`# 사건 ${n}. ${c.title} (\`${c.id}\`)`, '');
|
||
out.push(
|
||
'> 이 파일은 `bun scripts/case-file-doc.ts`가 사건 데이터(`packages/games/src/case-file/cases/' +
|
||
c.id +
|
||
'.ts`)와 점검 파일(`checks/' +
|
||
c.id +
|
||
'.ts`)로 만든다. 직접 고치지 말고 데이터를 고친 뒤 다시 만들 것. **스포일러 주의**: 정답이 있다.',
|
||
'',
|
||
);
|
||
out.push(
|
||
`> 난이도 ${c.level} · ${c.days}일 · 단서 ${s.leads}개(합계 ${s.hours}시간) · 문제 ${s.questions}개 · 만점 ${s.max}점 · 해결 기준 ${c.pass}점(범인 문제 정답 필수) · S ${c.gradeS}점 / A ${c.gradeA}점`,
|
||
'',
|
||
);
|
||
out.push(`한 줄 소개(방 설정에 보이는 글): ${CASE_LIST.find((x) => x.id === c.id)?.pitch ?? ''}`, '');
|
||
|
||
out.push(`## ${n}.1 의뢰 (briefing)`, c.briefing, '');
|
||
|
||
out.push(`## ${n}.2 구역·장소·이동`, '| 구역 | 장소(id) |', '|---|---|');
|
||
for (const z of c.zones) {
|
||
const ps = c.places.filter((p) => p.zone === z.id).map((p) => `${p.name} \`${p.id}\``);
|
||
out.push(`| ${z.name} \`${z.id}\` | ${ps.join(', ')} |`);
|
||
}
|
||
out.push('', `| 이동 시간 | ${c.zones.map((z) => z.name).join(' | ')} |`, `|---|${c.zones.map(() => '---').join('|')}|`);
|
||
for (const a of c.zones) out.push(`| ${a.name} | ${c.zones.map((b) => (a.id === b.id ? '–' : String(c.travel[a.id]?.[b.id]))).join(' | ')} |`);
|
||
out.push('');
|
||
|
||
out.push(`## ${n}.3 인물 (자료실 카드)`, '| id | 이름 | 한 줄 | 처음 알려 주는 단서 |', '|---|---|---|---|');
|
||
for (const p of c.people) out.push(`| \`${p.id}\` | ${p.name} | ${p.line} | ${p.from.length ? p.from.map((x) => `\`${x}\``).join(', ') : '의뢰'} |`);
|
||
out.push('');
|
||
|
||
out.push(`## ${n}.4 단서 목록`, '| id | 장소 | 제목 | 시간 | 열리는 조건 | 깊이 보기 |', '|---|---|---|---|---|---|');
|
||
for (const l of c.leads) {
|
||
const deep = l.deep ? (l.deepOpens?.length ? `🔍 → ${l.deepOpens.map((x) => `\`${x}\``).join(', ')}` : '🔍') : '';
|
||
out.push(`| \`${l.id}\` | ${placeName(l.place)} (${zoneName(c.places.find((p) => p.id === l.place)?.zone ?? '')}) | ${l.title} | ${l.hours} | ${leadRef(l.from)} | ${deep} |`);
|
||
}
|
||
out.push('');
|
||
|
||
out.push(`## ${n}.5 단서 본문`, '');
|
||
for (const l of c.leads) {
|
||
out.push(`### \`${l.id}\` ${l.title}`, l.text, '');
|
||
if (l.deep) out.push(`- **깊이 보기**: ${l.deep}`, '');
|
||
}
|
||
|
||
out.push(`## ${n}.6 아침 소식`);
|
||
if (c.news.length === 0) out.push('- 없음');
|
||
for (const x of c.news) out.push(`- ${x.day}일째 아침: ${x.text}`);
|
||
out.push('');
|
||
|
||
out.push(`## ${n}.7 조언 (쓸 때마다 −2점)`);
|
||
c.hints.forEach((h, i) => out.push(`${i + 1}. ${h}`));
|
||
out.push('');
|
||
|
||
out.push(`## ${n}.8 보고서 문제`, '| id | 문제 | 보기 | 정답 | 점수 | 근거 단서 |', '|---|---|---|---|---|---|');
|
||
for (const q of c.questions) {
|
||
out.push(
|
||
`| \`${q.id}\`${q.culprit ? ' (범인)' : ''} | ${q.text} | ${q.choices.map((x, i) => `${NUM[i]} ${x}`).join(' ')} | ${NUM[q.answer]} | ${q.points} | ${q.evidence.map(short).join(', ')} |`,
|
||
);
|
||
}
|
||
out.push('');
|
||
|
||
out.push(`## ${n}.9 정답과 풀이 (끝난 뒤 공개)`, c.solution, '');
|
||
|
||
out.push(`## ${n}.10 앞뒤 맞추기 점검표`, check.timeline.trim(), '');
|
||
out.push(
|
||
`- 빠듯한 길(하루 6시간, 야근·돋보기·조언 없이, \`cases.test.ts\`가 실제 엔진으로 따라감): ${check.tight.map((d, i) => `${i + 1}일 ${d.map(short).join('·')}`).join(' / ')}`,
|
||
'',
|
||
);
|
||
return out.join('\n');
|
||
}
|