From e33fdffd99b3287b4fb56af8fc36f1f5830b115c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Thu, 1 Feb 2024 13:05:09 -0600 Subject: [PATCH] feat: advanced dpm --- .../[id]/components/Characteristics/index.tsx | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx index bb7315645..400b7cbd5 100644 --- a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx +++ b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx @@ -13,9 +13,8 @@ import { Info } from './components/Info'; export function Characteristics() { const awaitedModelDefinitions = use(modelDefinitions); - const { tank, turret, gun, shell, engine } = useDuel( - (state) => state.protagonist!, - ); + const { tank, turret, gun, engine } = useDuel((state) => state.protagonist!); + const shell = gun.shells[0]; const tankModelDefinition = awaitedModelDefinitions[tank.id]; const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const gunModelDefinition = turretModelDefinition.guns[gun.id]; @@ -80,13 +79,34 @@ export function Characteristics() { Fire {GUN_TYPE_NAMES[gun.type]} + + {dpm.toFixed(0)} + {gun.type === 'auto_reloader' && ( <> - TODO + {gun.reload.at(-1)! < gun.reload.at(-2)! + ? ( + (shell.damage.armor / + (gun.reload.at(-1)! + gun.interClip)) * + 60 + ).toFixed(0) + : ((shell.damage.armor / gun.reload[0]) * 60).toFixed(0)} - - TODO + + {gun.reload.at(-1)! < gun.reload.at(-2)! + ? ( + (shell.damage.armor / + (gun.reload.at(-1)! + gun.interClip)) * + (60 - + (gun.reload.slice(0, -1).length - 1) * gun.interClip) + + shell.damage.armor * gun.reload.slice(0, -1).length + ).toFixed(0) + : ( + (shell.damage.armor / (gun.reload[0] + gun.interClip)) * + (60 - (gun.reload.slice(1).length - 1) * gun.interClip) + + shell.damage.armor * gun.reload.slice(1).length + ).toFixed(0)} )} @@ -105,9 +125,6 @@ export function Characteristics() { {gun.reload.toFixed(2)} )} - - {dpm.toFixed(0)} - {shell.caliber}