fix: handle null in ArchonCrystalUpgrades
All checks were successful
Build / build (pull_request) Successful in 44s
Build / build (push) Successful in 1m28s

This commit is contained in:
Sainan 2025-06-13 13:49:23 +02:00
parent 71d1b6094c
commit 9a0f112420
3 changed files with 6 additions and 6 deletions

View File

@ -60,10 +60,10 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
const suit = inventory.Suits.id(request.SuitId.$oid)!;
const miscItemChanges: IMiscItem[] = [];
if (suit.ArchonCrystalUpgrades![request.Slot].Color) {
if (suit.ArchonCrystalUpgrades![request.Slot]?.Color) {
// refund shard
const shard = Object.entries(colorToShard).find(
([color]) => color == suit.ArchonCrystalUpgrades![request.Slot].Color
([color]) => color == suit.ArchonCrystalUpgrades![request.Slot]!.Color
)![1];
miscItemChanges.push({
ItemType: shard,
@ -83,9 +83,9 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
// >= 38.6.0
type =
archonCrystalRemovalResource[
suit.ArchonCrystalUpgrades![request.Slot].Color!.replace("_MYTHIC", "")
suit.ArchonCrystalUpgrades![request.Slot]!.Color!.replace("_MYTHIC", "")
];
count = suit.ArchonCrystalUpgrades![request.Slot].Color!.indexOf("_MYTHIC") != -1 ? 300 : 150;
count = suit.ArchonCrystalUpgrades![request.Slot]!.Color!.indexOf("_MYTHIC") != -1 ? 300 : 150;
}
inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == type)!.Count -= count;
}

View File

@ -8,7 +8,7 @@ export const popArchonCrystalUpgradeController: RequestHandler = async (req, res
const suit = inventory.Suits.id(req.query.oid as string);
if (suit && suit.ArchonCrystalUpgrades) {
suit.ArchonCrystalUpgrades = suit.ArchonCrystalUpgrades.filter(
x => x.UpgradeType != (req.query.type as string)
x => x && x.UpgradeType != (req.query.type as string)
);
await inventory.save();
res.end();

View File

@ -136,7 +136,7 @@ export interface IEquipmentDatabase {
DefensiveUpgrade?: string;
UpgradesExpiry?: Date;
UmbraDate?: Date; // related to scrapped "echoes of umbra" feature
ArchonCrystalUpgrades?: IArchonCrystalUpgrade[];
ArchonCrystalUpgrades?: (IArchonCrystalUpgrade | null)[];
Weapon?: ICrewShipWeapon;
Customization?: ICrewShipCustomization;
RailjackImage?: IFlavourItem;