Fix alt kits not having correct dmg multiplier

This commit is contained in:
Kalle
2023-12-03 15:04:42 +02:00
parent 723ceaba0e
commit eef708909d

View File

@@ -22,6 +22,10 @@ import type { CombineWith, DamageReceiver } from "../calculator-types";
import { removeDuplicates } from "~/utils/arrays";
import type { Damage } from "~/features/build-analyzer/analyzer-types";
const getNormalizedMainWeapondId = (id: MainWeaponId) => {
return id % 10 !== 0 ? ((id - 1) as MainWeaponId) : id;
};
export function damageTypeToMultipliers({
type,
weapon,
@@ -34,7 +38,9 @@ export function damageTypeToMultipliers({
for (const [key, objectDamagesObj] of Object.entries(objectDamages)) {
if (
weapon.type === "MAIN" &&
(objectDamagesObj.mainWeaponIds as MainWeaponId[]).includes(weapon.id)
(objectDamagesObj.mainWeaponIds as MainWeaponId[]).includes(
getNormalizedMainWeapondId(weapon.id),
)
) {
matchingKeys.push(key as keyof typeof objectDamages);
} else if (
@@ -77,8 +83,8 @@ function resolveRelevantKey({
// handle alt kits e.g. Splatteshot might have id 10 but Tentatek Splattershot has id 11
// but in the context of this function they are one and the same
const normalizedWeaponId =
weapon.type === "MAIN" && weapon.id % 10 !== 0
? ((weapon.id - 1) as MainWeaponId)
weapon.type === "MAIN"
? getNormalizedMainWeapondId(weapon.id)
: weapon.id;
if (weaponType !== weapon.type) continue;