fix: some linting for new proto

This commit is contained in:
TrèsAbhi committed 2024-10-05 15:24:54 -05:00
1 parent 78dce028d9
commit 94f67e30f1
21 files changed
+372 -327

No files matched your search

BIN
View File
Binary file not shown.
-1
View File
@@ -42,7 +42,6 @@
"esbuild": "^0.19.12",
"prettier": "^3.3.3",
"prisma": "^5.19.1",
"ts-proto": "^2.2.1",
"typescript": "^5.5.4"
}
}
+6 -4
View File
@@ -4,13 +4,15 @@ import {
TankDefinition,
Tier,
flags,
gameDefinitions,
getAccountInfo,
getTankStats,
tankDefinitions,
} from '@blitzkit/core';
import { chunk } from 'lodash-es';
import markdownEscape from 'markdown-escape';
import {
gameDefinitions,
tankDefinitions,
} from '../core/blitzkit/nonBlockingPromises';
import { addTierChoices } from '../core/discord/addTierChoices';
import { addUsernameChoices } from '../core/discord/addUsernameChoices';
import { autocompleteUsername } from '../core/discord/autocompleteUsername';
@@ -41,7 +43,7 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
const filteredTanks = (
await Promise.all(
tankStats.map(async (tankData) => ({
tankDefinitions: (await tankDefinitions)[tankData.tank_id]!,
tankDefinitions: (await tankDefinitions).tanks[tankData.tank_id]!,
id: tankData.tank_id,
})),
)
@@ -61,7 +63,7 @@ export const ownedTanksCommand = new Promise<CommandRegistry>((resolve) => {
const awaitedTankDefinitions = await tankDefinitions;
const awaitedGameDefinitions = await gameDefinitions;
const lines = tankStats
.map(({ tank_id }) => awaitedTankDefinitions[tank_id])
.map(({ tank_id }) => awaitedTankDefinitions.tanks[tank_id])
.filter((tank) => tank.tier === tier)
.sort(
(a, b) =>
@@ -0,0 +1,4 @@
import { fetchGameDefinitions, fetchTankDefinitions } from '@blitzkit/core';
export const tankDefinitions = fetchTankDefinitions();
export const gameDefinitions = fetchGameDefinitions();
+11 -10
View File
@@ -4,18 +4,19 @@
"type": "module",
"main": "src/index.ts",
"dependencies": {
"@octokit/rest": "^20.1.1",
"lodash": "^4.17.21",
"@prisma/client": "^5.19.1",
"@octokit/plugin-throttling": "^8.2.0",
"protobufjs": "^7.4.0",
"lz4js": "^0.2.0",
"yaml": "^2.5.0",
"sharp": "^0.33.5",
"dotenv": "^16.4.5",
"pickleparser": "^0.2.1",
"@octokit/rest": "^20.1.1",
"@prisma/client": "^5.19.1",
"adm-zip": "^0.5.16",
"crc": "^4.3.2"
"crc": "^4.3.2",
"dotenv": "^16.4.5",
"lodash": "^4.17.21",
"lz4js": "^0.2.0",
"pickleparser": "^0.2.1",
"protobufjs": "^7.4.0",
"sharp": "^0.33.5",
"ts-proto": "^2.2.2",
"yaml": "^2.5.0"
},
"devDependencies": {
"@types/adm-zip": "^0.5.5",
@@ -5,65 +5,74 @@ import {
TankClass,
TankType,
Tier,
} from '.';
} from '../../protos';
export const SHELL_NAMES: Record<ShellType, string> = {
ap: 'AP',
ap_cr: 'APCR',
hc: 'HEAT',
he: 'HE',
[ShellType.AP]: 'AP',
[ShellType.APCR]: 'APCR',
[ShellType.HEAT]: 'HEAT',
[ShellType.HE]: 'HE',
[ShellType.UNRECOGNIZED]: 'unrecognized',
};
export const CREW_MEMBER_NAMES: Record<CrewType, string> = {
commander: 'Commander',
radioman: 'Radioman',
gunner: 'Gunner',
driver: 'Driver',
loader: 'Loader',
[CrewType.COMMANDER]: 'Commander',
[CrewType.DRIVER]: 'Driver',
[CrewType.GUNNER]: 'Gunner',
[CrewType.LOADER]: 'Loader',
[CrewType.RADIOMAN]: 'Radioman',
[CrewType.UNRECOGNIZED]: 'unrecognized',
};
export const GUN_TYPE_NAMES: Record<GunDefinition['type'], string> = {
regular: 'Regular',
export const GUN_TYPE_NAMES: Record<
Exclude<GunDefinition['gunType'], undefined>['$case'],
string
> = {
autoLoader: 'Auto loader',
autoReloader: 'Auto reloader',
regular: 'Regular',
};
/**
* @deprecated use svg
*/
export const TANK_ICONS: Record<TankClass, string> = {
'AT-SPG': 'https://i.imgur.com/BIHSEH0.png',
lightTank: 'https://i.imgur.com/CSNha5V.png',
mediumTank: 'https://i.imgur.com/wvf3ltm.png',
heavyTank: 'https://i.imgur.com/ECeqlZa.png',
[TankClass.TANK_DESTROYER]: 'https://i.imgur.com/BIHSEH0.png',
[TankClass.LIGHT]: 'https://i.imgur.com/CSNha5V.png',
[TankClass.MEDIUM]: 'https://i.imgur.com/wvf3ltm.png',
[TankClass.HEAVY]: 'https://i.imgur.com/ECeqlZa.png',
[TankClass.UNRECOGNIZED]: 'https://i.imgur.com/6FBBzb9.png', // lmfao click on this
};
/**
* @deprecated use svg
*/
export const TANK_ICONS_PREMIUM: Record<TankClass, string> = {
'AT-SPG': 'https://i.imgur.com/TCu3EdR.png',
lightTank: 'https://i.imgur.com/zdkpTRb.png',
mediumTank: 'https://i.imgur.com/3z7eHX6.png',
heavyTank: 'https://i.imgur.com/P3vbmyA.png',
[TankClass.TANK_DESTROYER]: 'https://i.imgur.com/TCu3EdR.png',
[TankClass.LIGHT]: 'https://i.imgur.com/zdkpTRb.png',
[TankClass.MEDIUM]: 'https://i.imgur.com/3z7eHX6.png',
[TankClass.HEAVY]: 'https://i.imgur.com/P3vbmyA.png',
[TankClass.UNRECOGNIZED]: 'https://i.imgur.com/6FBBzb9.png',
};
/**
* @deprecated use svg
*/
export const TANK_ICONS_COLLECTOR: Record<TankClass, string> = {
'AT-SPG': 'https://i.imgur.com/WTjeirB.png',
lightTank: 'https://i.imgur.com/EwhtKkU.png',
mediumTank: 'https://i.imgur.com/u8YDMBh.png',
heavyTank: 'https://i.imgur.com/8xRf3nc.png',
[TankClass.TANK_DESTROYER]: 'https://i.imgur.com/WTjeirB.png',
[TankClass.LIGHT]: 'https://i.imgur.com/EwhtKkU.png',
[TankClass.MEDIUM]: 'https://i.imgur.com/u8YDMBh.png',
[TankClass.HEAVY]: 'https://i.imgur.com/8xRf3nc.png',
[TankClass.UNRECOGNIZED]: 'https://i.imgur.com/6FBBzb9.png',
};
export const TIERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] as const;
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
1: 'I',
2: 'II',
3: 'III',
4: 'IV',
5: 'V',
6: 'VI',
7: 'VII',
8: 'VIII',
9: 'IX',
10: 'X',
[Tier.I]: 'I',
[Tier.II]: 'II',
[Tier.III]: 'III',
[Tier.IV]: 'IV',
[Tier.V]: 'V',
[Tier.VI]: 'VI',
[Tier.VII]: 'VII',
[Tier.VIII]: 'VIII',
[Tier.IX]: 'IX',
[Tier.X]: 'X',
[Tier.UNRECOGNIZED]: 'unrecognized',
};
export const flags: Record<string, string> = {
@@ -78,7 +87,14 @@ export const flags: Record<string, string> = {
other: '<:other:1218421572243558482>',
};
export const TREE_TYPE_ICONS: Record<TankType, Record<TankClass, string>> = {
researchable: TANK_ICONS,
premium: TANK_ICONS_PREMIUM,
collector: TANK_ICONS_COLLECTOR,
[TankType.RESEARCHABLE]: TANK_ICONS,
[TankType.PREMIUM]: TANK_ICONS_PREMIUM,
[TankType.COLLECTOR]: TANK_ICONS_COLLECTOR,
[TankType.UNRECOGNIZED]: {
'-1': 'https://i.imgur.com/6FBBzb9.png',
'0': 'https://i.imgur.com/6FBBzb9.png',
'1': 'https://i.imgur.com/6FBBzb9.png',
'2': 'https://i.imgur.com/6FBBzb9.png',
'3': 'https://i.imgur.com/6FBBzb9.png',
},
};
@@ -1,47 +1,47 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
message AverageDefinitions {
map<uint32, AverageDefinitionsEntry> averages = 1;
Samples samples = 2;
uint64 time = 3;
required Samples samples = 2;
required uint64 time = 3;
}
message AverageDefinitionsEntry {
AverageDefinitionsAllStats mu = 1;
AverageDefinitionsAllStats sigma = 2;
AverageDefinitionsAllStats r = 3;
Samples samples = 4;
required AverageDefinitionsAllStats mu = 1;
required AverageDefinitionsAllStats sigma = 2;
required AverageDefinitionsAllStats r = 3;
required Samples samples = 4;
}
message AverageDefinitionsAllStats {
float battles = 1;
float capture_points = 2;
float damage_dealt = 3;
float damage_received = 4;
float dropped_capture_points = 5;
float frags = 6;
float frags8p = 7;
float hits = 8;
float losses = 9;
float max_frags = 10;
float max_xp = 11;
float shots = 12;
float spotted = 13;
float survived_battles = 14;
float win_and_survived = 15;
float wins = 16;
float xp = 17;
float battle_life_time = 18;
required float battles = 1;
required float capture_points = 2;
required float damage_dealt = 3;
required float damage_received = 4;
required float dropped_capture_points = 5;
required float frags = 6;
required float frags8p = 7;
required float hits = 8;
required float losses = 9;
required float max_frags = 10;
required float max_xp = 11;
required float shots = 12;
required float spotted = 13;
required float survived_battles = 14;
required float win_and_survived = 15;
required float wins = 16;
required float xp = 17;
required float battle_life_time = 18;
}
message Samples {
uint32 d_1 = 1;
uint32 d_7 = 2;
uint32 d_30 = 3;
uint32 d_60 = 4;
uint32 d_90 = 5;
uint32 d_120 = 6;
uint32 total = 7;
required uint32 d_1 = 1;
required uint32 d_7 = 2;
required uint32 d_30 = 3;
required uint32 d_60 = 4;
required uint32 d_90 = 5;
required uint32 d_120 = 6;
required uint32 total = 7;
}
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -7,8 +7,8 @@ message CamouflageDefinitions {
}
message Camouflage {
uint32 id = 1;
string name = 2;
required uint32 id = 1;
required string name = 2;
optional string tank_name = 3;
optional string tank_name_full = 4;
}
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -9,11 +9,11 @@ message ConsumableDefinitions {
}
message Consumable {
uint32 id = 1;
string name = 2;
uint32 cooldown = 3;
required uint32 id = 1;
required string name = 2;
required uint32 cooldown = 3;
optional uint32 duration = 4;
bool game_mode_exclusive = 5;
required bool game_mode_exclusive = 5;
repeated ConsumableTankFilter include = 6;
repeated ConsumableTankFilter exclude = 7;
}
@@ -28,8 +28,8 @@ message ConsumableTankFilter {
}
message ConsumableTankTierFilter {
Tier min = 1;
Tier max = 2;
required Tier min = 1;
required Tier max = 2;
}
message ConsumableTankIdsFilter {
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -8,8 +8,8 @@ message EquipmentDefinitions {
}
message Equipment {
string name = 1;
string description = 2;
required string name = 1;
required string description = 2;
}
message EquipmentPreset {
@@ -17,6 +17,6 @@ message EquipmentPreset {
}
message EquipmentSlot {
uint32 left = 1;
uint32 right = 2;
required uint32 left = 1;
required uint32 right = 2;
}
@@ -1,16 +1,16 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
message GameDefinitions {
string version = 1;
required string version = 1;
repeated string nations = 2;
map<uint32, GameMode> gameModes = 3;
map<uint32, GameModeRole> roles = 4;
}
message GameMode {
string name = 1;
required string name = 1;
}
message GameModeRole {
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -7,6 +7,6 @@ message MapDefinitions {
}
message MapDefinition {
uint32 id = 1;
string name = 2;
required uint32 id = 1;
required string name = 2;
}
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -7,12 +7,12 @@ message ModelDefinitions {
}
message ModelDefinition {
Armor armor = 1;
Vector3 turret_origin = 2;
required Armor armor = 1;
required Vector3 turret_origin = 2;
optional InitialTurretRotation initial_turret_rotation = 3;
map<uint32, TurretModelDefinition> turrets = 4;
map<uint32, TrackModelDefinition> tracks = 5;
BoundingBox bounding_box = 6;
required BoundingBox bounding_box = 6;
}
message Armor {
@@ -21,59 +21,59 @@ message Armor {
}
message Vector3 {
float x = 1;
float y = 2;
float z = 3;
required float x = 1;
required float y = 2;
required float z = 3;
}
message InitialTurretRotation {
float yaw = 1;
float pitch = 2;
float roll = 3;
required float yaw = 1;
required float pitch = 2;
required float roll = 3;
}
message TurretModelDefinition {
BoundingBox bounding_box = 1;
Armor armor = 2;
uint32 model_id = 3;
Vector3 gun_origin = 4;
required BoundingBox bounding_box = 1;
required Armor armor = 2;
required uint32 model_id = 3;
required Vector3 gun_origin = 4;
map<uint32, GunModelDefinition> guns = 5;
optional YawLimits yaw = 6;
}
message YawLimits {
float min = 1;
float max = 2;
required float min = 1;
required float max = 2;
}
message BoundingBox {
Vector3 min = 1;
Vector3 max = 2;
required Vector3 min = 1;
required Vector3 max = 2;
}
message TrackModelDefinition {
uint32 thickness = 1;
Vector3 origin = 2;
required uint32 thickness = 1;
required Vector3 origin = 2;
}
message GunModelDefinition {
Armor armor = 1;
uint32 thickness = 2;
uint32 model_id = 3;
PitchLimits pitch = 4;
required Armor armor = 1;
required uint32 thickness = 2;
required uint32 model_id = 3;
required PitchLimits pitch = 4;
optional float mask = 5;
}
message PitchLimits {
float min = 1;
float max = 2;
required float min = 1;
required float max = 2;
optional PitchLimitsExtrema front = 3;
optional PitchLimitsExtrema back = 4;
optional float transition = 5;
}
message PitchLimitsExtrema {
float min = 1;
float max = 2;
float range = 3;
required float min = 1;
required float max = 2;
required float range = 3;
}
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -9,10 +9,10 @@ message ProvisionDefinitions {
}
message Provision {
uint32 id = 1;
string name = 2;
required uint32 id = 1;
required string name = 2;
optional float crew = 3;
bool game_mode_exclusive = 5;
required bool game_mode_exclusive = 5;
repeated ConsumableTankFilter include = 6;
repeated ConsumableTankFilter exclude = 7;
}
+4 -4
View File
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -7,11 +7,11 @@ message Reviews {
}
message Review {
float last_updated = 1;
required float last_updated = 1;
repeated Video videos = 2;
}
message Video {
string id = 1;
string author = 2;
required string id = 1;
required string author = 2;
}
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
+89 -89
View File
@@ -1,4 +1,4 @@
syntax = "proto3";
syntax = "proto2";
package blitzkit;
@@ -7,37 +7,37 @@ message TankDefinitions {
}
message TankDefinition {
uint32 id = 1;
required uint32 id = 1;
map<uint32, uint32> roles = 2;
optional string description = 3;
bool fixed_camouflage = 4;
required bool fixed_camouflage = 4;
repeated int32 camouflages = 5;
repeated int32 ancestors = 6;
repeated int32 successors = 7;
repeated Crew crew = 8;
uint32 health = 9;
string nation = 10;
string name = 11;
required uint32 health = 9;
required string nation = 10;
required string name = 11;
optional string name_full = 12;
TankType type = 13;
uint32 max_consumables = 14;
uint32 max_provisions = 15;
Tier tier = 16;
TankClass class = 17;
bool testing = 18;
bool deprecated = 19;
required TankType type = 13;
required uint32 max_consumables = 14;
required uint32 max_provisions = 15;
required Tier tier = 16;
required TankClass class = 17;
required bool testing = 18;
required bool deprecated = 19;
repeated TurretDefinition turrets = 20;
repeated EngineDefinition engines = 21;
repeated TrackDefinition tracks = 22;
TankPrice price = 23;
required TankPrice price = 23;
optional uint32 xp = 24;
float speed_forwards = 25;
float speed_backwards = 26;
float camouflage_still = 27;
float camouflage_moving = 28;
float camouflage_onFire = 29;
string equipment_preset = 30;
uint32 weight = 31;
required float speed_forwards = 25;
required float speed_backwards = 26;
required float camouflage_still = 27;
required float camouflage_moving = 28;
required float camouflage_onFire = 29;
required string equipment_preset = 30;
required uint32 weight = 31;
}
enum TankPriceType {
@@ -46,45 +46,45 @@ enum TankPriceType {
}
message TankPrice {
TankPriceType type = 1;
uint32 value = 2;
required TankPriceType type = 1;
required uint32 value = 2;
}
message TrackDefinition {
uint32 id = 1;
Tier tier = 2;
string name = 3;
uint32 weight = 4;
float traverse_speed = 5;
required uint32 id = 1;
required Tier tier = 2;
required string name = 3;
required uint32 weight = 4;
required float traverse_speed = 5;
optional uint32 xp = 6;
float dispersion_move = 7;
float dispersion_traverse = 8;
float resistance_hard = 9;
float resistance_medium = 10;
float resistance_soft = 11;
required float dispersion_move = 7;
required float dispersion_traverse = 8;
required float resistance_hard = 9;
required float resistance_medium = 10;
required float resistance_soft = 11;
repeated Unlock unlocks = 12;
}
message EngineDefinition {
uint32 id = 1;
string name = 2;
required uint32 id = 1;
required string name = 2;
optional uint32 xp = 3;
Tier tier = 4;
required Tier tier = 4;
optional float fire_chance = 5;
uint32 power = 6;
uint32 weight = 7;
required uint32 power = 6;
required uint32 weight = 7;
repeated Unlock unlocks = 8;
}
message TurretDefinition {
uint32 id = 1;
uint32 health = 2;
uint32 view_range = 3;
float traverse_speed = 4;
required uint32 id = 1;
required uint32 health = 2;
required uint32 view_range = 3;
required float traverse_speed = 4;
optional uint32 xp = 5;
string name = 6;
Tier tier = 7;
uint32 weight = 8;
required string name = 6;
required Tier tier = 7;
required uint32 weight = 8;
repeated GunDefinition guns = 9;
repeated Unlock unlocks = 10;
}
@@ -98,66 +98,66 @@ message GunDefinition {
}
message GunDefinitionRegular {
GunDefinitionBase gun = 1;
GunDefinitionRegularProperties regular = 2;
required GunDefinitionBase gun = 1;
required GunDefinitionRegularProperties regular = 2;
}
message GunDefinitionRegularProperties {
float reload = 1;
required float reload = 1;
}
message GunDefinitionAutoLoader {
GunDefinitionBase gun = 1;
GunDefinitionAutoLoaderProperties auto_loader = 2;
required GunDefinitionBase gun = 1;
required GunDefinitionAutoLoaderProperties auto_loader = 2;
}
message GunDefinitionAutoLoaderProperties {
float clip_reload = 1;
float intra_clip = 2;
float shell_count = 3;
required float clip_reload = 1;
required float intra_clip = 2;
required float shell_count = 3;
}
message GunDefinitionAutoReloader {
GunDefinitionBase gun = 1;
GunDefinitionAutoReloaderProperties auto_reloader = 2;
required GunDefinitionBase gun = 1;
required GunDefinitionAutoReloaderProperties auto_reloader = 2;
}
message GunDefinitionAutoReloaderProperties {
repeated float shell_reloads = 1;
float intra_clip = 2;
float shell_count = 3;
required float intra_clip = 2;
required float shell_count = 3;
}
message GunDefinitionBase {
uint32 id = 1;
float rotation_speed = 2;
required uint32 id = 1;
required float rotation_speed = 2;
optional uint32 xp = 3;
uint32 weight = 4;
string name = 5;
Tier tier = 6;
required uint32 weight = 4;
required string name = 5;
required Tier tier = 6;
repeated ShellDefinition shells = 7;
float camouflage_loss = 8;
float aim_time = 9;
float dispersion_base = 10;
float dispersion_traverse = 11;
float dispersion_shot = 12;
float dispersion_damaged = 13;
required float camouflage_loss = 8;
required float aim_time = 9;
required float dispersion_base = 10;
required float dispersion_traverse = 11;
required float dispersion_shot = 12;
required float dispersion_damaged = 13;
repeated Unlock unlocks = 14;
}
message ShellDefinition {
uint32 id = 1;
string name = 2;
uint32 velocity = 3;
uint32 armor_damage = 4;
uint32 module_damage = 5;
uint32 caliber = 6;
string icon = 7;
ShellPenetration penetration = 8;
ShellType type = 9;
uint32 normalization = 10;
uint32 ricochet = 11;
uint32 explosion_radius = 12;
required uint32 id = 1;
required string name = 2;
required uint32 velocity = 3;
required uint32 armor_damage = 4;
required uint32 module_damage = 5;
required uint32 caliber = 6;
required string icon = 7;
required ShellPenetration penetration = 8;
required ShellType type = 9;
required uint32 normalization = 10;
required uint32 ricochet = 11;
required uint32 explosion_radius = 12;
}
enum ShellType {
@@ -168,19 +168,19 @@ enum ShellType {
}
message ShellPenetration {
uint32 near = 1;
uint32 far = 2;
required uint32 near = 1;
required uint32 far = 2;
}
message Unlock {
int32 id = 1;
ModuleType type = 2;
UnlockCost cost = 3;
required int32 id = 1;
required ModuleType type = 2;
required UnlockCost cost = 3;
}
message UnlockCost {
string type = 1;
int32 value = 2;
required string type = 1;
required int32 value = 2;
}
enum ModuleType {
@@ -218,8 +218,8 @@ enum TankType {
}
message Crew {
CrewType type = 1;
uint32 count = 2;
required CrewType type = 1;
required uint32 count = 2;
repeated CrewType substitute = 3;
}
-10
View File
@@ -1,10 +0,0 @@
syntax = "proto3";
message Test {
Child child_b = 1;
uint32 child_a = 2;
}
message Child {
string value = 1;
}
+116 -80
View File
@@ -46,17 +46,17 @@ const blitzTankFilterDefinitionCategoryToBlitzkit: Record<
BlitzTankFilterDefinitionCategory,
ConsumableTankCategoryFilterCategory
> = {
clip: ConsumableTankCategoryFilterCategory.TANK_CATEGORY_CLIP,
clip: ConsumableTankCategoryFilterCategory.CLIP,
};
function vector3TupleToBlitzkit(tuple: Vector3Tuple) {
return { x: tuple[0], y: tuple[1], z: tuple[2] } satisfies Vector3;
}
type BlitzTankClass = 'lightTank' | 'mediumTank' | 'heavyTank' | 'AT-SPG';
const blitzTankClassToBlitzkit: Record<BlitzTankClass, TankClass> = {
lightTank: TankClass.TANK_CLASS_LIGHT,
'AT-SPG': TankClass.TANK_CLASS_TANK_DESTROYER,
heavyTank: TankClass.TANK_CLASS_HEAVY,
mediumTank: TankClass.TANK_CLASS_MEDIUM,
lightTank: TankClass.LIGHT,
'AT-SPG': TankClass.TANK_DESTROYER,
heavyTank: TankClass.HEAVY,
mediumTank: TankClass.MEDIUM,
};
export interface BlitzStrings {
[key: string]: string;
@@ -115,18 +115,18 @@ type BlitzModuleType = {
type UnlocksListing = BlitzModuleType | undefined;
type BlitzCrewType = 'commander' | 'radioman' | 'gunner' | 'driver' | 'loader';
const blitzCrewTypeToBlitzkit: Record<BlitzCrewType, CrewType> = {
commander: CrewType.CREW_TYPE_COMMANDER,
driver: CrewType.CREW_TYPE_DRIVER,
gunner: CrewType.CREW_TYPE_GUNNER,
loader: CrewType.CREW_TYPE_LOADER,
radioman: CrewType.CREW_TYPE_RADIOMAN,
commander: CrewType.COMMANDER,
driver: CrewType.DRIVER,
gunner: CrewType.GUNNER,
loader: CrewType.LOADER,
radioman: CrewType.RADIOMAN,
};
const blitzkitCrewTypeToBlitz: Record<CrewType, BlitzCrewType> = {
[CrewType.CREW_TYPE_COMMANDER]: 'commander',
[CrewType.CREW_TYPE_DRIVER]: 'driver',
[CrewType.CREW_TYPE_GUNNER]: 'gunner',
[CrewType.CREW_TYPE_LOADER]: 'loader',
[CrewType.CREW_TYPE_RADIOMAN]: 'radioman',
[CrewType.COMMANDER]: 'commander',
[CrewType.DRIVER]: 'driver',
[CrewType.GUNNER]: 'gunner',
[CrewType.LOADER]: 'loader',
[CrewType.RADIOMAN]: 'radioman',
// this should never happen... i hope 😢
[CrewType.UNRECOGNIZED]: 'radioman',
@@ -474,21 +474,21 @@ type CombatRolesYaml = Record<
>;
const blitzShellKindToBlitzkit: Record<ShellKind, ShellType> = {
ARMOR_PIERCING: ShellType.SHELL_TYPE_AP,
ARMOR_PIERCING_CR: ShellType.SHELL_TYPE_APCR,
HIGH_EXPLOSIVE: ShellType.SHELL_TYPE_HE,
HOLLOW_CHARGE: ShellType.SHELL_TYPE_HEAT,
ARMOR_PIERCING: ShellType.AP,
ARMOR_PIERCING_CR: ShellType.APCR,
HIGH_EXPLOSIVE: ShellType.HE,
HOLLOW_CHARGE: ShellType.HEAT,
};
const missingStrings: Record<string, string> = {
'#artefacts:tungstentip/name': 'Tungsten Shells',
};
export const botPattern = /^.+((tutorial_bot(\d+)?)|(TU(R?)))$/;
const blitzModuleTypeToBlitzkit: Record<keyof BlitzModuleType, ModuleType> = {
chassis: ModuleType.MODULE_TYPE_TRACKS,
engine: ModuleType.MODULE_TYPE_ENGINE,
gun: ModuleType.MODULE_TYPE_GUN,
turret: ModuleType.MODULE_TYPE_TURRET,
vehicle: ModuleType.MODULE_TYPE_VEHICLE,
chassis: ModuleType.TRACKS,
engine: ModuleType.ENGINE,
gun: ModuleType.GUN,
turret: ModuleType.TURRET,
vehicle: ModuleType.VEHICLE,
};
export async function definitions() {
@@ -524,10 +524,10 @@ export async function definitions() {
const provisionDefinitions: ProvisionDefinitions = { provisions: {} };
const skillDefinitions: SkillDefinitions = {
classes: {
[TankClass.TANK_CLASS_LIGHT]: { skills: [] },
[TankClass.TANK_CLASS_MEDIUM]: { skills: [] },
[TankClass.TANK_CLASS_HEAVY]: { skills: [] },
[TankClass.TANK_CLASS_TANK_DESTROYER]: { skills: [] },
[TankClass.LIGHT]: { skills: [] },
[TankClass.MEDIUM]: { skills: [] },
[TankClass.HEAVY]: { skills: [] },
[TankClass.TANK_DESTROYER]: { skills: [] },
},
};
const nations = await readdir(`${DATA}/XML/item_defs/vehicles`).then(
@@ -749,17 +749,17 @@ export async function definitions() {
if (tank.sellPrice) {
tankPrice = {
type: TankPriceType.TANK_PRICE_TYPE_GOLD,
type: TankPriceType.GOLD,
value: tank.sellPrice['#text'] * 2,
};
} else if (typeof tank.price === 'number') {
tankPrice = {
type: TankPriceType.TANK_PRICE_TYPE_CREDITS,
type: TankPriceType.CREDITS,
value: tank.price,
};
} else {
tankPrice = {
type: TankPriceType.TANK_PRICE_TYPE_CREDITS,
type: TankPriceType.CREDITS,
value: tank.price['#text'] * 400,
};
}
@@ -869,10 +869,10 @@ export async function definitions() {
nameFull: strings[tank.userString],
nation,
type: tankTags.includes('collectible')
? TankType.TANK_TYPE_COLLECTOR
? TankType.COLLECTOR
: (typeof tank.price === 'number' ? false : 'gold' in tank.price)
? TankType.TANK_TYPE_PREMIUM
: TankType.TANK_TYPE_RESEARCHABLE,
? TankType.PREMIUM
: TankType.RESEARCHABLE,
tier: tank.level as Tier,
class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass],
testing: tankTags.includes('testTank'),
@@ -1398,22 +1398,31 @@ export async function definitions() {
if ('minLevel' in includeRaw) {
entry.include.push({
tiers: { min: includeRaw.minLevel, max: includeRaw.maxLevel },
filterType: {
$case: 'tiers',
tiers: { min: includeRaw.minLevel, max: includeRaw.maxLevel },
},
});
} else if ('name' in includeRaw) {
entry.include.push({
ids: {
ids: includeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
filterType: {
$case: 'ids',
ids: {
ids: includeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
},
},
});
} else throw new SyntaxError('Unhandled include type');
if (consumable.vehicleFilter?.include.nations) {
entry.include.push({
nations: {
nations: consumable.vehicleFilter.include.nations.split(' '),
filterType: {
$case: 'nations',
nations: {
nations: consumable.vehicleFilter.include.nations.split(' '),
},
},
});
}
@@ -1424,31 +1433,40 @@ export async function definitions() {
if ('name' in excludeRaw) {
entry.exclude!.push({
ids: {
ids: excludeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
filterType: {
$case: 'ids',
ids: {
ids: excludeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
},
},
});
} else if ('extendedTags' in excludeRaw) {
entry.exclude!.push({
categories: {
categories: excludeRaw.extendedTags
.split(' ')
.map(
(item) =>
blitzTankFilterDefinitionCategoryToBlitzkit[
item as BlitzTankFilterDefinitionCategory
],
),
filterType: {
$case: 'categories',
categories: {
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({
nations: {
nations: consumable.vehicleFilter.exclude.nations.split(' '),
filterType: {
$case: 'nations',
nations: {
nations: consumable.vehicleFilter.exclude.nations.split(' '),
},
},
});
}
@@ -1480,25 +1498,34 @@ export async function definitions() {
if ('minLevel' in includeRaw) {
entry.include.push({
tiers: {
min: includeRaw.minLevel,
max: includeRaw.maxLevel,
filterType: {
$case: 'tiers',
tiers: {
min: includeRaw.minLevel,
max: includeRaw.maxLevel,
},
},
});
} else if ('name' in includeRaw) {
entry.include.push({
ids: {
ids: includeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
filterType: {
$case: 'ids',
ids: {
ids: includeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
},
},
});
} else throw new SyntaxError('Unhandled include type');
if (provision.vehicleFilter?.include.nations) {
entry.include.push({
nations: {
nations: provision.vehicleFilter.include.nations.split(' '),
filterType: {
$case: 'nations',
nations: {
nations: provision.vehicleFilter.include.nations.split(' '),
},
},
});
}
@@ -1509,31 +1536,40 @@ export async function definitions() {
if ('name' in excludeRaw) {
entry.exclude!.push({
ids: {
ids: excludeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
filterType: {
$case: 'ids',
ids: {
ids: excludeRaw.name
.split(' ')
.map((key) => tankStringIdMap[key]),
},
},
});
} else if ('extendedTags' in excludeRaw) {
entry.exclude!.push({
categories: {
categories: excludeRaw.extendedTags
.split(' ')
.map(
(item) =>
blitzTankFilterDefinitionCategoryToBlitzkit[
item as BlitzTankFilterDefinitionCategory
],
),
filterType: {
$case: 'categories',
categories: {
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({
nations: {
nations: provision.vehicleFilter.exclude.nations.split(' '),
filterType: {
$case: 'nations',
nations: {
nations: provision.vehicleFilter.exclude.nations.split(' '),
},
},
});
}
+2 -2
View File
@@ -13,7 +13,7 @@ import { boosterIcons } from './boosterIcons';
import { camouflageIcons } from './camouflageIcons';
import { consumableProvisionIcons } from './consumableProvisionIcons';
import { currencies } from './currencies';
import { tankDefinitions } from './definitions';
import { definitions } from './definitions';
import { equipmentIcons } from './equipmentIcons';
import { flags } from './flags';
import { gameModeBanners } from './gameModeBanners';
@@ -30,7 +30,7 @@ const methods = [
tankModels,
tankArmors,
gameModeBanners,
tankDefinitions,
definitions,
tankIcons,
currencies,
skillIcons,
-3
View File
@@ -30,9 +30,6 @@ const args = [
'--ts_proto_opt=esModuleInterop=true',
'--ts_proto_opt=oneof=unions',
'--ts_proto_opt=removeEnumPrefix=true',
'--ts_proto_opt=snakeToCamel=false',
'--ts_proto_opt=useOptionals=none',
'--ts_proto_opt=noDefaultsForOptionals=true',
'--ts_proto_out=.',
...files.map((file) => `${ROOT}/${file}`),
];