fix: caliberated shells now affects stats once again

This commit is contained in:
TrèsAbhi committed 2024-02-11 14:24:26 -06:00
1 parent bc4fa60f67
commit efbb8376ef
1 file changed
+19 -10
@@ -2,6 +2,7 @@ import { Flex, Heading, Slider, Text, TextField } from '@radix-ui/themes';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { use, useEffect, useRef, useState } from 'react'; import { use, useEffect, useRef, useState } from 'react';
import { lerp } from 'three/src/math/MathUtils'; import { lerp } from 'three/src/math/MathUtils';
import { isExplosive } from '../../../../../../core/blitz/isExplosive';
import { resolveNearPenetration } from '../../../../../../core/blitz/resolveNearPenetration'; import { resolveNearPenetration } from '../../../../../../core/blitz/resolveNearPenetration';
import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions'; import { modelDefinitions } from '../../../../../../core/blitzkrieg/modelDefinitions';
import { normalizeBoundingBox } from '../../../../../../core/blitzkrieg/normalizeBoundingBox'; import { normalizeBoundingBox } from '../../../../../../core/blitzkrieg/normalizeBoundingBox';
@@ -33,7 +34,7 @@ export function Characteristics() {
); );
const weight = const weight =
tank.weight + engine.weight + track.weight + turret.weight + gun.weight; tank.weight + engine.weight + track.weight + turret.weight + gun.weight;
const weightMt = weight / 1000; const weightTons = weight / 1000;
const stockWeight = const stockWeight =
tank.weight + tank.weight +
stockEngine.weight + stockEngine.weight +
@@ -62,6 +63,11 @@ export function Characteristics() {
? 1.07 ? 1.07
: 1.05 : 1.05
: 1; : 1;
const hasCalibratedShellsBonus = hasCalibratedShells
? isExplosive(shell.type)
? 1.1
: 1.05
: 1;
/** /**
* TODO: * TODO:
@@ -158,7 +164,8 @@ export function Characteristics() {
decimals={0} decimals={0}
name="Penetration" name="Penetration"
> >
{resolveNearPenetration(shell.penetration)} {resolveNearPenetration(shell.penetration) *
hasCalibratedShellsBonus}
</InfoWithDelta> </InfoWithDelta>
)} )}
{typeof shell.penetration !== 'number' && ( {typeof shell.penetration !== 'number' && (
@@ -169,15 +176,17 @@ export function Characteristics() {
decimals={0} decimals={0}
name="At 0m" name="At 0m"
> >
{shell.penetration[0]} {shell.penetration[0] * hasCalibratedShellsBonus}
</InfoWithDelta> </InfoWithDelta>
<Info <Info
delta={ delta={
lerp( (lerp(
shell.penetration[0], shell.penetration[0],
shell.penetration[1], shell.penetration[1],
penetrationDistance / 500, penetrationDistance / 500,
) - shell.penetration[0] ) -
shell.penetration[0]) *
hasCalibratedShellsBonus
} }
indent indent
decimals={0} decimals={0}
@@ -187,7 +196,7 @@ export function Characteristics() {
shell.penetration[0], shell.penetration[0],
shell.penetration[1], shell.penetration[1],
penetrationDistance / 500, penetrationDistance / 500,
)} ) * hasCalibratedShellsBonus}
</Info> </Info>
<Flex align="center" gap="2" style={{ paddingLeft: 24 }}> <Flex align="center" gap="2" style={{ paddingLeft: 24 }}>
<Text>Distance</Text> <Text>Distance</Text>
@@ -357,7 +366,7 @@ export function Characteristics() {
<Info name="Power to weight ratio" unit="hp/mt" /> <Info name="Power to weight ratio" unit="hp/mt" />
<InfoWithDelta decimals={1} indent name="On hard terrain"> <InfoWithDelta decimals={1} indent name="On hard terrain">
{(engine.power / {(engine.power /
weightMt / weightTons /
(track.resistance.hard * (hasImprovedSuspension ? 0.75 : 1))) * (track.resistance.hard * (hasImprovedSuspension ? 0.75 : 1))) *
(hasEngineAccelerator (hasEngineAccelerator
? tank.type === 'light' || tank.type === 'medium' ? tank.type === 'light' || tank.type === 'medium'
@@ -367,7 +376,7 @@ export function Characteristics() {
</InfoWithDelta> </InfoWithDelta>
<InfoWithDelta decimals={1} indent name="On medium terrain"> <InfoWithDelta decimals={1} indent name="On medium terrain">
{(engine.power / {(engine.power /
weightMt / weightTons /
(track.resistance.medium * (hasImprovedSuspension ? 0.75 : 1))) * (track.resistance.medium * (hasImprovedSuspension ? 0.75 : 1))) *
(hasEngineAccelerator (hasEngineAccelerator
? tank.type === 'light' || tank.type === 'medium' ? tank.type === 'light' || tank.type === 'medium'
@@ -377,7 +386,7 @@ export function Characteristics() {
</InfoWithDelta> </InfoWithDelta>
<InfoWithDelta decimals={1} indent name="On soft terrain"> <InfoWithDelta decimals={1} indent name="On soft terrain">
{(engine.power / {(engine.power /
weightMt / weightTons /
(track.resistance.soft * (hasImprovedSuspension ? 0.75 : 1))) * (track.resistance.soft * (hasImprovedSuspension ? 0.75 : 1))) *
(hasEngineAccelerator (hasEngineAccelerator
? tank.type === 'light' || tank.type === 'medium' ? tank.type === 'light' || tank.type === 'medium'
@@ -391,7 +400,7 @@ export function Characteristics() {
unit="mt" unit="mt"
deltaType="lowerIsBetter" deltaType="lowerIsBetter"
> >
{weightMt} {weightTons}
</InfoWithDelta> </InfoWithDelta>
<Info name="Effective traverse speed" unit="°/s" /> <Info name="Effective traverse speed" unit="°/s" />
<InfoWithDelta decimals={1} indent name="On hard terrain"> <InfoWithDelta decimals={1} indent name="On hard terrain">