fix: definitions casing

This commit is contained in:
TrèsAbhi committed 2024-10-07 19:37:38 -05:00
1 parent afb730924c
commit 1bd4c498c2
1 file changed
+81 -80
+81 -80
View File
@@ -46,12 +46,12 @@ import { TankParameters } from './tankIcons';
function parseResearchCost(raw: number | string) { function parseResearchCost(raw: number | string) {
if (typeof raw === 'number') { if (typeof raw === 'number') {
return { return {
researchCostType: { $case: 'xp', value: raw }, research_cost_type: { $case: 'xp', value: raw },
} satisfies ResearchCost; } satisfies ResearchCost;
} else { } else {
return { return {
researchCostType: { research_cost_type: {
$case: 'seasonalTokens', $case: 'seasonal_tokens',
value: { value: {
season: Number(/prx_season_(\d+):\d+/.exec(raw)![1]), season: Number(/prx_season_(\d+):\d+/.exec(raw)![1]),
tokens: Number(/prx_season_\d+:(\d+)/.exec(raw)![1]), tokens: Number(/prx_season_\d+:(\d+)/.exec(raw)![1]),
@@ -668,8 +668,8 @@ export async function definitions() {
camouflageDefinitions.camouflages[camo.id] = { camouflageDefinitions.camouflages[camo.id] = {
id: camo.id, id: camo.id,
name: strings[camo.userString], name: strings[camo.userString],
tankName: resolvedTankName, tank_name: resolvedTankName,
tankNameFull: resolvedTankNameFull, tank_name_full: resolvedTankNameFull,
}; };
}); });
@@ -867,35 +867,35 @@ export async function definitions() {
camouflages: camouflages, camouflages: camouflages,
description: description:
wargamingTankopedia.data[tankId]?.description ?? undefined, wargamingTankopedia.data[tankId]?.description ?? undefined,
fixedCamouflage: fixedCamouflage, fixed_camouflage: fixedCamouflage,
crew, crew,
weight: tankDefinition.root.hull.weight, weight: tankDefinition.root.hull.weight,
health: tankDefinition.root.hull.maxHealth, health: tankDefinition.root.hull.maxHealth,
speedForwards: tankDefinition.root.speedLimits.forward, speed_forwards: tankDefinition.root.speedLimits.forward,
speedBackwards: tankDefinition.root.speedLimits.backward, speed_backwards: tankDefinition.root.speedLimits.backward,
equipmentPreset: equipment_preset:
typeof equipment === 'string' ? equipment : equipment.at(-1)!, typeof equipment === 'string' ? equipment : equipment.at(-1)!,
maxConsumables: tankDefinition.root.consumableSlots, max_consumables: tankDefinition.root.consumableSlots,
maxProvisions: tankDefinition.root.provisionSlots, max_provisions: tankDefinition.root.provisionSlots,
name: name:
(tank.shortUserString (tank.shortUserString
? strings[tank.shortUserString] ? strings[tank.shortUserString]
: undefined) ?? strings[tank.userString], : undefined) ?? strings[tank.userString],
nameFull: strings[tank.userString], name_full: strings[tank.userString],
nation, nation,
type: tankTags.includes('collectible') type: tankTags.includes('collectible')
? TankType.COLLECTOR ? TankType.COLLECTOR
: (typeof tank.price === 'number' ? false : 'gold' in tank.price) : (typeof tank.price === 'number' ? false : 'gold' in tank.price)
? TankType.PREMIUM ? TankType.PREMIUM
: TankType.RESEARCHABLE, : TankType.RESEARCHABLE,
tier: tank.level as Tier, tier: (tank.level - 1) as Tier,
class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass], class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass],
testing: tankTags.includes('testTank'), testing: tankTags.includes('testTank'),
deprecated: tankTags.includes('deprecated'), deprecated: tankTags.includes('deprecated'),
price: tankPrice, price: tankPrice,
camouflageStill: tankDefinition.root.invisibility.still, camouflage_still: tankDefinition.root.invisibility.still,
camouflageMoving: tankDefinition.root.invisibility.moving, camouflage_moving: tankDefinition.root.invisibility.moving,
camouflageOnFire: tankDefinition.root.invisibility.firePenalty, camouflage_onFire: tankDefinition.root.invisibility.firePenalty,
turrets: [], turrets: [],
engines: [], engines: [],
tracks: [], tracks: [],
@@ -919,22 +919,23 @@ export async function definitions() {
if ( if (
tankDefinitions.tanks[tankId].name === tankDefinitions.tanks[tankId].name ===
tankDefinitions.tanks[tankId].nameFull tankDefinitions.tanks[tankId].name_full
) { ) {
delete tankDefinitions.tanks[tankId].nameFull; delete tankDefinitions.tanks[tankId].name_full;
} }
modelDefinitions.models[tankId] = { modelDefinitions.models[tankId] = {
armor: hullArmor, armor: hullArmor,
turretOrigin: vector3TupleToBlitzkit(turretOrigin), turret_origin: vector3TupleToBlitzkit(turretOrigin),
initialTurretRotation: tankDefinition.root.hull.turretInitialRotation initial_turret_rotation: tankDefinition.root.hull
.turretInitialRotation
? { ? {
yaw: tankDefinition.root.hull.turretInitialRotation.yaw, yaw: tankDefinition.root.hull.turretInitialRotation.yaw,
pitch: tankDefinition.root.hull.turretInitialRotation.pitch, pitch: tankDefinition.root.hull.turretInitialRotation.pitch,
roll: tankDefinition.root.hull.turretInitialRotation.roll, roll: tankDefinition.root.hull.turretInitialRotation.roll,
} }
: undefined, : undefined,
boundingBox: { bounding_box: {
min: vector3TupleToBlitzkit(tankParameters.collision.hull.bbox.min), min: vector3TupleToBlitzkit(tankParameters.collision.hull.bbox.min),
max: vector3TupleToBlitzkit(tankParameters.collision.hull.bbox.max), max: vector3TupleToBlitzkit(tankParameters.collision.hull.bbox.max),
}, },
@@ -958,13 +959,13 @@ export async function definitions() {
id: trackId, id: trackId,
weight: track.weight, weight: track.weight,
name: strings[track.userString], name: strings[track.userString],
traverseSpeed: track.rotationSpeed, traverse_speed: track.rotationSpeed,
dispersionMove: track.shotDispersionFactors.vehicleMovement, dispersion_move: track.shotDispersionFactors.vehicleMovement,
dispersionTraverse: track.shotDispersionFactors.vehicleRotation, dispersion_traverse: track.shotDispersionFactors.vehicleRotation,
resistanceHard: terrainResistances[0], resistance_hard: terrainResistances[0],
resistanceMedium: terrainResistances[1], resistance_medium: terrainResistances[1],
resistanceSoft: terrainResistances[2], resistance_soft: terrainResistances[2],
tier: track.level as Tier, tier: (track.level - 1) as Tier,
unlocks: resolveUnlocks(track.unlocks), unlocks: resolveUnlocks(track.unlocks),
}); });
@@ -986,8 +987,8 @@ export async function definitions() {
tankDefinitions.tanks[tankId].engines.push({ tankDefinitions.tanks[tankId].engines.push({
id: engineId, id: engineId,
name: strings[engineListEntry.userString], name: strings[engineListEntry.userString],
fireChance: engineListEntry.fireStartingChance, fire_chance: engineListEntry.fireStartingChance,
tier: engineListEntry.level as Tier, tier: (engineListEntry.level - 1) as Tier,
weight: engineListEntry.weight, weight: engineListEntry.weight,
power: engineListEntry.power, power: engineListEntry.power,
unlocks: resolveUnlocks(engine.unlocks), unlocks: resolveUnlocks(engine.unlocks),
@@ -1041,30 +1042,30 @@ export async function definitions() {
tankDefinitions.tanks[tankId].turrets.push({ tankDefinitions.tanks[tankId].turrets.push({
id: turretId, id: turretId,
traverseSpeed: turret.rotationSpeed, traverse_speed: turret.rotationSpeed,
name: name:
strings[turret.userString] ?? strings[turret.userString] ??
turretKey turretKey
.replaceAll('_', ' ') .replaceAll('_', ' ')
.replace(/^(Turret ([0-9] )?)+/, ''), .replace(/^(Turret ([0-9] )?)+/, ''),
tier: turret.level as Tier, tier: (turret.level - 1) as Tier,
guns: [], guns: [],
health: turret.maxHealth, health: turret.maxHealth,
viewRange: turret.circularVisionRadius, view_range: turret.circularVisionRadius,
weight: turret.weight, weight: turret.weight,
unlocks: resolveUnlocks(turret.unlocks), unlocks: resolveUnlocks(turret.unlocks),
}); });
modelDefinitions.models[tankId].turrets[turretId] = { modelDefinitions.models[tankId].turrets[turretId] = {
armor: turretArmor, armor: turretArmor,
gunOrigin: vector3TupleToBlitzkit(gunOrigin), gun_origin: vector3TupleToBlitzkit(gunOrigin),
modelId: turretModel, model_id: turretModel,
yaw: yaw:
-turretYaw[0] + turretYaw[1] === 360 -turretYaw[0] + turretYaw[1] === 360
? undefined ? undefined
: { min: turretYaw[0], max: turretYaw[1] }, : { min: turretYaw[0], max: turretYaw[1] },
guns: {}, guns: {},
boundingBox: { bounding_box: {
min: vector3TupleToBlitzkit( min: vector3TupleToBlitzkit(
tankParameters.collision[ tankParameters.collision[
parsePath( parsePath(
@@ -1157,25 +1158,25 @@ export async function definitions() {
const base = { const base = {
id: gunId, id: gunId,
weight: gunListEntry.weight, weight: gunListEntry.weight,
rotationSpeed: gunListEntry.rotationSpeed, rotation_speed: gunListEntry.rotationSpeed,
name: gunName, name: gunName,
tier: gunListEntry.level as Tier, tier: (gunListEntry.level - 1) as Tier,
shells: [], shells: [],
camouflageLoss: camouflage_loss:
typeof gun.invisibilityFactorAtShot === 'number' typeof gun.invisibilityFactorAtShot === 'number'
? gun.invisibilityFactorAtShot ? gun.invisibilityFactorAtShot
: gun.invisibilityFactorAtShot.at(-1)!, : gun.invisibilityFactorAtShot.at(-1)!,
aimTime: gun.aimingTime ?? gunListEntry.aimingTime, aim_time: gun.aimingTime ?? gunListEntry.aimingTime,
dispersionBase: dispersion_base:
gun.shotDispersionRadius ?? gunListEntry.shotDispersionRadius, gun.shotDispersionRadius ?? gunListEntry.shotDispersionRadius,
dispersionDamaged: shotDispersionFactors.whileGunDamaged, dispersion_damaged: shotDispersionFactors.whileGunDamaged,
dispersionShot: shotDispersionFactors.afterShot, dispersion_shot: shotDispersionFactors.afterShot,
dispersionTraverse: shotDispersionFactors.turretRotation, dispersion_traverse: shotDispersionFactors.turretRotation,
unlocks: resolveUnlocks(gun.unlocks), unlocks: resolveUnlocks(gun.unlocks),
} satisfies GunDefinitionBase; } satisfies GunDefinitionBase;
tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({ tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({
gunType: gun_type:
gunType === 'regular' gunType === 'regular'
? { ? {
$case: 'regular', $case: 'regular',
@@ -1186,26 +1187,26 @@ export async function definitions() {
} }
: gunType === 'autoReloader' : gunType === 'autoReloader'
? { ? {
$case: 'autoReloader', $case: 'auto_reloader',
value: { value: {
base, base,
extension: { extension: {
intraClip: 60 / gun.clip!.rate, intra_clip: 60 / gun.clip!.rate,
shellCount: gunClipCount, shell_count: gunClipCount,
shellReloads: gun shell_reloads: gun
.pumpGunReloadTimes!.split(' ') .pumpGunReloadTimes!.split(' ')
.map(Number), .map(Number),
}, },
}, },
} }
: { : {
$case: 'autoLoader', $case: 'auto_loader',
value: { value: {
base, base,
extension: { extension: {
intraClip: 60 / gun.clip!.rate, intra_clip: 60 / gun.clip!.rate,
clipReload: gun.reloadTime, clip_reload: gun.reloadTime,
shellCount: gunClipCount, shell_count: gunClipCount,
}, },
}, },
}, },
@@ -1213,7 +1214,7 @@ export async function definitions() {
modelDefinitions.models[tankId].turrets[turretId].guns[gunId] = { modelDefinitions.models[tankId].turrets[turretId].guns[gunId] = {
armor: gunArmor, armor: gunArmor,
modelId: gunModel, model_id: gunModel,
mask, mask,
thickness: thickness:
gun.armor.gun === undefined gun.armor.gun === undefined
@@ -1256,17 +1257,17 @@ export async function definitions() {
tankDefinitions.tanks[tankId].turrets[turretIndex].guns[ tankDefinitions.tanks[tankId].turrets[turretIndex].guns[
gunIndex gunIndex
].gunType!.value.base.shells.push({ ].gun_type!.value.base.shells.push({
id: shellId, id: shellId,
name: shellName, name: shellName,
velocity: gunShellEntry.speed, velocity: gunShellEntry.speed,
armorDamage: shell.damage.armor, armor_damage: shell.damage.armor,
moduleDamage: shell.damage.devices, module_damage: shell.damage.devices,
caliber: shell.caliber, caliber: shell.caliber,
normalization: shell.normalizationAngle, normalization: shell.normalizationAngle,
ricochet: shell.ricochetAngle, ricochet: shell.ricochetAngle,
type: blitzShellKindToBlitzkit[shell.kind], type: blitzShellKindToBlitzkit[shell.kind],
explosionRadius: explosion_radius:
shell.kind === 'HIGH_EXPLOSIVE' shell.kind === 'HIGH_EXPLOSIVE'
? (shell.explosionRadius ?? 0) ? (shell.explosionRadius ?? 0)
: undefined, : undefined,
@@ -1341,11 +1342,11 @@ export async function definitions() {
Object.values(tankDefinitions.tanks[tankId].turrets).forEach( Object.values(tankDefinitions.tanks[tankId].turrets).forEach(
(turret) => { (turret) => {
turret.researchCost = turretXps.get(turret.id); turret.research_cost = turretXps.get(turret.id);
Object.values(turret.guns).forEach((gunRaw) => { Object.values(turret.guns).forEach((gunRaw) => {
gunRaw.gunType!.value.base.researchCost = gunXps.get( gunRaw.gun_type!.value.base.research_cost = gunXps.get(
gunRaw.gunType!.value.base.id, gunRaw.gun_type!.value.base.id,
); );
}); });
}, },
@@ -1353,19 +1354,19 @@ export async function definitions() {
Object.values(tankDefinitions.tanks[tankId].engines).forEach( Object.values(tankDefinitions.tanks[tankId].engines).forEach(
(engine) => { (engine) => {
engine.researchCost = engineXps.get(engine.id); engine.research_cost = engineXps.get(engine.id);
}, },
); );
Object.values(tankDefinitions.tanks[tankId].tracks).forEach((track) => { Object.values(tankDefinitions.tanks[tankId].tracks).forEach((track) => {
track.researchCost = trackXps.get(track.id); track.research_cost = trackXps.get(track.id);
}); });
} }
}), }),
); );
Object.values(tankDefinitions.tanks).forEach((tank) => { Object.values(tankDefinitions.tanks).forEach((tank) => {
tank.researchCost = tankXps.get(tank.id); tank.research_cost = tankXps.get(tank.id);
}); });
Object.values(tankDefinitions.tanks).forEach((tank) => { Object.values(tankDefinitions.tanks).forEach((tank) => {
@@ -1411,7 +1412,7 @@ export async function definitions() {
const entry: Consumable = { const entry: Consumable = {
id: consumable.id, id: consumable.id,
gameModeExclusive: 'gameModeFilter' in consumable, game_mode_exclusive: 'gameModeFilter' in consumable,
cooldown: consumable.script.cooldown, cooldown: consumable.script.cooldown,
duration: consumable.script.duration, duration: consumable.script.duration,
name: name:
@@ -1426,20 +1427,20 @@ export async function definitions() {
const includeRaw = consumable.vehicleFilter?.include.vehicle; const includeRaw = consumable.vehicleFilter?.include.vehicle;
const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle; const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle;
if (!entry.gameModeExclusive) { if (!entry.game_mode_exclusive) {
if (includeRaw) { if (includeRaw) {
entry.include = []; entry.include = [];
if ('minLevel' in includeRaw) { if ('minLevel' in includeRaw) {
entry.include.push({ entry.include.push({
filterType: { filter_type: {
$case: 'tiers', $case: 'tiers',
value: { min: includeRaw.minLevel, max: includeRaw.maxLevel }, value: { min: includeRaw.minLevel, max: includeRaw.maxLevel },
}, },
}); });
} else if ('name' in includeRaw) { } else if ('name' in includeRaw) {
entry.include.push({ entry.include.push({
filterType: { filter_type: {
$case: 'ids', $case: 'ids',
value: { value: {
ids: includeRaw.name.split(/ +/).map((key) => { ids: includeRaw.name.split(/ +/).map((key) => {
@@ -1452,7 +1453,7 @@ export async function definitions() {
if (consumable.vehicleFilter?.include.nations) { if (consumable.vehicleFilter?.include.nations) {
entry.include.push({ entry.include.push({
filterType: { filter_type: {
$case: 'nations', $case: 'nations',
value: { value: {
nations: consumable.vehicleFilter.include.nations.split(' '), nations: consumable.vehicleFilter.include.nations.split(' '),
@@ -1467,7 +1468,7 @@ export async function definitions() {
if ('name' in excludeRaw) { if ('name' in excludeRaw) {
entry.exclude!.push({ entry.exclude!.push({
filterType: { filter_type: {
$case: 'ids', $case: 'ids',
value: { value: {
ids: excludeRaw.name.split(/ +/).map((key) => { ids: excludeRaw.name.split(/ +/).map((key) => {
@@ -1478,7 +1479,7 @@ export async function definitions() {
}); });
} else if ('extendedTags' in excludeRaw) { } else if ('extendedTags' in excludeRaw) {
entry.exclude!.push({ entry.exclude!.push({
filterType: { filter_type: {
$case: 'categories', $case: 'categories',
value: { value: {
categories: excludeRaw.extendedTags categories: excludeRaw.extendedTags
@@ -1496,7 +1497,7 @@ export async function definitions() {
if (consumable.vehicleFilter?.exclude?.nations) { if (consumable.vehicleFilter?.exclude?.nations) {
entry.exclude!.push({ entry.exclude!.push({
filterType: { filter_type: {
$case: 'nations', $case: 'nations',
value: { value: {
nations: consumable.vehicleFilter.exclude.nations.split(' '), nations: consumable.vehicleFilter.exclude.nations.split(' '),
@@ -1515,7 +1516,7 @@ export async function definitions() {
id: provision.id, id: provision.id,
exclude: [], exclude: [],
include: [], include: [],
gameModeExclusive: 'gameModeFilter' in provision, game_mode_exclusive: 'gameModeFilter' in provision,
name: name:
strings[provision.userString] ?? strings[provision.userString] ??
missingStrings[provision.userString] ?? missingStrings[provision.userString] ??
@@ -1526,13 +1527,13 @@ export async function definitions() {
const includeRaw = provision.vehicleFilter?.include.vehicle; const includeRaw = provision.vehicleFilter?.include.vehicle;
const excludeRaw = provision.vehicleFilter?.exclude?.vehicle; const excludeRaw = provision.vehicleFilter?.exclude?.vehicle;
if (!entry.gameModeExclusive) { if (!entry.game_mode_exclusive) {
if (includeRaw) { if (includeRaw) {
entry.include = []; entry.include = [];
if ('minLevel' in includeRaw) { if ('minLevel' in includeRaw) {
entry.include.push({ entry.include.push({
filterType: { filter_type: {
$case: 'tiers', $case: 'tiers',
value: { value: {
min: includeRaw.minLevel, min: includeRaw.minLevel,
@@ -1542,7 +1543,7 @@ export async function definitions() {
}); });
} else if ('name' in includeRaw) { } else if ('name' in includeRaw) {
entry.include.push({ entry.include.push({
filterType: { filter_type: {
$case: 'ids', $case: 'ids',
value: { value: {
ids: includeRaw.name.split(/ +/).map((key) => { ids: includeRaw.name.split(/ +/).map((key) => {
@@ -1555,7 +1556,7 @@ export async function definitions() {
if (provision.vehicleFilter?.include.nations) { if (provision.vehicleFilter?.include.nations) {
entry.include.push({ entry.include.push({
filterType: { filter_type: {
$case: 'nations', $case: 'nations',
value: { value: {
nations: provision.vehicleFilter.include.nations.split(' '), nations: provision.vehicleFilter.include.nations.split(' '),
@@ -1570,7 +1571,7 @@ export async function definitions() {
if ('name' in excludeRaw) { if ('name' in excludeRaw) {
entry.exclude!.push({ entry.exclude!.push({
filterType: { filter_type: {
$case: 'ids', $case: 'ids',
value: { value: {
ids: excludeRaw.name ids: excludeRaw.name
@@ -1581,7 +1582,7 @@ export async function definitions() {
}); });
} else if ('extendedTags' in excludeRaw) { } else if ('extendedTags' in excludeRaw) {
entry.exclude!.push({ entry.exclude!.push({
filterType: { filter_type: {
$case: 'categories', $case: 'categories',
value: { value: {
categories: excludeRaw.extendedTags categories: excludeRaw.extendedTags
@@ -1599,7 +1600,7 @@ export async function definitions() {
if (provision.vehicleFilter?.exclude?.nations) { if (provision.vehicleFilter?.exclude?.nations) {
entry.exclude!.push({ entry.exclude!.push({
filterType: { filter_type: {
$case: 'nations', $case: 'nations',
value: { value: {
nations: provision.vehicleFilter.exclude.nations.split(' '), nations: provision.vehicleFilter.exclude.nations.split(' '),