mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: prettier
This commit is contained in:
1 parent
6a92b3ae80
commit
089d0e9682
4 files changed
+47
-15
No files matched your search
@@ -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.",
|
"tank_seo_description": "%s1 armor, statistics, equipment, provisions, and more. %s2 DPM, %s3hp alpha, %s4mm penetration, %s5kph top speed, %s6hp health.",
|
||||||
|
|
||||||
"visualizers": {
|
"visualizers": {
|
||||||
|
"assault": {
|
||||||
|
"title": "Assault shells"
|
||||||
|
},
|
||||||
|
|
||||||
"rotator": {
|
"rotator": {
|
||||||
"hull": "Hull",
|
"hull": "Hull",
|
||||||
"turret": "Turret",
|
"turret": "Turret",
|
||||||
|
|||||||
+36
-14
@@ -1,15 +1,33 @@
|
|||||||
import type { AssaultRanges } from '@blitzkit/core';
|
import type { AssaultRanges } from '@blitzkit/core';
|
||||||
|
import { literals } from '@blitzkit/i18n';
|
||||||
import { Box, Card, Flex, Text } from '@radix-ui/themes';
|
import { Box, Card, Flex, Text } from '@radix-ui/themes';
|
||||||
import { clamp } from 'three/src/math/MathUtils.js';
|
import { clamp } from 'three/src/math/MathUtils.js';
|
||||||
|
import type { TankCharacteristics } from '../../../../../../../core/blitzkit/tankCharacteristics';
|
||||||
import { Var } from '../../../../../../../core/radix/var';
|
import { Var } from '../../../../../../../core/radix/var';
|
||||||
|
import { useLocale } from '../../../../../../../hooks/useLocale';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
ranges: AssaultRanges;
|
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 (
|
return (
|
||||||
<Card variant="classic" style={{ aspectRatio: '1 / 1' }}>
|
<Card mb="6" variant="classic" style={{ aspectRatio: '1 / 1' }}>
|
||||||
<Flex
|
<Flex
|
||||||
position="absolute"
|
position="absolute"
|
||||||
top="0"
|
top="0"
|
||||||
@@ -19,7 +37,7 @@ export function AssaultRangesVisualizer({ ranges }: Props) {
|
|||||||
direction="column"
|
direction="column"
|
||||||
>
|
>
|
||||||
<Text m="3" size="2" color="gray">
|
<Text m="3" size="2" color="gray">
|
||||||
Assault shell damage
|
{strings.website.tools.tankopedia.visualizers.assault.title}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Flex
|
<Flex
|
||||||
@@ -31,8 +49,8 @@ export function AssaultRangesVisualizer({ ranges }: Props) {
|
|||||||
flexGrow="1"
|
flexGrow="1"
|
||||||
>
|
>
|
||||||
<Flex flexGrow="1">
|
<Flex flexGrow="1">
|
||||||
<Box position="relative" width={Var('space-7')}>
|
<Box position="relative" width={Var('space-8')}>
|
||||||
{ranges.ranges.map((range) => (
|
{ranges.map((range) => (
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -44,30 +62,32 @@ export function AssaultRangesVisualizer({ ranges }: Props) {
|
|||||||
size="1"
|
size="1"
|
||||||
wrap="nowrap"
|
wrap="nowrap"
|
||||||
>
|
>
|
||||||
{Math.round(range.factor * 100)}%
|
{literals(strings.common.units.hp, [
|
||||||
|
`${Math.round(stats.damageWithoutAssault * range.factor)}`,
|
||||||
|
])}
|
||||||
</Text>
|
</Text>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Flex flexGrow="1" align="end" position="relative">
|
<Flex flexGrow="1" align="end" position="relative">
|
||||||
{ranges.ranges.map((range, index) => {
|
{ranges.map((range, index) => {
|
||||||
const mix = clamp(1.5 * (range.factor - 1) + 1, 0, 1) * 100;
|
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 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}%)`;
|
const color1 = `color-mix(in hsl, ${Var('tomato-7')}, ${Var('jade-7')} ${mix}%)`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
width={`${(range.fakeDistance / sumFakeDistances) * 100}%`}
|
||||||
|
height={`${range.factor * 100}%`}
|
||||||
style={{
|
style={{
|
||||||
height: `${range.factor * 100}%`,
|
|
||||||
background: `linear-gradient(45deg, ${color1}, ${color0})`,
|
background: `linear-gradient(45deg, ${color1}, ${color0})`,
|
||||||
}}
|
}}
|
||||||
flexGrow={`${range.distance}`}
|
|
||||||
key={index}
|
key={index}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{ranges.ranges.map((range, index) => (
|
{ranges.map((range, index) => (
|
||||||
<Box
|
<Box
|
||||||
key={index}
|
key={index}
|
||||||
position="absolute"
|
position="absolute"
|
||||||
@@ -84,13 +104,13 @@ export function AssaultRangesVisualizer({ ranges }: Props) {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex ml="7" height={Var('space-7')}>
|
<Flex ml="8" height={Var('space-7')}>
|
||||||
{ranges.ranges.map((range, index) => (
|
{ranges.map((range, index) => (
|
||||||
<Box
|
<Box
|
||||||
position="relative"
|
position="relative"
|
||||||
key={index}
|
key={index}
|
||||||
|
width={`${(range.fakeDistance / sumFakeDistances) * 100}%`}
|
||||||
height="100%"
|
height="100%"
|
||||||
flexGrow={`${range.distance}`}
|
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
size="1"
|
size="1"
|
||||||
@@ -103,7 +123,9 @@ export function AssaultRangesVisualizer({ ranges }: Props) {
|
|||||||
writingMode: 'vertical-rl',
|
writingMode: 'vertical-rl',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{range.distance}m
|
{literals(strings.common.units.m, [
|
||||||
|
`${Math.round(range.distance)}`,
|
||||||
|
])}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
|
|||||||
+1
@@ -122,6 +122,7 @@ export function Firepower({ stats }: StatsAcceptorProps) {
|
|||||||
|
|
||||||
{gun.gun_type!.value.base.assault_ranges && (
|
{gun.gun_type!.value.base.assault_ranges && (
|
||||||
<AssaultRangesVisualizer
|
<AssaultRangesVisualizer
|
||||||
|
stats={stats}
|
||||||
ranges={gun.gun_type!.value.base.assault_ranges}
|
ranges={gun.gun_type!.value.base.assault_ranges}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -336,7 +336,9 @@ export function tankCharacteristics(
|
|||||||
stockTurret.weight +
|
stockTurret.weight +
|
||||||
stockGun.gun_type!.value.base.weight;
|
stockGun.gun_type!.value.base.weight;
|
||||||
const resolvedEnginePower = engine.power * enginePowerCoefficient;
|
const resolvedEnginePower = engine.power * enginePowerCoefficient;
|
||||||
const damageCoefficient = armorDamageCoefficient * assaultDamageCoefficient;
|
const damageCoefficientWithoutAssault = armorDamageCoefficient;
|
||||||
|
const damageCoefficient =
|
||||||
|
damageCoefficientWithoutAssault * assaultDamageCoefficient;
|
||||||
const dpm = resolveDpm(
|
const dpm = resolveDpm(
|
||||||
gun,
|
gun,
|
||||||
shell,
|
shell,
|
||||||
@@ -363,6 +365,8 @@ export function tankCharacteristics(
|
|||||||
return current;
|
return current;
|
||||||
}, null)!.index
|
}, null)!.index
|
||||||
: undefined;
|
: undefined;
|
||||||
|
const damageWithoutAssault =
|
||||||
|
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'
|
||||||
@@ -544,6 +548,7 @@ export function tankCharacteristics(
|
|||||||
caliber,
|
caliber,
|
||||||
penetration,
|
penetration,
|
||||||
damage,
|
damage,
|
||||||
|
damageWithoutAssault,
|
||||||
clipDamage,
|
clipDamage,
|
||||||
moduleDamage,
|
moduleDamage,
|
||||||
explosionRadius,
|
explosionRadius,
|
||||||
|
|||||||
Reference in new issue
Block a user