import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import { fixpoint } from './trait_effects.mjs'; const read = name => JSON.parse(fs.readFileSync(new URL('../../resources/grid_fight/' + name, import.meta.url))); const raw = read('wiki-4654.raw.json'); const rules = read('wiki-4654.json'); const equipment = read('equipment.json'); test('CW WIKI runtime rule parameters retain the fresh native table values and season', () => { for (const [key, type] of [ ['permanent', 'GridFightTalentConfigRow'], ['season', 'GridFightSeasonTalentConfigRow'], ['portals', 'GridFightPortalBuffConfigRow'], ['augments', 'GridFightAugmentConfigRow'], ]) { assert.equal(rules[key].length, raw[type].length); for (const row of rules[key]) { const native = raw[type].find(r => r.ID === row.id); assert.ok(native); assert.equal(row.season, native.SeasonID ?? 0); assert.equal(row.oc, !!native.IsOCEffective); assert.deepEqual(row.params, native.EffectParamList.map(p => fixpoint(p.wire))); } } }); test('CW WIKI all 57 S2 crafting recipes preserve the exact ingredient multiset and output', () => { const ids = new Set(raw.GridFightSeasonCraftConfigRow.filter(r => r.SeasonID === 2).map(r => r.CraftID)); assert.equal(ids.size, 57); for (const native of raw.GridFightCraftConfigRow.filter(r => ids.has(r.CraftID))) { const recipe = equipment.recipes.find(r => r.craft_id === native.CraftID); assert.ok(recipe, 'missing recipe ' + native.CraftID); assert.equal(recipe.result, native.CraftEquipID); assert.deepEqual([...recipe.cost].sort((a, b) => a - b), [...native.CostEquipList].sort((a, b) => a - b)); } }); test('CW WIKI S2 changed the S1 insurance, compensation, streak and talent layout', () => { const params = id => rules.season.find(r => r.id === id).params.map(p => Math.round(p * 1e6) / 1e6); assert.deepEqual(params(4011), [1, 0.1, 0.1]); assert.deepEqual(params(3061), [50, 5, 1]); assert.deepEqual(params(4061), [0.1, 6, 4]); assert.equal(rules.permanent.length, 13); assert.equal(rules.season.length, 40); assert.ok(rules.season.every(r => r.season === 2)); }); test('CW WIKI provenance ties every decoded table to complete 4.6.54 asset bytes', () => { const proof = read('wiki-4654-provenance.json'); assert.equal(proof.game_assembly_sha256, '4aa08a0706f27d2cf9951b61920c179140ece9ea94f7e34422c18e46922939b6'); assert.equal(proof.dump_sha256, 'f46de09bd1f14dca6fc0ba07b819e2328f3c4910dc833d33bf48f10e9b7402bd'); for (const p of proof.tables) { assert.equal(p.round_trip, true, p.table); assert.equal(raw[p.table].length, p.records); assert.match(p.asset_sha256, /^[a-f0-9]{64}$/); } });