fix(campaign): register c50 with the fields the app actually reads
Opening the c50 edition threw `campaign.legacyStorageKeys is not iterable` and left the board blank — the header still drew, so the level set looked loaded. Every other edition carries the array; the hand-written c50 entry did not, and 197 passing tests had nothing to say about it, because nothing tested the registration itself. The test now walks every edition and asserts the shape app.js relies on, including that the chapter list can actually hold the levels. It fails on the entry as it shipped. The task board was reading levels/prototypes/d5.json while the campaign sat in levels/campaign-50.json, so it showed "候选关卡 18 / 50" with fifty levels built. It reads the shipping set when there is one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,10 @@ const f2 = x => x == null || Number.isNaN(x) ? '—' : (Math.round(x * 100) / 10
|
||||
const mean = a => a.length ? a.reduce((x, y) => x + y, 0) / a.length : null;
|
||||
|
||||
// ---------- live measurement ----------
|
||||
const SET = resolve('levels/prototypes/d5.json');
|
||||
// The shipping set once it exists, the prototype output before that. Reading
|
||||
// the prototype after the campaign was assembled showed the tile as "18 / 50"
|
||||
// while fifty levels were sitting in levels/campaign-50.json.
|
||||
const SET = [resolve('levels/campaign-50.json'), resolve('levels/prototypes/d5.json')].find(existsSync);
|
||||
let pool = { n: 0, rot: {}, apt: null, families: {}, blind: null, wrong: null, endgame: {} };
|
||||
if (existsSync(SET)) {
|
||||
const raw = JSON.parse(readFileSync(SET, 'utf8'));
|
||||
@@ -29,7 +32,7 @@ if (existsSync(SET)) {
|
||||
for (const l of levels) {
|
||||
const r = l.prototype?.stats?.rotations ?? solveRotations(l).rotations;
|
||||
pool.rot[r] = (pool.rot[r] || 0) + 1;
|
||||
const fam = l.id.replace('proto-d5-', '').replace(/-r\d+-s\d+$/, '');
|
||||
const fam = l.campaign?.family ?? l.id.replace('proto-d5-', '').replace(/-r\d+-s\d+$/, '');
|
||||
pool.families[fam] = (pool.families[fam] || 0) + 1;
|
||||
const a = l.prototype?.audit ?? deadTurnAudit(l);
|
||||
pool.endgame[a.endgameMinOpen] = (pool.endgame[a.endgameMinOpen] || 0) + 1;
|
||||
|
||||
Reference in New Issue
Block a user