Recompute unlocked ranks, prerequisites, and unit states before serving profiles. Add research target selection, research conversion, vehicle and slot purchases, and the price table. Support editing convertible RP and restrict hidden vehicle visibility to eligible entries. The client still displays zero purchase prices pending price table integration.
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
/**
|
|
* Datasets from char.vromfs.bin config/rank.blk.
|
|
*
|
|
* needBuyToOpenNextInEra{ <country>{ needBuyToOpenNextInEra<type><rank>: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<N>{ 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<Record<string, Readonly<Record<string, number>>>>;
|
|
|
|
export const eraRequirements: Dataset<EraRequirements> = {
|
|
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<CrewSlotPrices> = {
|
|
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);
|
|
},
|
|
};
|