/** * Datasets from char.vromfs.bin config/rank.blk. * * needBuyToOpenNextInEra{ { needBuyToOpenNextInEra:i=N } } * how many vehicles of a rank a country's branch must own before the next rank opens; the * stock scripts also look up the name without the type (gui.vromfs.bin * scripts/unit/unitInfo.nut getUnitsNeedBuyToOpenNextInEra). * * crew_slots{ slot{ cost:i costGold:i } } * the price of a country's next crew slot when it has N crews (aces.exe 2.61.0.37 * get_crew_slot_cost, 0x90eaa0). */ import { numberField } from './blk-fields.ts'; import type { Dataset } from './dataset.ts'; const RANK = 'config/rank.blk'; const SLOT = /^slot(\d+)$/; /** country -> parameter name -> vehicles needed, as written. */ export type EraRequirements = Readonly>>>; export const eraRequirements: Dataset = { id: 'era-requirements', version: 1, extract: (source) => { const block = source.readBlk('char.vromfs.bin', RANK).blocks.find((child) => child.name === 'needBuyToOpenNextInEra'); return Object.fromEntries((block?.blocks ?? []).map((country) => [ country.name, Object.fromEntries(country.params.flatMap((param) => (param.value.type === 'int' ? [[param.name, param.value.value]] : []))), ])); }, }; export interface CrewSlotPrice { readonly silverLions: number; readonly goldenEagles: number; } /** Indexed by the number of crews the country has; a missing index has no price (cannot be bought). */ export type CrewSlotPrices = readonly (CrewSlotPrice | null)[]; export const crewSlotPrices: Dataset = { id: 'crew-slot-prices', version: 1, extract: (source) => { const block = source.readBlk('char.vromfs.bin', RANK).blocks.find((child) => child.name === 'crew_slots'); const prices: (CrewSlotPrice | null)[] = []; for (const slot of block?.blocks ?? []) { const index = SLOT.exec(slot.name)?.[1]; if (index === undefined) continue; prices[Number(index)] = { silverLions: numberField(slot, 'cost') ?? 0, goldenEagles: numberField(slot, 'costGold') ?? 0 }; } return Array.from(prices, (price) => price ?? null); }, };