feat: format all

This commit is contained in:
TrèsAbhi committed 2025-12-30 19:03:00 -06:00
1 parent faf802cf3d
commit 540e56a12d
1 file changed
+97 -91
@@ -19,9 +19,9 @@ import {
type TankDefinition, type TankDefinition,
type TrackDefinition, type TrackDefinition,
type TurretDefinition, type TurretDefinition,
} from '@blitzkit/core'; } from "@blitzkit/core";
import { coefficient } from '@blitzkit/core/src/blitzkit/coefficient'; import { coefficient } from "@blitzkit/core/src/blitzkit/coefficient";
import type { EquipmentMatrix } from '../../stores/duel'; import type { EquipmentMatrix } from "../../stores/duel";
export type TankCharacteristics = ReturnType<typeof tankCharacteristics>; export type TankCharacteristics = ReturnType<typeof tankCharacteristics>;
export type TankCharacteristicsKey = keyof TankCharacteristics; export type TankCharacteristicsKey = keyof TankCharacteristics;
@@ -76,7 +76,7 @@ export function tankCharacteristics(
tankModelDefinition: ModelDefinition; tankModelDefinition: ModelDefinition;
equipmentDefinitions: EquipmentDefinitions; equipmentDefinitions: EquipmentDefinitions;
provisionDefinitions: ProvisionDefinitions; provisionDefinitions: ProvisionDefinitions;
}, }
) { ) {
const preset = equipmentDefinitions.presets[tank.equipment_preset]; const preset = equipmentDefinitions.presets[tank.equipment_preset];
const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id];
@@ -86,7 +86,7 @@ export function tankCharacteristics(
return preset.slots.some((slot, index) => { return preset.slots.some((slot, index) => {
const choice = equipmentMatrix[Math.floor(index / 3)][index % 3]; const choice = equipmentMatrix[Math.floor(index / 3)][index % 3];
if (choice === 0) return false; if (choice === 0) return false;
const equipped = slot[choice === -1 ? 'left' : 'right']; const equipped = slot[choice === -1 ? "left" : "right"];
return equipped === id; return equipped === id;
}); });
} }
@@ -138,7 +138,7 @@ export function tankCharacteristics(
provisionDefinitions.provisions[provision].crew provisionDefinitions.provisions[provision].crew
? total + provisionDefinitions.provisions[provision].crew! / 100 ? total + provisionDefinitions.provisions[provision].crew! / 100
: total, : total,
0, 0
) + (hasImprovedVentilation ? 0.08 : 0); ) + (hasImprovedVentilation ? 0.08 : 0);
const commanderMastery = 1 + provisionCrewBonus; const commanderMastery = 1 + provisionCrewBonus;
const loaderMastery = const loaderMastery =
@@ -158,19 +158,19 @@ export function tankCharacteristics(
coefficient( coefficient(
[applyReactiveArmor && shell.type !== ShellType.HE, -0.27], [applyReactiveArmor && shell.type !== ShellType.HE, -0.27],
[applyDynamicArmor, -0.1], [applyDynamicArmor, -0.1],
[applySpallLiner && shell.type === ShellType.HE, -0.2], [applySpallLiner && shell.type === ShellType.HE, -0.2]
); );
const assaultDamageCoefficient = const assaultDamageCoefficient =
gun.assault_ranges && gun.assault_ranges.types.includes(shell.type) gun.assault_ranges && gun.assault_ranges.types.includes(shell.type)
? (gun.assault_ranges.ranges.find( ? gun.assault_ranges.ranges.find(
({ distance }) => distance >= assaultDistance, ({ distance }) => distance >= assaultDistance
)?.factor ?? 0) )?.factor ?? 0
: 1; : 1;
const moduleDamageCoefficient = coefficient([hasTungsten, 0.15]); const moduleDamageCoefficient = coefficient([hasTungsten, 0.15]);
const reloadCoefficient = const reloadCoefficient =
(coefficient([hasGunRammer, -0.05]) * (coefficient([hasGunRammer, -0.05]) *
coefficient([true, degressiveStat(loaderMastery)])) / coefficient([true, degressiveStat(loaderMastery)])) /
coefficient([hasAdrenaline && gun.gun_type!.$case === 'regular', 0.17]); coefficient([hasAdrenaline && gun.gun_type!.$case === "regular", 0.17]);
const penetrationCoefficient = coefficient([ const penetrationCoefficient = coefficient([
hasCalibratedShells, hasCalibratedShells,
resolvePenetrationCoefficient(true, shell.type) - 1, resolvePenetrationCoefficient(true, shell.type) - 1,
@@ -178,16 +178,16 @@ export function tankCharacteristics(
const healthCoefficient = coefficient( const healthCoefficient = coefficient(
[hasSandbagArmor, 0.03], [hasSandbagArmor, 0.03],
[hasEnhancedSandbagArmor, 0.06], [hasEnhancedSandbagArmor, 0.06],
[hasImprovedAssembly, 0.04], [hasImprovedAssembly, 0.04]
); );
const shellVelocityCoefficient = coefficient( const shellVelocityCoefficient = coefficient(
[hasSupercharger, 0.35], [hasSupercharger, 0.35],
[hasImprovedGunPowder, 0.3], [hasImprovedGunPowder, 0.3]
); );
const aimTimeCoefficient = const aimTimeCoefficient =
coefficient( coefficient(
[hasEnhancedGunLayingDrive, -0.15], [hasEnhancedGunLayingDrive, -0.15],
[hasReticleCalibration, -0.3], [hasReticleCalibration, -0.3]
) * coefficient([true, degressiveStat(gunnerMastery)]); ) * coefficient([true, degressiveStat(gunnerMastery)]);
const dispersionStillCoefficient = const dispersionStillCoefficient =
coefficient([hasRefinedGun, -0.15], [hasReticleCalibration, -0.3]) * coefficient([hasRefinedGun, -0.15], [hasReticleCalibration, -0.3]) *
@@ -198,19 +198,19 @@ export function tankCharacteristics(
]); ]);
const dispersionHullTraverseCoefficient = coefficient( const dispersionHullTraverseCoefficient = coefficient(
[hasVerticalStabilizer, -0.15], [hasVerticalStabilizer, -0.15],
[true, -crewSkills.smooth_turn / 100], [true, -crewSkills.smooth_turn / 100]
); );
const dispersionAfterShotCoefficient = coefficient( const dispersionAfterShotCoefficient = coefficient(
[hasVerticalStabilizer, -0.15], [hasVerticalStabilizer, -0.15],
[true, -crewSkills.soft_recoil / 100], [true, -crewSkills.soft_recoil / 100]
); );
const dispersionMovingCoefficient = coefficient( const dispersionMovingCoefficient = coefficient(
[hasVerticalStabilizer, -0.15], [hasVerticalStabilizer, -0.15],
[true, -crewSkills.smooth_driving / 100], [true, -crewSkills.smooth_driving / 100]
); );
const dispersionTurretTraverseCoefficient = coefficient( const dispersionTurretTraverseCoefficient = coefficient(
[hasVerticalStabilizer, -0.15], [hasVerticalStabilizer, -0.15],
[true, -crewSkills.smooth_turret * (2 / 100)], [true, -crewSkills.smooth_turret * (2 / 100)]
); );
const enginePowerCoefficient = coefficient( const enginePowerCoefficient = coefficient(
[ [
@@ -225,7 +225,7 @@ export function tankCharacteristics(
[hasStandardFuel, 0.03], [hasStandardFuel, 0.03],
[hasImprovedFuel, 0.1], [hasImprovedFuel, 0.1],
[hasGearOil, 0.03], [hasGearOil, 0.03],
[hasImprovedGearOil, 0.06], [hasImprovedGearOil, 0.06]
); );
const turretTraverseCoefficient = const turretTraverseCoefficient =
coefficient([hasStandardFuel, 0.03], [hasImprovedFuel, 0.1]) * coefficient([hasStandardFuel, 0.03], [hasImprovedFuel, 0.1]) *
@@ -234,12 +234,18 @@ export function tankCharacteristics(
coefficient( coefficient(
[hasImprovedControl, 0.11], [hasImprovedControl, 0.11],
[hasImprovedEnginePowerBoost, 0.01], [hasImprovedEnginePowerBoost, 0.01],
[true, crewSkills.virtuoso / 100], [true, crewSkills.virtuoso / 100]
) * coefficient([true, progressiveStat(driverMastery)]); ) * coefficient([true, progressiveStat(driverMastery)]);
const resistanceHardCoefficient = coefficient([hasImprovedSuspension, -0.2]) * coefficient([true, degressiveStat(driverMastery)]); const resistanceHardCoefficient =
const resistanceMediumCoefficient = coefficient([hasImprovedSuspension, -0.15]) * coefficient([true, degressiveStat(driverMastery)]); coefficient([hasImprovedSuspension, -0.2]) *
const resistanceSoftCoefficient = coefficient([hasImprovedSuspension, -0.3]) * coefficient([true, degressiveStat(driverMastery)]); coefficient([true, degressiveStat(driverMastery)]);
const resistanceMediumCoefficient =
coefficient([hasImprovedSuspension, -0.15]) *
coefficient([true, degressiveStat(driverMastery)]);
const resistanceSoftCoefficient =
coefficient([hasImprovedSuspension, -0.3]) *
coefficient([true, degressiveStat(driverMastery)]);
const viewRangeCoefficient = const viewRangeCoefficient =
coefficient([ coefficient([
@@ -247,22 +253,22 @@ export function tankCharacteristics(
tank.class === TankClass.HEAVY tank.class === TankClass.HEAVY
? 0.06 ? 0.06
: tank.class === TankClass.MEDIUM : tank.class === TankClass.MEDIUM
? 0.08 ? 0.08
: tank.class === TankClass.LIGHT : tank.class === TankClass.LIGHT
? 0.11 ? 0.11
: 0.04, : 0.04,
]) * coefficient([true, progressiveStat(commanderMastery)]); ]) * coefficient([true, progressiveStat(commanderMastery)]);
const fireChanceCoefficient = coefficient([hasProtectiveKit, -0.2]); const fireChanceCoefficient = coefficient([hasProtectiveKit, -0.2]);
const speedForwardsSum = sum( const speedForwardsSum = sum(
[hasImprovedEnginePowerBoost, 4], [hasImprovedEnginePowerBoost, 4],
[hasGearOil, 2], [hasGearOil, 2],
[hasImprovedGearOil, 4], [hasImprovedGearOil, 4]
); );
const speedBackwardsSum = sum( const speedBackwardsSum = sum(
[hasImprovedEnginePowerBoost, 8], [hasImprovedEnginePowerBoost, 8],
[hasGearOil, 2], [hasGearOil, 2],
[hasImprovedGearOil, 4], [hasImprovedGearOil, 4]
); );
const camouflageCoefficientMoving = sum( const camouflageCoefficientMoving = sum(
[ [
@@ -272,8 +278,8 @@ export function tankCharacteristics(
tank.class === TankClass.TANK_DESTROYER tank.class === TankClass.TANK_DESTROYER
? 0.04 ? 0.04
: tank.class === TankClass.HEAVY : tank.class === TankClass.HEAVY
? 0.03 ? 0.03
: 0.02, : 0.02,
]), ]),
], ],
[ [
@@ -281,11 +287,11 @@ export function tankCharacteristics(
tank.class === TankClass.HEAVY tank.class === TankClass.HEAVY
? 0.02 ? 0.02
: tank.class === TankClass.MEDIUM : tank.class === TankClass.MEDIUM
? 0.04 ? 0.04
: tank.class === TankClass.LIGHT : tank.class === TankClass.LIGHT
? 0.07 ? 0.07
: 0.1, : 0.1,
], ]
); );
const camouflageCoefficientStill = sum( const camouflageCoefficientStill = sum(
[ [
@@ -296,10 +302,10 @@ export function tankCharacteristics(
tank.class === TankClass.TANK_DESTROYER tank.class === TankClass.TANK_DESTROYER
? 0.04 ? 0.04
: tank.class === TankClass.HEAVY : tank.class === TankClass.HEAVY
? 0.03 ? 0.03
: 0.02, : 0.02,
], ],
[true, crewSkills.camouflage * (3 / 100)], [true, crewSkills.camouflage * (3 / 100)]
), ),
], ],
[ [
@@ -307,18 +313,18 @@ export function tankCharacteristics(
tank.class === TankClass.HEAVY tank.class === TankClass.HEAVY
? 0.04 ? 0.04
: tank.class === TankClass.MEDIUM : tank.class === TankClass.MEDIUM
? 0.08 ? 0.08
: tank.class === TankClass.LIGHT : tank.class === TankClass.LIGHT
? 0.14 ? 0.14
: 0.2, : 0.2,
], ]
); );
const size = normalizeBoundingBox( const size = normalizeBoundingBox(
unionBoundingBox( unionBoundingBox(
tankModelDefinition.bounding_box, tankModelDefinition.bounding_box,
turretModelDefinition.bounding_box, turretModelDefinition.bounding_box
), )
); );
const weightKg = const weightKg =
tank.weight + engine.weight + track.weight + turret.weight + gun.weight; tank.weight + engine.weight + track.weight + turret.weight + gun.weight;
@@ -338,14 +344,14 @@ export function tankCharacteristics(
shell, shell,
damageCoefficient, damageCoefficient,
reloadCoefficient, reloadCoefficient,
intraClipCoefficient, intraClipCoefficient
); );
const intraClip = const intraClip =
gun.gun_type?.$case === 'regular' gun.gun_type?.$case === "regular"
? undefined ? undefined
: gun.gun_type!.value.intra_clip * intraClipCoefficient; : gun.gun_type!.value.intra_clip * intraClipCoefficient;
const mostOptimalShellIndex = const mostOptimalShellIndex =
gun.gun_type!.$case === 'auto_reloader' gun.gun_type!.$case === "auto_reloader"
? gun.gun_type!.value.shell_reloads.reduce<null | { ? gun.gun_type!.value.shell_reloads.reduce<null | {
index: number; index: number;
reload: number; reload: number;
@@ -363,7 +369,7 @@ export function tankCharacteristics(
shell.armor_damage * damageCoefficientWithoutAssault; shell.armor_damage * damageCoefficientWithoutAssault;
const damage = shell.armor_damage * damageCoefficient; const damage = shell.armor_damage * damageCoefficient;
const dpmEffective = const dpmEffective =
gun.gun_type!.$case === 'auto_reloader' gun.gun_type!.$case === "auto_reloader"
? gun.gun_type!.value.shell_reloads[0] > ? gun.gun_type!.value.shell_reloads[0] >
gun.gun_type!.value.shell_reloads[1] + gun.gun_type!.value.intra_clip gun.gun_type!.value.shell_reloads[1] + gun.gun_type!.value.intra_clip
? ((armorDamageCoefficient * shell.armor_damage) / ? ((armorDamageCoefficient * shell.armor_damage) /
@@ -388,23 +394,23 @@ export function tankCharacteristics(
gun.gun_type!.value.shell_reloads.slice(1).length gun.gun_type!.value.shell_reloads.slice(1).length
: undefined; : undefined;
const shells = const shells =
gun.gun_type!.$case === 'regular' ? 1 : gun.gun_type!.value.shell_count; gun.gun_type!.$case === "regular" ? 1 : gun.gun_type!.value.shell_count;
const shellReloads = const shellReloads =
gun.gun_type!.$case === 'auto_reloader' gun.gun_type!.$case === "auto_reloader"
? gun.gun_type!.value.shell_reloads.map( ? gun.gun_type!.value.shell_reloads.map(
(reload) => reload * reloadCoefficient, (reload) => reload * reloadCoefficient
) )
: undefined; : undefined;
const shellReload = const shellReload =
gun.gun_type!.$case === 'auto_reloader' gun.gun_type!.$case === "auto_reloader"
? undefined ? undefined
: (gun.gun_type!.$case === 'regular' : (gun.gun_type!.$case === "regular"
? gun.gun_type!.value.reload ? gun.gun_type!.value.reload
: gun.gun_type!.value.clip_reload) * reloadCoefficient; : gun.gun_type!.value.clip_reload) * reloadCoefficient;
const caliber = shell.caliber; const caliber = shell.caliber;
const penetration = shell.penetration.near * penetrationCoefficient; const penetration = shell.penetration.near * penetrationCoefficient;
const clipDamage = const clipDamage =
gun.gun_type!.$case === 'regular' gun.gun_type!.$case === "regular"
? undefined ? undefined
: gun.gun_type!.value.shell_count * damage; : gun.gun_type!.value.shell_count * damage;
const moduleDamage = shell.module_damage * moduleDamageCoefficient; const moduleDamage = shell.module_damage * moduleDamageCoefficient;
@@ -598,45 +604,45 @@ export const characteristicsOrder: {
items: TankCharacteristicsKey[]; items: TankCharacteristicsKey[];
}[] = [ }[] = [
{ {
name: 'Firepower', name: "Firepower",
items: [ items: [
'gunType', "gunType",
'dpm', "dpm",
'shells', "shells",
'shellReload', "shellReload",
'shellReloads', "shellReloads",
'intraClip', "intraClip",
'penetration', "penetration",
'penetrationAt250m', "penetrationAt250m",
'damage', "damage",
'clipDamage', "clipDamage",
'moduleDamage', "moduleDamage",
'caliber', "caliber",
'shellNormalization', "shellNormalization",
'shellRicochet', "shellRicochet",
'shellVelocity', "shellVelocity",
'shellRange', "shellRange",
'shellCapacity', "shellCapacity",
'aimTime', "aimTime",
'dispersion', "dispersion",
'dispersionMoving', "dispersionMoving",
'dispersionHullTraversing', "dispersionHullTraversing",
'dispersionTurretTraversing', "dispersionTurretTraversing",
'dispersionShooting', "dispersionShooting",
'dispersionGunDamaged', "dispersionGunDamaged",
'gunDepression', "gunDepression",
'gunElevation', "gunElevation",
'gunFrontalDepression', "gunFrontalDepression",
'gunFrontalElevation', "gunFrontalElevation",
'gunRearDepression', "gunRearDepression",
'gunRearElevation', "gunRearElevation",
'azimuthLeft', "azimuthLeft",
'azimuthRight', "azimuthRight",
], ],
}, },
{ {
name: 'Crew', name: "Crew",
items: ['crewCount'], items: ["crewCount"],
}, },
]; ];