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