import * as s from './stages.mjs'; import { Reader, zigzag, fixpoint, rounded } from './trait_effects.mjs'; const e=s.primitive; export const TYPES={ 0:'item', 1:'refresh', 3:'maze_buff', 4:'stat', 5:'role', 6:'power' }; export function decode(raw){ const r=new Reader(raw), rows=[], count=Math.floor(Number(r.var())/2); for(let i=0; ir.var()); if(mask&8n)row.JsonPath=r.text(); if(mask&16n)row.EffectParamList=Array.from({ length:Math.floor(Number(r.var())/2) }, ()=>rounded(fixpoint(r.var()))); if(mask&32n)row.Cost=r.var(); if(mask&64n)row.Icon=r.text(); if(mask&128n)row.Desc=r.text(); for(const [bit, key]of [[256n, 'TrailGoodTitle'], [512n, 'TrailGoodDesc'], [1024n, 'TrailGoodSimpleDesc']])if(mask&bit)row[key]={ hash:r.var(), hash64:r.var() }; if(mask&2048n)row.FatherGoodID=r.var(); if(mask>>12n)e.fail('GridFightTrailblazeGoods: unknown fields'); rows.push(row); } r.done('GridFightTrailblazeGoods'); return rows; } export function goods(rows){ const out=[], ids=new Set(); for(const r of rows){ const gid=r.ID; if(gid===undefined)e.fail('Missing goods ID'); if(ids.has(gid))e.fail('duplicate Trailblaze goods '+gid); ids.add(gid); const kind=TYPES[r.Type??0]; if(kind===undefined)e.fail('unknown Trailblaze goods type '+r.Type+' for '+gid); const params=(r.ParamList??[]).map(Number); if(['maze_buff', 'item', 'power'].includes(kind)&¶ms.length!==1)e.fail(`goods ${gid}: ${kind} needs one parameter`); if(['stat', 'role'].includes(kind)&¶ms.length!==2)e.fail(`goods ${gid}: ${kind} needs two parameters`); out.push({ id:gid, kind, cost:r.Cost??0, father:r.FatherGoodID??0, params }); } for(const g of out)if(g.father&&!ids.has(g.father))e.fail(`goods ${g.id}: missing father ${g.father}`); return out; } export function main(){ const a=e.cli(['client'], { output:e.resource('trailblaze.json') }), [raw, proof]=new s.Assets(a.client).get('BakedConfig/ExcelOutput/GridFightTrailblazeGoods.bytes'), out={ goods:goods(decode(raw)), provenance:proof }; e.atomic_json(a.output, out, 1, true); console.log(`${a.output}: ${out.goods.length} goods`); } e.runMain(import.meta.url, main);