mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
(5) some implementation
This commit is contained in:
1 parent
6ad64c9bd9
commit
ed31f40876
5 files changed
+442
-579
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import sharp from "sharp";
|
||||
import { AssetUploader } from "../core/github/assetUploader";
|
||||
import { parsePackedSpriteRect } from "../core/blitz/parsePackedSpriteRect";
|
||||
import { AssetUploader } from "../core/github/assetUploader";
|
||||
import { vfs } from "./constants";
|
||||
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