From f4b893dfa5fbc8ae390914eedef5b026cbde5435 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:16:34 +0300 Subject: [PATCH] Splat/Suction/Burst Bomb to damage table --- app/modules/analyzer/stats.ts | 11 +++++++++-- app/modules/analyzer/types.ts | 1 + app/routes/analyzer.tsx | 28 ++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/app/modules/analyzer/stats.ts b/app/modules/analyzer/stats.ts index cbfbbbf53..b11feb87e 100644 --- a/app/modules/analyzer/stats.ts +++ b/app/modules/analyzer/stats.ts @@ -8,6 +8,7 @@ import type { InkConsumeType, MainWeaponParams, StatFunctionInput, + SubWeaponParams, } from "./types"; import { DAMAGE_TYPE } from "./types"; import { INK_CONSUME_TYPES } from "./types"; @@ -238,7 +239,10 @@ function inkConsumeTypeToParamsKeys( } } -const damageTypeToParamsKey: Record = { +const damageTypeToParamsKey: Record< + DamageType, + keyof MainWeaponParams | keyof SubWeaponParams +> = { NORMAL_MIN: "DamageParam_ValueMin", NORMAL_MAX: "DamageParam_ValueMax", DIRECT: "DamageParam_ValueDirect", @@ -246,6 +250,7 @@ const damageTypeToParamsKey: Record = { FULL_CHARGE: "DamageParam_ValueFullCharge", MAX_CHARGE: "DamageParam_ValueMaxCharge", TAP_SHOT: "DamageParam_ValueMinCharge", + BOMB_NORMAL: "DistanceDamage", }; function damages(args: StatFunctionInput): AnalyzedBuild["stats"]["damages"] { @@ -253,7 +258,9 @@ function damages(args: StatFunctionInput): AnalyzedBuild["stats"]["damages"] { for (const type of DAMAGE_TYPE) { const key = damageTypeToParamsKey[type]; - const value = args.mainWeaponParams[key]; + const value = + args.mainWeaponParams[key as keyof MainWeaponParams] ?? + args.subWeaponParams[key as keyof SubWeaponParams]; if (Array.isArray(value)) { for (const subValue of value) { diff --git a/app/modules/analyzer/types.ts b/app/modules/analyzer/types.ts index cf68220fc..b9aef8f0e 100644 --- a/app/modules/analyzer/types.ts +++ b/app/modules/analyzer/types.ts @@ -141,6 +141,7 @@ export const DAMAGE_TYPE = [ "MAX_CHARGE", "TAP_SHOT", "DISTANCE", + "BOMB_NORMAL", ] as const; export type DamageType = typeof DAMAGE_TYPE[number]; diff --git a/app/routes/analyzer.tsx b/app/routes/analyzer.tsx index 747272cb6..34ee0f8f5 100644 --- a/app/routes/analyzer.tsx +++ b/app/routes/analyzer.tsx @@ -90,6 +90,7 @@ export default function BuildAnalyzerPage() { )} @@ -224,21 +225,25 @@ function StatCard({ function DamageTable({ values, isTripleShooter, + subWeaponId, }: { values: AnalyzedBuild["stats"]["damages"]; isTripleShooter: AnalyzedBuild["weapon"]["isTripleShooter"]; + subWeaponId: SubWeaponId; }) { - const { t } = useTranslation("analyzer"); + const { t } = useTranslation(["weapons", "analyzer"]); + + const showDistanceColumn = values.some((val) => val.distance); return ( <> - - - {values.some((val) => val.distance) && ( - + + + {showDistanceColumn && ( + )} @@ -248,18 +253,25 @@ function DamageTable({ ? `${val.value}+${val.value}+${val.value}` : val.value; + const typeRowName = val.type.startsWith("BOMB_") + ? t(`weapons:SUB_${subWeaponId}`) + : // xxx: maybe this could use a sub type where "BOMB_" starting are filtered out + t(`analyzer:damage.${val.type as "NORMAL_MIN"}`); + return ( - + - {val.distance && } + {showDistanceColumn && } ); })}
{t("damage.header.type")}{t("damage.header.damage")}{t("damage.header.distance")}{t("analyzer:damage.header.type")}{t("analyzer:damage.header.damage")}{t("analyzer:damage.header.distance")}
{t(`damage.${val.type}`)}{typeRowName} {damage}{" "} {val.shotsToSplat && ( - {t("damage.toSplat", { count: val.shotsToSplat })} + {t("analyzer:damage.toSplat", { + count: val.shotsToSplat, + })} )} {val.distance}{val.distance}