import * as e from './extract.mjs'; import * as s from './stages.mjs'; import {table_bindings} from './rounds.mjs'; export const TYPES = ['GridFightProjectionConfigRow', 'GridFightSpotLightConfigRow', 'GridFightBinaryDiffAddRuleConfigRow', 'RewardRow']; function rewardTable(ctx, asset) { const [raw, proof] = ctx.assets.get(asset), cur = new e.Cursor(raw); const count = cur.length(1000000), type = 'RPG.GameCore.RewardRow'; const rows = Array.from({length: count}, () => ctx.codec.record(cur, type)); const encoded = e.cat(e.encode_varint(count * 2), rows.map(r => ctx.codec.encode_record(r, type))); if (cur.at !== raw.length || !encoded.equals(raw)) e.fail('Reward table round-trip failed'); return [rows, {table: 'RewardRow', records: count, round_trip: true, ...proof}]; } export function main() { const a = e.cli(['client', 'dump', 'identity', 'literals', 'output']); const ctx = s.extractionContext(a); const literals = new Map(e.loadJSON(a.literals).map(r => [Number(BigInt(r.Address)), r.Value])); const tables = {}, proofs = []; for (const name of TYPES) { const assets = table_bindings(ctx.codec, literals, 'RPG.GameCore.' + name, name === 'RewardRow' ? new Set(['RewardData', 'RewardDataLD']) : null); tables[name] = []; for (const asset of assets) { const match = asset.match(/^BakedConfig\/ExcelOutput(GameCore)?\/(\w+)\.bytes$/); if (!match) e.fail('Unsupported table path: ' + asset); const [rows, proof] = name === 'RewardRow' ? rewardTable(ctx, asset) : s.table(ctx.assets, ctx.codec, name, match[1] ?? '', match[2]); tables[name].push(...(name === 'RewardRow' ? rows.filter(r => r.RewardID >= 312901 && r.RewardID <= 312912) : rows)); proofs.push(proof); console.log(`${name}: ${rows.length} byte-exact rows (${tables[name].length} retained)`); } } if (tables.RewardRow.length !== 12) e.fail("Expected all twelve weekly reward definitions"); s.publish(a, ctx, tables, proofs, {'mechanics.json': tables}, 'mechanics', {gameplay_verified: false}); } e.runMain(import.meta.url, main);