2025-10-23 21:22:21 -05:00
|
|
|
import { toUniqueId } from "@blitzkit/core";
|
|
|
|
|
import { readdir } from "fs/promises";
|
|
|
|
|
import { readXMLDVPL } from "../core/blitz/readXMLDVPL";
|
|
|
|
|
import { AssetUploader } from "../core/github/assetUploader";
|
|
|
|
|
import { DATA } from "./constants";
|
|
|
|
|
import { VehicleDefinitionList } from "./definitions";
|
2025-04-06 22:57:35 -05:00
|
|
|
|
|
|
|
|
export async function migration() {
|
2025-10-23 21:22:21 -05:00
|
|
|
console.log("Building migration map...");
|
2025-04-06 22:57:35 -05:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
using uploader = new AssetUploader("migration map");
|
2025-04-06 22:57:35 -05:00
|
|
|
const map: Record<string, number> = {};
|
|
|
|
|
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
|
2025-10-23 21:22:21 -05:00
|
|
|
(nations) => nations.filter((nation) => nation !== "common")
|
2025-04-06 22:57:35 -05:00
|
|
|
);
|
|
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
for (const nation of nations) {
|
|
|
|
|
const tankList = await readXMLDVPL<{ root: VehicleDefinitionList }>(
|
|
|
|
|
`${DATA}/XML/item_defs/vehicles/${nation}/list.xml`
|
|
|
|
|
);
|
2025-04-06 22:57:35 -05:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
for (const tankKey in tankList.root) {
|
|
|
|
|
const tank = tankList.root[tankKey];
|
|
|
|
|
const tankId = toUniqueId(nation, tank.id);
|
|
|
|
|
const davaKey = `${nation}:${tankKey}`;
|
2025-04-06 22:57:35 -05:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
map[davaKey] = tankId;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-06 22:57:35 -05:00
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
await uploader.add({
|
|
|
|
|
path: "definitions/migration.json",
|
|
|
|
|
content: new TextEncoder().encode(JSON.stringify(map)),
|
|
|
|
|
});
|
|
|
|
|
await uploader.flush();
|
2025-04-06 22:57:35 -05:00
|
|
|
}
|