feedback5 WE2: remove the kits/tier1-6.js re-export shims and shared/standIn.js diyRecord (#5)

Nothing but tests imported them: kits_t3 / kits_alt_t3 / kits_t4 / kits_t5 read
kits/index.js TIER_KITS, playtest5_elements / playtest6-combat / facing the real modules,
simServe checks /sim/content/kits/index.js; test/backups.test.js composes the prototypes
through shared/diy.js diyRecordOf at their locked selection. check:imports passes.
Docs: kits/README.md, DATA.md. Golden: no scenario moved.
This commit is contained in:
sganggs committed 2026-10-06 16:07:49 +08:00
1 parent 19691d0b06
commit 92a179e71e
18 files changed
+33 -81

No files matched your search

+14 -13
View File
@@ -12,7 +12,8 @@ import assert from 'node:assert/strict';
import { readFileSync, existsSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { standInRecord, diyRecord, composeUnitRecord, unitForm, statusKey, IDENTITY_FIELDS } from '../shared/standIn.js';
import { standInRecord, composeUnitRecord, unitForm, statusKey, IDENTITY_FIELDS } from '../shared/standIn.js';
import { diyRecordOf, lockedSelection } from '../shared/diy.js';
import { composeStats, composeTalents, resolveLoadout, loadoutRecord, normalizeChess } from '../server/sim/simdata.js';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
@@ -212,26 +213,26 @@ test('DIY: prototype picks — the 9 elites at tiers 5 and 6, six 4★ reserves
assert.deepEqual(prototypes['6'], ELITES);
assert.deepEqual(prototypes['5'], [...RESERVES.filter((id) => !['char_600_cpione', 'char_607_cspec'].includes(id)), ...ELITES]);
assert.equal(prototypes['5'].length, 15);
// every pick composes in every slot form, with any of its skills (which skill a prototype carries in a slot is an open
// question — the data supports any answer), with the derived bonds (协防干员: no prototype has a faction) and no 特质
// every pick composes in every slot form — at its locked selection (diy.locked: "技能携带规则与系统补位时一致"; shared/diy.js
// diyRecordOf, which replaced standIn.js's prototype-only diyRecord in 0.2.0) — with the derived bonds (协防干员: no
// prototype has a faction) and no 特质
const data = { chess, backups };
for (const [id, s] of Object.entries(backups.diy.slots)) {
for (const slot of [chess[id], chess[s.goldenId]]) {
for (const p of prototypes[s.tier]) {
const form = unitForm(backups, p, slot.status);
assert.ok(form, `${slot.chessId} ${p}: form`);
for (const sk of form.skills) {
const mod = slot.status.equipLevel > 0 ? form.modules[0]?.uniEquipId ?? null : null;
const r = diyRecord(slot, p, backups, { skillIndex: sk.index, moduleId: mod });
assert.ok(r && r.skill.index === sk.index && r.charId === p, `${slot.chessId} ${p} S${sk.index + 1}`);
assert.deepEqual([r.bonds, r.garrisonIds, r.price, r.tier], [['emptyShip'], [], 4, s.tier]);
if (mod) assert.equal(r.module.active, true, `${slot.chessId} ${p}: module`);
}
const lk = lockedSelection(data, s.tier, p);
const r = diyRecordOf(slot, { charId: p }, data);
assert.ok(r && r.skill.index === lk.skillIndex && r.charId === p, `${slot.chessId} ${p}`);
assert.deepEqual([r.bonds, r.garrisonIds, r.price, r.tier], [['emptyShip'], [], 4, s.tier]);
if (slot.status.equipLevel > 0 && lk.uniEquipId) assert.equal(r.module.active, true, `${slot.chessId} ${p}: module`);
}
}
}
assert.equal(diyRecord(chess.chess_char_6_diy1_a, 'char_601_cguard', backups, { skillIndex: 2 }), null, 'a reserve is not a tier-6 pick');
assert.equal(diyRecord(chess.chess_char_5_diy1_a, 'char_600_cpione', backups, { skillIndex: 2 }), null, '预备干员-先锋 is not a pick');
assert.equal(diyRecord(chess.chess_char_5_01_a, 'char_608_acpion', backups, { skillIndex: 2 }), null, 'not a DIY slot');
assert.equal(diyRecordOf(chess.chess_char_6_diy1_a, { charId: 'char_601_cguard' }, data), null, 'a reserve is not a tier-6 pick');
assert.equal(diyRecordOf(chess.chess_char_5_diy1_a, { charId: 'char_600_cpione' }, data), null, '预备干员-先锋 is not a pick');
assert.equal(diyRecordOf(chess.chess_char_5_01_a, { charId: 'char_608_acpion' }, data), null, 'not a DIY slot');
});
test('DIY: the 71 owned 6★ picks — a form at every slot status with all three skills, every module at stage 1 and 3, their summons', () => {
+3 -1
View File
@@ -9,7 +9,9 @@ import { skillSpecSource } from '../../server/sim/content/index.js';
import { effectiveProfile } from '../../server/sim/ai.js';
import { kitCoverage } from '../../tools/kit-coverage.mjs';
import { wolfShadows, wolfTacticalPoint } from '../../server/sim/content/tokens.js';
import KITS from '../../server/sim/content/kits/tier3.js';
import { TIER_KITS } from '../../server/sim/content/kits/index.js';
const KITS = TIER_KITS[2];
const ds = getDefaultSource();
/** Skill index of `skillId` on chess `id`. */
+3 -1
View File
@@ -5,9 +5,11 @@ import assert from 'node:assert/strict';
import { makeBattle, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
import { getDefaultSource } from '../../server/sim/simdata.js';
import { effectiveProfile } from '../../server/sim/ai.js';
import KITS from '../../server/sim/content/kits/tier3.js';
import { TIER_KITS } from '../../server/sim/content/kits/index.js';
import { COLS } from '../../server/sim/constants.js';
const KITS = TIER_KITS[2];
const ds = getDefaultSource();
const D = (id) => ds.getChess(id);
const BB = (id) => D(id).skill.bb;
+3 -1
View File
@@ -4,9 +4,11 @@ import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeBattle, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
import { getDefaultSource } from '../../server/sim/simdata.js';
import kits from '../../server/sim/content/kits/tier4.js';
import { TIER_KITS } from '../../server/sim/content/kits/index.js';
import { absoluteRangeKeys } from '../../server/sim/targeting.js';
const kits = TIER_KITS[3];
const ds = getDefaultSource();
const D = (id) => ds.getChess(id);
const approx = (a, b, eps = 1e-6, msg = '') => assert.ok(Math.abs(a - b) <= eps * Math.max(1, Math.abs(b)), `${msg} ${a} ≈ ${b}`);
+3 -1
View File
@@ -3,7 +3,9 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeBattle, enemyRec, chessRec, checkInvariants } from '../helpers/battleHarness.js';
import KITS from '../../server/sim/content/kits/tier5.js';
import { TIER_KITS } from '../../server/sim/content/kits/index.js';
const KITS = TIER_KITS[4];
const approx = (a, b, eps = 1e-6, msg = '') => assert.ok(Math.abs(a - b) <= eps * Math.max(1, Math.abs(b)), `${msg} ${a} ≉ ${b}`);
const dummy = (key = 'enemy_dummy', o = {}) => enemyRec({ key, hp: 1e7, speed: 0, ...o });
+1 -1
View File
@@ -14,7 +14,7 @@ import { test } from 'node:test';
import assert from 'node:assert/strict';
import { makeBattle, enemyRec, chessRec, checkInvariants } from '../helpers/battleHarness.js';
import { getDefaultSource } from '../../server/sim/simdata.js';
import { PITHST_ELEMENTS } from '../../server/sim/content/kits/tier6.js';
import { PITHST_ELEMENTS } from '../../server/sim/content/kits/ops/chess_char_1_15-pithst.js';
import { spawnYanyou } from '../../server/sim/content/tokens.js';
import { COLS } from '../../server/sim/constants.js';
+1 -1
View File
@@ -12,7 +12,7 @@ after(async () => { if (srv) await srv.close(); });
test('/sim/ serves the simulation modules read-only; nothing else of server/ is reachable', async () => {
srv = await startServer({ port: 0, host: '127.0.0.1', quiet: true });
const get = (p, headers = {}) => fetch(srv.url + p, { redirect: 'manual', headers });
for (const p of ['/sim/spec.js', '/sim/Battle.js', '/sim/simdata.js', '/sim/constants.js', '/sim/content/index.js', '/sim/content/kits/tier1.js', '/sim/content/support/index.js']) {
for (const p of ['/sim/spec.js', '/sim/Battle.js', '/sim/simdata.js', '/sim/constants.js', '/sim/content/index.js', '/sim/content/kits/index.js', '/sim/content/support/index.js']) {
const r = await get(p);
assert.equal(r.status, 200, p);
assert.match(r.headers.get('content-type'), /^text\/javascript/, p);
+1 -1
View File
@@ -12,7 +12,7 @@ import { COLS } from '../../server/sim/constants.js';
import { makeBattle, chessRec, enemyRec, checkInvariants } from '../helpers/battleHarness.js';
import { findSummonTile } from '../../server/sim/content/tokens.js';
import { frontTile, sideTiles, alliesAround, N4 } from '../../server/sim/content/support/index.js';
import { freeTileAround } from '../../server/sim/content/kits/tier1.js';
import { freeTileAround } from '../../server/sim/content/kits/shared/tier1.js';
import { DIRS as PROTOCOL_DIRS } from '../../shared/protocol.js';
const K = (r, c) => r * COLS + c;
+1 -1
View File
@@ -22,7 +22,7 @@ import { makeBattle, chessRec, enemyRec, checkInvariants } from '../helpers/batt
import { getDefaultSource, hasGeneratedData } from '../../server/sim/simdata.js';
import { effectiveProfile } from '../../server/sim/ai.js';
import { PUSH_TILES, PUSH_TILES_EFFECT, PULL_STOP_RADIUS, ASPD_MIN, COLS } from '../../server/sim/constants.js';
import { alliesInGridOf } from '../../server/sim/content/kits/tier1.js';
import { alliesInGridOf } from '../../server/sim/content/kits/shared/tier1.js';
import { Unit } from '../../server/sim/units.js';
import { spawnYanyou, TOKEN_IDS } from '../../server/sim/content/tokens.js';