mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-23 06:04:32 +01:00
(5) some implementation
This commit is contained in:
1 parent
6ad64c9bd9
commit
ed31f40876
5 files changed
+238
-375
No files matched your search
@@ -6,13 +6,16 @@ import {
|
|||||||
BlitzModuleType,
|
BlitzModuleType,
|
||||||
BlitzStrings,
|
BlitzStrings,
|
||||||
BlitzTankClass,
|
BlitzTankClass,
|
||||||
|
BlitzTankFilterDefinitionCategory,
|
||||||
CamouflageDefinitions,
|
CamouflageDefinitions,
|
||||||
CamouflagesXml,
|
CamouflagesXml,
|
||||||
CamouflagesYaml,
|
CamouflagesYaml,
|
||||||
ChassisDefinitionsList,
|
ChassisDefinitionsList,
|
||||||
CombatRolesYaml,
|
CombatRolesYaml,
|
||||||
|
Consumable,
|
||||||
ConsumableDefinitions,
|
ConsumableDefinitions,
|
||||||
ConsumablesCommon,
|
ConsumablesCommon,
|
||||||
|
ConsumableTankCategoryFilterCategory,
|
||||||
Crew,
|
Crew,
|
||||||
CrewType,
|
CrewType,
|
||||||
EngineDefinitionsList,
|
EngineDefinitionsList,
|
||||||
@@ -28,6 +31,7 @@ import {
|
|||||||
ModuleType,
|
ModuleType,
|
||||||
OptionalDevices,
|
OptionalDevices,
|
||||||
OptionalDeviceSlots,
|
OptionalDeviceSlots,
|
||||||
|
Provision,
|
||||||
ProvisionDefinitions,
|
ProvisionDefinitions,
|
||||||
ProvisionsCommon,
|
ProvisionsCommon,
|
||||||
ResearchCost,
|
ResearchCost,
|
||||||
@@ -108,6 +112,13 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
HIGH_EXPLOSIVE: ShellType.SHELL_TYPE_HE,
|
HIGH_EXPLOSIVE: ShellType.SHELL_TYPE_HE,
|
||||||
HOLLOW_CHARGE: ShellType.SHELL_TYPE_HEAT,
|
HOLLOW_CHARGE: ShellType.SHELL_TYPE_HEAT,
|
||||||
};
|
};
|
||||||
|
private blitzTankFilterDefinitionCategoryToBlitzkit: Record<
|
||||||
|
BlitzTankFilterDefinitionCategory,
|
||||||
|
ConsumableTankCategoryFilterCategory
|
||||||
|
> = {
|
||||||
|
clip: ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP,
|
||||||
|
};
|
||||||
|
|
||||||
private botPattern = /^.+((tutorial_bot(\d+)?)|(TU))$/;
|
private botPattern = /^.+((tutorial_bot(\d+)?)|(TU))$/;
|
||||||
|
|
||||||
private stringsI18n: Record<string, Record<string, string>> = {};
|
private stringsI18n: Record<string, Record<string, string>> = {};
|
||||||
@@ -165,6 +176,7 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`,
|
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`,
|
||||||
);
|
);
|
||||||
this.tierEqualizer = await this.vfs.csv(
|
this.tierEqualizer = await this.vfs.csv(
|
||||||
|
// spell:disable-next-line
|
||||||
`Data/XML/item_defs/vehicles/common/tier_equializer.csv`,
|
`Data/XML/item_defs/vehicles/common/tier_equializer.csv`,
|
||||||
{ delimiter: ";" },
|
{ delimiter: ";" },
|
||||||
);
|
);
|
||||||
@@ -490,8 +502,6 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
|
|
||||||
for (const crewKey in tankDefinition.root.crew) {
|
for (const crewKey in tankDefinition.root.crew) {
|
||||||
const value = tankDefinition.root.crew[crewKey as BlitzCrewType];
|
const value = tankDefinition.root.crew[crewKey as BlitzCrewType];
|
||||||
|
|
||||||
{
|
|
||||||
let entry: Crew;
|
let entry: Crew;
|
||||||
const index = crew.findIndex(
|
const index = crew.findIndex(
|
||||||
({ type }) => this.blitzkitCrewTypeToBlitz[type] === crewKey,
|
({ type }) => this.blitzkitCrewTypeToBlitz[type] === crewKey,
|
||||||
@@ -526,7 +536,6 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const camouflages = Object.entries(
|
const camouflages = Object.entries(
|
||||||
this.camouflagesXml!.root.camouflages,
|
this.camouflagesXml!.root.camouflages,
|
||||||
@@ -669,7 +678,6 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
|
|
||||||
let turretIndex = 0;
|
let turretIndex = 0;
|
||||||
for (const turretKey in tankDefinition.root.turrets0) {
|
for (const turretKey in tankDefinition.root.turrets0) {
|
||||||
{
|
|
||||||
const turret = tankDefinition.root.turrets0[turretKey];
|
const turret = tankDefinition.root.turrets0[turretKey];
|
||||||
const turretId = toUniqueId(nation, turretList.root.ids[turretKey]);
|
const turretId = toUniqueId(nation, turretList.root.ids[turretKey]);
|
||||||
|
|
||||||
@@ -692,22 +700,9 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
|
|
||||||
let gunIndex = 0;
|
let gunIndex = 0;
|
||||||
for (const gunKey in turret.guns) {
|
for (const gunKey in turret.guns) {
|
||||||
{
|
|
||||||
const gun = turret.guns[gunKey];
|
const gun = turret.guns[gunKey];
|
||||||
const gunId = toUniqueId(nation, gunList.root.ids[gunKey]);
|
const gunId = toUniqueId(nation, gunList.root.ids[gunKey]);
|
||||||
const gunListEntry = gunList.root.shared[gunKey];
|
const gunListEntry = gunList.root.shared[gunKey];
|
||||||
const pitchLimitsRaw =
|
|
||||||
gun.pitchLimits ?? gunListEntry.pitchLimits;
|
|
||||||
const gunPitch = (
|
|
||||||
typeof pitchLimitsRaw === "string"
|
|
||||||
? pitchLimitsRaw
|
|
||||||
: pitchLimitsRaw.at(-1)!
|
|
||||||
)
|
|
||||||
.split(" ")
|
|
||||||
.map(Number) as [number, number];
|
|
||||||
const gunModel = Number(
|
|
||||||
parsePath(gun.models.undamaged).name.split("_")[1],
|
|
||||||
);
|
|
||||||
const gunName = this.getString(gunListEntry.userString);
|
const gunName = this.getString(gunListEntry.userString);
|
||||||
const gunType =
|
const gunType =
|
||||||
"clip" in gun
|
"clip" in gun
|
||||||
@@ -715,17 +710,9 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
? "autoReloader"
|
? "autoReloader"
|
||||||
: "autoLoader"
|
: "autoLoader"
|
||||||
: "regular";
|
: "regular";
|
||||||
// const gunReload = gun.reloadTime;
|
const gunClipCount = gunType === "regular" ? 1 : gun.clip!.count;
|
||||||
// const shellReloads =
|
|
||||||
const gunClipCount =
|
|
||||||
gunType === "regular" ? 1 : gun.clip!.count;
|
|
||||||
const gunArmor: Armor = { thickness: {}, spaced: [] };
|
|
||||||
const shotDispersionFactors =
|
const shotDispersionFactors =
|
||||||
gun.shotDispersionFactors ??
|
gun.shotDispersionFactors ?? gunListEntry.shotDispersionFactors;
|
||||||
gunListEntry.shotDispersionFactors;
|
|
||||||
const maskName = `gun_${gunModel.toString().padStart(2, "0")}`;
|
|
||||||
const maskEnabled =
|
|
||||||
tankParameters.maskSlice?.[maskName]?.enabled ?? false;
|
|
||||||
let assault_ranges: AssaultRanges | undefined;
|
let assault_ranges: AssaultRanges | undefined;
|
||||||
|
|
||||||
if (gun.extras?.trayShell) {
|
if (gun.extras?.trayShell) {
|
||||||
@@ -735,9 +722,7 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
const trimmed = string.trim();
|
const trimmed = string.trim();
|
||||||
|
|
||||||
if (trimmed in this.blitzShellKindToBlitzkit) {
|
if (trimmed in this.blitzShellKindToBlitzkit) {
|
||||||
return this.blitzShellKindToBlitzkit[
|
return this.blitzShellKindToBlitzkit[trimmed as ShellKind];
|
||||||
trimmed as ShellKind
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new SyntaxError(`Invalid shell kind: ${trimmed}`);
|
throw new SyntaxError(`Invalid shell kind: ${trimmed}`);
|
||||||
@@ -774,8 +759,7 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
: gun.invisibilityFactorAtShot.at(-1)!,
|
: gun.invisibilityFactorAtShot.at(-1)!,
|
||||||
aim_time: gun.aimingTime ?? gunListEntry.aimingTime,
|
aim_time: gun.aimingTime ?? gunListEntry.aimingTime,
|
||||||
dispersion_base:
|
dispersion_base:
|
||||||
gun.shotDispersionRadius ??
|
gun.shotDispersionRadius ?? gunListEntry.shotDispersionRadius,
|
||||||
gunListEntry.shotDispersionRadius,
|
|
||||||
dispersion_damaged: shotDispersionFactors.whileGunDamaged,
|
dispersion_damaged: shotDispersionFactors.whileGunDamaged,
|
||||||
dispersion_shot: shotDispersionFactors.afterShot,
|
dispersion_shot: shotDispersionFactors.afterShot,
|
||||||
dispersion_traverse: shotDispersionFactors.turretRotation,
|
dispersion_traverse: shotDispersionFactors.turretRotation,
|
||||||
@@ -822,7 +806,6 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
} satisfies GunDefinition);
|
} satisfies GunDefinition);
|
||||||
|
|
||||||
for (const shellKey in gunListEntry.shots) {
|
for (const shellKey in gunListEntry.shots) {
|
||||||
{
|
|
||||||
const gunShellEntry = gunListEntry.shots[shellKey];
|
const gunShellEntry = gunListEntry.shots[shellKey];
|
||||||
const shell = shellList.root[shellKey];
|
const shell = shellList.root[shellKey];
|
||||||
const shellId = toUniqueId(nation, shell.id);
|
const shellId = toUniqueId(nation, shell.id);
|
||||||
@@ -856,12 +839,9 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
range: gunShellEntry.maxDistance,
|
range: gunShellEntry.maxDistance,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gunIndex++;
|
gunIndex++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
turretIndex++;
|
turretIndex++;
|
||||||
}
|
}
|
||||||
@@ -1076,8 +1056,6 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
|
|
||||||
for (const crewKey in tankDefinition.root.crew) {
|
for (const crewKey in tankDefinition.root.crew) {
|
||||||
const value = tankDefinition.root.crew[crewKey as BlitzCrewType];
|
const value = tankDefinition.root.crew[crewKey as BlitzCrewType];
|
||||||
|
|
||||||
{
|
|
||||||
let entry: Crew;
|
let entry: Crew;
|
||||||
const index = crew.findIndex(
|
const index = crew.findIndex(
|
||||||
({ type }) => this.blitzkitCrewTypeToBlitz[type] === crewKey,
|
({ type }) => this.blitzkitCrewTypeToBlitz[type] === crewKey,
|
||||||
@@ -1112,7 +1090,6 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
modelDefinitions.models[tankId] = {
|
modelDefinitions.models[tankId] = {
|
||||||
armor: hullArmor,
|
armor: hullArmor,
|
||||||
@@ -1310,6 +1287,15 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
async mapDefinitions() {
|
async mapDefinitions() {
|
||||||
const mapDefinitions = MapDefinitions.create();
|
const mapDefinitions = MapDefinitions.create();
|
||||||
|
|
||||||
|
for (const key in this.mapsYaml!.maps) {
|
||||||
|
const map = this.mapsYaml!.maps[key];
|
||||||
|
|
||||||
|
mapDefinitions.maps[map.id] = {
|
||||||
|
id: map.id,
|
||||||
|
name: this.getString(`#maps:${key}:${map.localName}`),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return mapDefinitions;
|
return mapDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1352,18 +1338,228 @@ export class ServerBlitzKitAPI extends BlitzKitAPI {
|
|||||||
async consumableDefinitions() {
|
async consumableDefinitions() {
|
||||||
const consumableDefinitions = ConsumableDefinitions.create();
|
const consumableDefinitions = ConsumableDefinitions.create();
|
||||||
|
|
||||||
|
Object.entries(this.consumablesCommon).forEach(([key, consumable]) => {
|
||||||
|
const entry: Consumable = {
|
||||||
|
id: consumable.id,
|
||||||
|
game_mode_exclusive: "gameModeFilter" in consumable,
|
||||||
|
cooldown: consumable.script.cooldown,
|
||||||
|
duration: consumable.script.duration,
|
||||||
|
name: this.getString(consumable.userString),
|
||||||
|
exclude: [],
|
||||||
|
include: [],
|
||||||
|
};
|
||||||
|
consumableDefinitions.consumables[consumable.id] = entry;
|
||||||
|
|
||||||
|
const includeRaw = consumable.vehicleFilter?.include.vehicle;
|
||||||
|
const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle;
|
||||||
|
|
||||||
|
if (includeRaw) {
|
||||||
|
entry.include = [];
|
||||||
|
|
||||||
|
if ("minLevel" in includeRaw) {
|
||||||
|
entry.include.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "tiers",
|
||||||
|
value: {
|
||||||
|
min: includeRaw.minLevel,
|
||||||
|
max: includeRaw.maxLevel,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if ("name" in includeRaw) {
|
||||||
|
entry.include.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "ids",
|
||||||
|
value: {
|
||||||
|
ids: includeRaw.name.split(/ +/).map((key) => {
|
||||||
|
return this.tankStringIdMap[key];
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else throw new SyntaxError("Unhandled include type");
|
||||||
|
|
||||||
|
if (consumable.vehicleFilter?.include.nations) {
|
||||||
|
entry.include.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "nations",
|
||||||
|
value: {
|
||||||
|
nations: consumable.vehicleFilter.include.nations.split(" "),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludeRaw) {
|
||||||
|
entry.exclude = [];
|
||||||
|
|
||||||
|
if ("name" in excludeRaw) {
|
||||||
|
entry.exclude!.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "ids",
|
||||||
|
value: {
|
||||||
|
ids: excludeRaw.name.split(/ +/).map((key) => {
|
||||||
|
return this.tankStringIdMap[key];
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if ("extendedTags" in excludeRaw) {
|
||||||
|
entry.exclude!.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "categories",
|
||||||
|
value: {
|
||||||
|
categories: excludeRaw.extendedTags
|
||||||
|
.split(" ")
|
||||||
|
.map(
|
||||||
|
(item) =>
|
||||||
|
this.blitzTankFilterDefinitionCategoryToBlitzkit[
|
||||||
|
item as BlitzTankFilterDefinitionCategory
|
||||||
|
],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else throw new SyntaxError("Unhandled exclude type");
|
||||||
|
|
||||||
|
if (consumable.vehicleFilter?.exclude?.nations) {
|
||||||
|
entry.exclude!.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "nations",
|
||||||
|
value: {
|
||||||
|
nations: consumable.vehicleFilter.exclude.nations.split(" "),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return consumableDefinitions;
|
return consumableDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
async provisionDefinitions() {
|
async provisionDefinitions() {
|
||||||
const provisionDefinitions = ProvisionDefinitions.create();
|
const provisionDefinitions = ProvisionDefinitions.create();
|
||||||
|
|
||||||
|
Object.entries(this.provisionsCommon).forEach(([key, provision]) => {
|
||||||
|
const entry: Provision = {
|
||||||
|
id: provision.id,
|
||||||
|
exclude: [],
|
||||||
|
include: [],
|
||||||
|
game_mode_exclusive: "gameModeFilter" in provision,
|
||||||
|
name: this.getString(provision.userString),
|
||||||
|
};
|
||||||
|
provisionDefinitions.provisions[provision.id] = entry;
|
||||||
|
|
||||||
|
const includeRaw = provision.vehicleFilter?.include.vehicle;
|
||||||
|
const excludeRaw = provision.vehicleFilter?.exclude?.vehicle;
|
||||||
|
|
||||||
|
if (includeRaw) {
|
||||||
|
entry.include = [];
|
||||||
|
|
||||||
|
if ("minLevel" in includeRaw) {
|
||||||
|
entry.include.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "tiers",
|
||||||
|
value: {
|
||||||
|
min: includeRaw.minLevel,
|
||||||
|
max: includeRaw.maxLevel,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if ("name" in includeRaw) {
|
||||||
|
entry.include.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "ids",
|
||||||
|
value: {
|
||||||
|
ids: includeRaw.name.split(/ +/).map((key) => {
|
||||||
|
return this.tankStringIdMap[key];
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else throw new SyntaxError("Unhandled include type");
|
||||||
|
|
||||||
|
if (provision.vehicleFilter?.include.nations) {
|
||||||
|
entry.include.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "nations",
|
||||||
|
value: {
|
||||||
|
nations: provision.vehicleFilter.include.nations.split(" "),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludeRaw) {
|
||||||
|
entry.exclude = [];
|
||||||
|
|
||||||
|
if ("name" in excludeRaw) {
|
||||||
|
entry.exclude!.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "ids",
|
||||||
|
value: {
|
||||||
|
ids: excludeRaw.name
|
||||||
|
.split(/ +/)
|
||||||
|
.map((key) => this.tankStringIdMap[key]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if ("extendedTags" in excludeRaw) {
|
||||||
|
entry.exclude!.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "categories",
|
||||||
|
value: {
|
||||||
|
categories: excludeRaw.extendedTags
|
||||||
|
.split(" ")
|
||||||
|
.map(
|
||||||
|
(item) =>
|
||||||
|
this.blitzTankFilterDefinitionCategoryToBlitzkit[
|
||||||
|
item as BlitzTankFilterDefinitionCategory
|
||||||
|
],
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else throw new SyntaxError("Unhandled exclude type");
|
||||||
|
|
||||||
|
if (provision.vehicleFilter?.exclude?.nations) {
|
||||||
|
entry.exclude!.push({
|
||||||
|
filter_type: {
|
||||||
|
$case: "nations",
|
||||||
|
value: {
|
||||||
|
nations: provision.vehicleFilter.exclude.nations.split(" "),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (provision.script.bonusValues?.crewLevelIncrease !== undefined) {
|
||||||
|
provisionDefinitions.provisions[provision.id].crew =
|
||||||
|
provision.script.bonusValues?.crewLevelIncrease;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return provisionDefinitions;
|
return provisionDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
async skillDefinitions() {
|
async skillDefinitions() {
|
||||||
const skillDefinitions = SkillDefinitions.create();
|
const skillDefinitions = SkillDefinitions.create();
|
||||||
|
|
||||||
|
for (const tankClass in this.tankmenAvatar!.root.skillsByClasses) {
|
||||||
|
const skills =
|
||||||
|
this.tankmenAvatar!.root.skillsByClasses[
|
||||||
|
Number(tankClass) as TankClass
|
||||||
|
];
|
||||||
|
|
||||||
|
skillDefinitions.classes[
|
||||||
|
this.blitzTankClassToBlitzkit[tankClass as BlitzTankClass]
|
||||||
|
] = { skills: skills.split(" ") };
|
||||||
|
}
|
||||||
|
|
||||||
return skillDefinitions;
|
return skillDefinitions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export type BlitzTankFilterDefinitionCategory = "clip";
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
export * from "./availableNationsYaml";
|
export * from "./availableNationsYaml";
|
||||||
export * from "./blitzModuleType";
|
export * from "./blitzModuleType";
|
||||||
export * from "./blitzStrings";
|
export * from "./blitzStrings";
|
||||||
|
export * from "./blitzTankFilterDefinitionCategory";
|
||||||
export * from "./camouflagesXml";
|
export * from "./camouflagesXml";
|
||||||
export * from "./camouflagesYaml";
|
export * from "./camouflagesYaml";
|
||||||
export * from "./chassisDefinitionsList";
|
export * from "./chassisDefinitionsList";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import { AssetUploader } from "../core/github/assetUploader";
|
|
||||||
import { parsePackedSpriteRect } from "../core/blitz/parsePackedSpriteRect";
|
import { parsePackedSpriteRect } from "../core/blitz/parsePackedSpriteRect";
|
||||||
|
import { AssetUploader } from "../core/github/assetUploader";
|
||||||
import { vfs } from "./constants";
|
import { vfs } from "./constants";
|
||||||
import { ConsumablesCommon, ProvisionsCommon } from "./definitions";
|
import { ConsumablesCommon, ProvisionsCommon } from "./definitions";
|
||||||
|
|
||||||
|
|||||||
@@ -1,335 +0,0 @@
|
|||||||
import {
|
|
||||||
type BlitzTankClass,
|
|
||||||
CamouflageDefinitions,
|
|
||||||
Consumable,
|
|
||||||
ConsumableDefinitions,
|
|
||||||
ConsumableTankCategoryFilterCategory,
|
|
||||||
EquipmentDefinitions,
|
|
||||||
MapDefinitions,
|
|
||||||
ModelDefinitions,
|
|
||||||
Provision,
|
|
||||||
ProvisionDefinitions,
|
|
||||||
SkillDefinitions,
|
|
||||||
TankDefinitions,
|
|
||||||
} from "@blitzkit/core";
|
|
||||||
|
|
||||||
type BlitzTankFilterDefinitionCategory = "clip";
|
|
||||||
const blitzTankFilterDefinitionCategoryToBlitzkit: Record<
|
|
||||||
BlitzTankFilterDefinitionCategory,
|
|
||||||
ConsumableTankCategoryFilterCategory
|
|
||||||
> = {
|
|
||||||
clip: ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP,
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface BlitzStrings {
|
|
||||||
[key: string]: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ConsumablesCommon {
|
|
||||||
[key: string]: {
|
|
||||||
id: number;
|
|
||||||
userString: string;
|
|
||||||
description: string;
|
|
||||||
icon: string;
|
|
||||||
category: string;
|
|
||||||
tags: string;
|
|
||||||
vehicleFilter?: {
|
|
||||||
include: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
||||||
exclude?: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
||||||
};
|
|
||||||
script: {
|
|
||||||
"#text": string;
|
|
||||||
automatic?: boolean;
|
|
||||||
cooldown: number;
|
|
||||||
duration?: number;
|
|
||||||
shotEffect?: string;
|
|
||||||
bonusValues?: { [key: string]: number };
|
|
||||||
} & Record<string, string>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface ProvisionsCommon {
|
|
||||||
[key: string]: {
|
|
||||||
id: number;
|
|
||||||
userString: string;
|
|
||||||
description: string;
|
|
||||||
icon: string;
|
|
||||||
category: string;
|
|
||||||
tags: string;
|
|
||||||
vehicleFilter?: {
|
|
||||||
include: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
||||||
exclude?: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
||||||
};
|
|
||||||
script: {
|
|
||||||
"#text": string;
|
|
||||||
automatic?: boolean;
|
|
||||||
shotEffect?: string;
|
|
||||||
bonusValues?: { [key: string]: number };
|
|
||||||
} & Record<string, string>;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
type ConsumablesVehicleFilter =
|
|
||||||
| { minLevel: number; maxLevel: number }
|
|
||||||
| { name: string }
|
|
||||||
| { extendedTags: string };
|
|
||||||
|
|
||||||
type CombatRolesYaml = Record<
|
|
||||||
string,
|
|
||||||
{
|
|
||||||
id: number;
|
|
||||||
default_abilities: string[];
|
|
||||||
}
|
|
||||||
>;
|
|
||||||
|
|
||||||
export async function definitions() {
|
|
||||||
Object.entries(consumablesCommon).forEach(([key, consumable]) => {
|
|
||||||
const entry: Consumable = {
|
|
||||||
id: consumable.id,
|
|
||||||
game_mode_exclusive: "gameModeFilter" in consumable,
|
|
||||||
cooldown: consumable.script.cooldown,
|
|
||||||
duration: consumable.script.duration,
|
|
||||||
name: getString(consumable.userString),
|
|
||||||
exclude: [],
|
|
||||||
include: [],
|
|
||||||
};
|
|
||||||
consumableDefinitions.consumables[consumable.id] = entry;
|
|
||||||
|
|
||||||
const includeRaw = consumable.vehicleFilter?.include.vehicle;
|
|
||||||
const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle;
|
|
||||||
|
|
||||||
if (includeRaw) {
|
|
||||||
entry.include = [];
|
|
||||||
|
|
||||||
if ("minLevel" in includeRaw) {
|
|
||||||
entry.include.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "tiers",
|
|
||||||
value: {
|
|
||||||
min: includeRaw.minLevel,
|
|
||||||
max: includeRaw.maxLevel,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else if ("name" in includeRaw) {
|
|
||||||
entry.include.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "ids",
|
|
||||||
value: {
|
|
||||||
ids: includeRaw.name.split(/ +/).map((key) => {
|
|
||||||
return tankStringIdMap[key];
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else throw new SyntaxError("Unhandled include type");
|
|
||||||
|
|
||||||
if (consumable.vehicleFilter?.include.nations) {
|
|
||||||
entry.include.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "nations",
|
|
||||||
value: {
|
|
||||||
nations: consumable.vehicleFilter.include.nations.split(" "),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (excludeRaw) {
|
|
||||||
entry.exclude = [];
|
|
||||||
|
|
||||||
if ("name" in excludeRaw) {
|
|
||||||
entry.exclude!.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "ids",
|
|
||||||
value: {
|
|
||||||
ids: excludeRaw.name.split(/ +/).map((key) => {
|
|
||||||
return tankStringIdMap[key];
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else if ("extendedTags" in excludeRaw) {
|
|
||||||
entry.exclude!.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "categories",
|
|
||||||
value: {
|
|
||||||
categories: excludeRaw.extendedTags
|
|
||||||
.split(" ")
|
|
||||||
.map(
|
|
||||||
(item) =>
|
|
||||||
blitzTankFilterDefinitionCategoryToBlitzkit[
|
|
||||||
item as BlitzTankFilterDefinitionCategory
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else throw new SyntaxError("Unhandled exclude type");
|
|
||||||
|
|
||||||
if (consumable.vehicleFilter?.exclude?.nations) {
|
|
||||||
entry.exclude!.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "nations",
|
|
||||||
value: {
|
|
||||||
nations: consumable.vehicleFilter.exclude.nations.split(" "),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.entries(provisionsCommon).forEach(([key, provision]) => {
|
|
||||||
const entry: Provision = {
|
|
||||||
id: provision.id,
|
|
||||||
exclude: [],
|
|
||||||
include: [],
|
|
||||||
game_mode_exclusive: "gameModeFilter" in provision,
|
|
||||||
name: getString(provision.userString),
|
|
||||||
};
|
|
||||||
provisionDefinitions.provisions[provision.id] = entry;
|
|
||||||
|
|
||||||
const includeRaw = provision.vehicleFilter?.include.vehicle;
|
|
||||||
const excludeRaw = provision.vehicleFilter?.exclude?.vehicle;
|
|
||||||
|
|
||||||
if (includeRaw) {
|
|
||||||
entry.include = [];
|
|
||||||
|
|
||||||
if ("minLevel" in includeRaw) {
|
|
||||||
entry.include.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "tiers",
|
|
||||||
value: {
|
|
||||||
min: includeRaw.minLevel,
|
|
||||||
max: includeRaw.maxLevel,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else if ("name" in includeRaw) {
|
|
||||||
entry.include.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "ids",
|
|
||||||
value: {
|
|
||||||
ids: includeRaw.name.split(/ +/).map((key) => {
|
|
||||||
return tankStringIdMap[key];
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else throw new SyntaxError("Unhandled include type");
|
|
||||||
|
|
||||||
if (provision.vehicleFilter?.include.nations) {
|
|
||||||
entry.include.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "nations",
|
|
||||||
value: {
|
|
||||||
nations: provision.vehicleFilter.include.nations.split(" "),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (excludeRaw) {
|
|
||||||
entry.exclude = [];
|
|
||||||
|
|
||||||
if ("name" in excludeRaw) {
|
|
||||||
entry.exclude!.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "ids",
|
|
||||||
value: {
|
|
||||||
ids: excludeRaw.name
|
|
||||||
.split(/ +/)
|
|
||||||
.map((key) => tankStringIdMap[key]),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else if ("extendedTags" in excludeRaw) {
|
|
||||||
entry.exclude!.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "categories",
|
|
||||||
value: {
|
|
||||||
categories: excludeRaw.extendedTags
|
|
||||||
.split(" ")
|
|
||||||
.map(
|
|
||||||
(item) =>
|
|
||||||
blitzTankFilterDefinitionCategoryToBlitzkit[
|
|
||||||
item as BlitzTankFilterDefinitionCategory
|
|
||||||
],
|
|
||||||
),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else throw new SyntaxError("Unhandled exclude type");
|
|
||||||
|
|
||||||
if (provision.vehicleFilter?.exclude?.nations) {
|
|
||||||
entry.exclude!.push({
|
|
||||||
filter_type: {
|
|
||||||
$case: "nations",
|
|
||||||
value: {
|
|
||||||
nations: provision.vehicleFilter.exclude.nations.split(" "),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (provision.script.bonusValues?.crewLevelIncrease !== undefined) {
|
|
||||||
provisionDefinitions.provisions[provision.id].crew =
|
|
||||||
provision.script.bonusValues?.crewLevelIncrease;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.entries(tankmenAvatar.root.skillsByClasses).forEach(
|
|
||||||
([tankClass, skills]) => {
|
|
||||||
skillDefinitions.classes[
|
|
||||||
blitzTankClassToBlitzkit[tankClass as BlitzTankClass]
|
|
||||||
] = {
|
|
||||||
skills: skills.split(" "),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Object.entries(mapsYaml.maps).forEach(([key, map]) => {
|
|
||||||
mapDefinitions.maps[map.id] = {
|
|
||||||
id: map.id,
|
|
||||||
name: getString(`#maps:${key}:${map.localName}`),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
await uploader.add({
|
|
||||||
content: TankDefinitions.encode(tankDefinitions).finish(),
|
|
||||||
path: "definitions/tanks.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: ModelDefinitions.encode(modelDefinitions).finish(),
|
|
||||||
path: "definitions/models.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: EquipmentDefinitions.encode(equipmentDefinitions).finish(),
|
|
||||||
path: "definitions/equipment.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: ConsumableDefinitions.encode(consumableDefinitions).finish(),
|
|
||||||
path: "definitions/consumables.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: ProvisionDefinitions.encode(provisionDefinitions).finish(),
|
|
||||||
path: "definitions/provisions.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: SkillDefinitions.encode(skillDefinitions).finish(),
|
|
||||||
path: "definitions/skills.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: MapDefinitions.encode(mapDefinitions).finish(),
|
|
||||||
path: "definitions/maps.pb",
|
|
||||||
});
|
|
||||||
await uploader.add({
|
|
||||||
content: CamouflageDefinitions.encode(camouflageDefinitions).finish(),
|
|
||||||
path: "definitions/camouflages.pb",
|
|
||||||
});
|
|
||||||
|
|
||||||
await uploader.flush();
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user