mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: equipment definitions
This commit is contained in:
1 parent
5adc69977b
commit
b053018958
2 files changed
+52
-18
No files matched your search
@@ -6,6 +6,11 @@ import { readXMLDVPL } from '../../src/core/blitz/readXMLDVPL';
|
|||||||
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
|
import { readYAMLDVPL } from '../../src/core/blitz/readYAMLDVPL';
|
||||||
import { toUniqueId } from '../../src/core/blitz/toUniqueId';
|
import { toUniqueId } from '../../src/core/blitz/toUniqueId';
|
||||||
import commitMultipleFiles from '../../src/core/blitzkrieg/commitMultipleFiles';
|
import commitMultipleFiles from '../../src/core/blitzkrieg/commitMultipleFiles';
|
||||||
|
import {
|
||||||
|
EquipmentDefinitions,
|
||||||
|
EquipmentRow,
|
||||||
|
EquipmentRows,
|
||||||
|
} from '../../src/core/blitzkrieg/equipmentDefinitions';
|
||||||
import {
|
import {
|
||||||
ModelArmor,
|
ModelArmor,
|
||||||
ModelDefinitions,
|
ModelDefinitions,
|
||||||
@@ -174,18 +179,7 @@ interface OptionalDeviceSlots {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface OptionalDeviceSlotRow {
|
interface OptionalDeviceSlotRow {
|
||||||
attack: {
|
[key: string]: { device0: string; device1: string };
|
||||||
device0: string;
|
|
||||||
device1: string;
|
|
||||||
};
|
|
||||||
defence: {
|
|
||||||
device0: string;
|
|
||||||
device1: string;
|
|
||||||
};
|
|
||||||
support: {
|
|
||||||
device0: string;
|
|
||||||
device1: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const blitzTankTypeToBlitzkrieg: Record<BlitzTankType, TankType> = {
|
const blitzTankTypeToBlitzkrieg: Record<BlitzTankType, TankType> = {
|
||||||
@@ -207,6 +201,10 @@ export async function buildDefinitions() {
|
|||||||
|
|
||||||
const tankDefinitions: TankDefinitions = {};
|
const tankDefinitions: TankDefinitions = {};
|
||||||
const modelDefinitions: ModelDefinitions = {};
|
const modelDefinitions: ModelDefinitions = {};
|
||||||
|
const equipmentDefinitions: EquipmentDefinitions = {
|
||||||
|
presets: {},
|
||||||
|
equipments: {},
|
||||||
|
};
|
||||||
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then(
|
const nations = await readdir(`${DATA}/${POI.vehicleDefinitions}`).then(
|
||||||
(nations) => nations.filter((nation) => nation !== 'common'),
|
(nations) => nations.filter((nation) => nation !== 'common'),
|
||||||
);
|
);
|
||||||
@@ -214,11 +212,11 @@ export async function buildDefinitions() {
|
|||||||
`${DATA}/${POI.strings}/${LANGUAGE}.yaml.dvpl`,
|
`${DATA}/${POI.strings}/${LANGUAGE}.yaml.dvpl`,
|
||||||
);
|
);
|
||||||
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
|
const optionalDevices = await readXMLDVPL<{ root: OptionalDevices }>(
|
||||||
`${DATA}/${POI.optionalDevices}`,
|
`${DATA}/${POI.optionalDevices}.dvpl`,
|
||||||
);
|
);
|
||||||
const optionalDeviceSlots = await readXMLDVPL<{
|
const optionalDeviceSlots = await readXMLDVPL<{
|
||||||
root: OptionalDeviceSlots;
|
root: OptionalDeviceSlots;
|
||||||
}>(`${DATA}/${POI.optionalDeviceSlots}`);
|
}>(`${DATA}/${POI.optionalDeviceSlots}.dvpl`);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
nations.map(async (nation) => {
|
nations.map(async (nation) => {
|
||||||
@@ -537,7 +535,34 @@ export async function buildDefinitions() {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
Object.entries(optionalDevices.root).forEach(
|
||||||
|
([optionalDeviceKey, optionalDeviceEntry]) => {
|
||||||
|
if (optionalDeviceKey === 'nextAvailableId') return;
|
||||||
|
|
||||||
|
equipmentDefinitions.equipments[optionalDeviceEntry.id] = {
|
||||||
|
name: strings[optionalDeviceEntry.userString],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
Object.entries(optionalDeviceSlots.root.presets).forEach(
|
||||||
|
([optionalDeviceSlotKey, optionalDeviceSlotEntry]) => {
|
||||||
|
if (optionalDeviceSlotKey === 'emptyPreset') return;
|
||||||
|
|
||||||
|
equipmentDefinitions.presets[optionalDeviceSlotKey] = Object.values(
|
||||||
|
optionalDeviceSlotEntry,
|
||||||
|
).map(
|
||||||
|
(level) =>
|
||||||
|
Object.values(level).map((options) => {
|
||||||
|
return [
|
||||||
|
optionalDevices.root[options.device0].id,
|
||||||
|
optionalDevices.root[options.device1].id,
|
||||||
|
];
|
||||||
|
}) as EquipmentRow,
|
||||||
|
) as EquipmentRows;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
console.log('Committing definitions...');
|
console.log('Committing definitions...');
|
||||||
await commitMultipleFiles(
|
await commitMultipleFiles(
|
||||||
'tresabhi',
|
'tresabhi',
|
||||||
@@ -555,6 +580,11 @@ export async function buildDefinitions() {
|
|||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
path: 'definitions/models.json',
|
path: 'definitions/models.json',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
content: JSON.stringify(equipmentDefinitions),
|
||||||
|
encoding: 'utf-8',
|
||||||
|
path: 'definitions/equipment.json',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,11 +2,15 @@ import { asset } from './asset';
|
|||||||
|
|
||||||
type EquipmentOptions = [number, number];
|
type EquipmentOptions = [number, number];
|
||||||
|
|
||||||
type EquipmentRow = [EquipmentOptions, EquipmentOptions, EquipmentOptions];
|
export type EquipmentRow = [
|
||||||
|
EquipmentOptions,
|
||||||
|
EquipmentOptions,
|
||||||
|
EquipmentOptions,
|
||||||
|
];
|
||||||
|
|
||||||
type EquipmentRows = [EquipmentRow, EquipmentRow, EquipmentRow];
|
export type EquipmentRows = [EquipmentRow, EquipmentRow, EquipmentRow];
|
||||||
|
|
||||||
interface EquipmentDefinitions {
|
export interface EquipmentDefinitions {
|
||||||
presets: {
|
presets: {
|
||||||
[key: string]: EquipmentRows;
|
[key: string]: EquipmentRows;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user