From 089d0e968218fab0ca1826702288faa7dc34a6af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 31 Jul 2025 20:40:02 -0500 Subject: [PATCH] feat: prettier --- packages/i18n/strings/en.json | 4 ++ .../AssaultRangesVisualizer/index.tsx | 50 +++++++++++++------ .../Characteristics/components/Firepower.tsx | 1 + .../src/core/blitzkit/tankCharacteristics.ts | 7 ++- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index 65bdf40fc..b752e8717 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -887,6 +887,10 @@ "tank_seo_description": "%s1 armor, statistics, equipment, provisions, and more. %s2 DPM, %s3hp alpha, %s4mm penetration, %s5kph top speed, %s6hp health.", "visualizers": { + "assault": { + "title": "Assault shells" + }, + "rotator": { "hull": "Hull", "turret": "Turret", diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/AssaultRangesVisualizer/index.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/AssaultRangesVisualizer/index.tsx index 69f2133c0..503ffe64c 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/AssaultRangesVisualizer/index.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/AssaultRangesVisualizer/index.tsx @@ -1,15 +1,33 @@ import type { AssaultRanges } from '@blitzkit/core'; +import { literals } from '@blitzkit/i18n'; import { Box, Card, Flex, Text } from '@radix-ui/themes'; import { clamp } from 'three/src/math/MathUtils.js'; +import type { TankCharacteristics } from '../../../../../../../core/blitzkit/tankCharacteristics'; import { Var } from '../../../../../../../core/radix/var'; +import { useLocale } from '../../../../../../../hooks/useLocale'; interface Props { ranges: AssaultRanges; + stats: TankCharacteristics; } -export function AssaultRangesVisualizer({ ranges }: Props) { +export function AssaultRangesVisualizer({ ranges: _ranges, stats }: Props) { + const maxDistance = Math.max( + ..._ranges.ranges.map((range) => range.distance), + ); + const ranges = _ranges.ranges.map((range) => ({ + factor: range.factor, + distance: range.distance, + fakeDistance: (2 / Math.PI) * Math.atan((4 * range.distance) / maxDistance), + })); + const sumFakeDistances = ranges.reduce( + (total, range) => total + range.fakeDistance, + 0, + ); + const { strings } = useLocale(); + return ( - + - Assault shell damage + {strings.website.tools.tankopedia.visualizers.assault.title} - - {ranges.ranges.map((range) => ( + + {ranges.map((range) => ( - {Math.round(range.factor * 100)}% + {literals(strings.common.units.hp, [ + `${Math.round(stats.damageWithoutAssault * range.factor)}`, + ])} ))} - {ranges.ranges.map((range, index) => { + {ranges.map((range, index) => { const mix = clamp(1.5 * (range.factor - 1) + 1, 0, 1) * 100; const color0 = `color-mix(in hsl, ${Var('tomato-9')}, ${Var('jade-9')} ${mix}%)`; const color1 = `color-mix(in hsl, ${Var('tomato-7')}, ${Var('jade-7')} ${mix}%)`; return ( ); })} - {ranges.ranges.map((range, index) => ( + {ranges.map((range, index) => ( - - {ranges.ranges.map((range, index) => ( + + {ranges.map((range, index) => ( - {range.distance}m + {literals(strings.common.units.m, [ + `${Math.round(range.distance)}`, + ])} ))} diff --git a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx index bd6ece543..a3cbb3efc 100644 --- a/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx +++ b/packages/website/src/components/Tankopedia/CharacteristicsSection/components/Characteristics/components/Firepower.tsx @@ -122,6 +122,7 @@ export function Firepower({ stats }: StatsAcceptorProps) { {gun.gun_type!.value.base.assault_ranges && ( )} diff --git a/packages/website/src/core/blitzkit/tankCharacteristics.ts b/packages/website/src/core/blitzkit/tankCharacteristics.ts index 954baae7f..e8e021203 100644 --- a/packages/website/src/core/blitzkit/tankCharacteristics.ts +++ b/packages/website/src/core/blitzkit/tankCharacteristics.ts @@ -336,7 +336,9 @@ export function tankCharacteristics( stockTurret.weight + stockGun.gun_type!.value.base.weight; const resolvedEnginePower = engine.power * enginePowerCoefficient; - const damageCoefficient = armorDamageCoefficient * assaultDamageCoefficient; + const damageCoefficientWithoutAssault = armorDamageCoefficient; + const damageCoefficient = + damageCoefficientWithoutAssault * assaultDamageCoefficient; const dpm = resolveDpm( gun, shell, @@ -363,6 +365,8 @@ export function tankCharacteristics( return current; }, null)!.index : undefined; + const damageWithoutAssault = + shell.armor_damage * damageCoefficientWithoutAssault; const damage = shell.armor_damage * damageCoefficient; const dpmEffective = gun.gun_type!.$case === 'auto_reloader' @@ -544,6 +548,7 @@ export function tankCharacteristics( caliber, penetration, damage, + damageWithoutAssault, clipDamage, moduleDamage, explosionRadius,