IT IS WORKING!!!!!

This commit is contained in:
kvan7
2026-06-20 10:46:09 -05:00
parent 8eddedf0d1
commit 635204c668
2 changed files with 41 additions and 5 deletions
+33 -3
View File
@@ -7,14 +7,22 @@ import {
OTHER_PSEUDO_STATS,
QUALITY_STATS,
} from "./calc-q20";
import { ARMOUR, WEAPON } from "./meta";
export function recalculateItemProperties(
newItem: ParsedItem,
oldItem: ParsedItem,
) {
const { category } = newItem;
const weaponOrArmour = isArmourOrWeaponOrCaster(category);
if (weaponOrArmour === undefined || weaponOrArmour === "caster") return;
if (newItem.category !== oldItem.category || !newItem.category) return;
if (ARMOUR.has(newItem.category)) {
recalculateArmourProperties(newItem, oldItem);
}
if (WEAPON.has(newItem.category)) {
recalculateWeaponProperties(newItem, oldItem);
}
}
function recalculateWeaponProperties(newItem: ParsedItem, oldItem: ParsedItem) {
if (newItem.weaponPHYSICAL) {
const base = calcBase(
oldItem,
@@ -24,6 +32,7 @@ export function recalculateItemProperties(
const total = calcTotal(base, newItem, QUALITY_STATS.PHYSICAL_DAMAGE);
newItem.weaponPHYSICAL = total;
}
if (newItem.weaponAS) {
const base = calcBase(
oldItem,
@@ -39,6 +48,9 @@ export function recalculateItemProperties(
);
newItem.weaponAS = total;
}
}
function recalculateArmourProperties(newItem: ParsedItem, oldItem: ParsedItem) {
if (newItem.armourAR) {
const base = calcBase(oldItem, oldItem.armourAR, QUALITY_STATS.ARMOUR);
const total = calcTotal(base, newItem, QUALITY_STATS.ARMOUR);
@@ -58,6 +70,24 @@ export function recalculateItemProperties(
const total = calcTotal(base, newItem, QUALITY_STATS.ENERGY_SHIELD);
newItem.armourES = total;
}
if (newItem.armourRW) {
const base = calcBase(
oldItem,
oldItem.armourRW,
QUALITY_STATS.ENERGY_SHIELD,
);
const total = calcTotal(base, newItem, QUALITY_STATS.ENERGY_SHIELD);
newItem.armourRW = total;
}
if (newItem.armourBLOCK) {
const base = calcBase(
oldItem,
oldItem.armourBLOCK,
QUALITY_STATS.ENERGY_SHIELD,
);
const total = calcTotal(base, newItem, QUALITY_STATS.ENERGY_SHIELD);
newItem.armourBLOCK = total;
}
}
export function applyEleAugment(
@@ -12,6 +12,7 @@ import { AppConfig } from "@/web/Config";
import { PriceCheckWidget } from "@/web/overlay/widgets";
import { StatFilter } from "@/web/price-check/filters/interfaces";
import { initUiModFilters } from "../filters/create-stat-filters";
import { recalculateItemProperties } from "@/parser/calc-base";
export function getCategoryGroups(
augments: AugmentGroup<BaseType>,
@@ -45,6 +46,9 @@ export function useAugment(
throw new Error("Augment index out of bounds");
}
// deep copy
const oldItem = JSON.parse(JSON.stringify(item)) as ParsedItem;
// remove old augment stats from item
item.newMods = item.newMods.filter(
(mod) => !INTERNAL_AUGMENT_TYPES.has(mod.info.type),
@@ -54,9 +58,9 @@ export function useAugment(
);
// add augment
item.augmentSockets.augments[index] = augment;
item.augmentSockets!.augments[index] = augment;
// add augment stat to item
for (const thisAugment of item.augmentSockets.augments) {
for (const thisAugment of item.augmentSockets!.augments) {
if (!thisAugment) continue;
const modInfo = {
// need to keep pre-existing ones marked as non-added
@@ -76,6 +80,8 @@ export function useAugment(
// need to fix the filters now
console.log(stats);
recalculateItemProperties(item, oldItem);
const config = AppConfig<PriceCheckWidget>("price-check")!;
stats = initUiModFilters(item, {