Normalize late campaign supply rewards

This commit is contained in:
2026-06-27 02:49:39 +09:00
parent be3ed036cb
commit d10cd6319d
2 changed files with 32 additions and 7 deletions

View File

@@ -1,7 +1,30 @@
import { spawn } from 'node:child_process';
import { readFileSync } from 'node:fs';
import { chromium } from 'playwright';
const targetUrl = process.env.VERIFY_URL ?? 'http://localhost:5173/';
const rewardDataFiles = ['src/game/data/battles.ts', 'src/game/scenes/CampScene.ts'];
function assertNoLegacyNumericRewardLabels() {
const legacyNumericRewardPattern = /itemRewards:\s*\[[^\]\r\n]*(["'])(쌀|금|군주)\s+\d+\1/u;
const failures = [];
for (const file of rewardDataFiles) {
const source = readFileSync(file, 'utf8');
const lines = source.split(/\r?\n/);
lines.forEach((line, index) => {
const match = legacyNumericRewardPattern.exec(line);
if (match) {
failures.push(`${file}:${index + 1} ${match[2]}`);
}
});
}
if (failures.length > 0) {
throw new Error(`Legacy numeric reward labels should use inventory names 콩/상처약/탁주: ${failures.join(', ')}`);
}
}
function unitUsesTexture(state, unitId, textureBase) {
return state?.units?.some((unit) => unit.id === unitId && unit.textureBase === textureBase && unit.actionTexture === `${textureBase}-actions`);
@@ -11,6 +34,8 @@ let serverProcess;
let browser;
try {
assertNoLegacyNumericRewardLabels();
serverProcess = await ensureLocalServer(targetUrl);
browser = await chromium.launch({ headless: true });