feat: cleanup some problems in inventories at daily reset
All checks were successful
Build / build (push) Successful in 46s
Build / build (pull_request) Successful in 1m32s

This commit is contained in:
Sainan 2025-04-21 19:30:43 +02:00
parent 218df461e1
commit a7e5425b55
2 changed files with 28 additions and 1 deletions

View File

@ -14,7 +14,12 @@ import {
ExportVirtuals
} from "warframe-public-export-plus";
import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "@/src/services/infestedFoundryService";
import { addMiscItems, allDailyAffiliationKeys, createLibraryDailyTask } from "@/src/services/inventoryService";
import {
addMiscItems,
allDailyAffiliationKeys,
cleanupInventory,
createLibraryDailyTask
} from "@/src/services/inventoryService";
import { logger } from "@/src/utils/logger";
import { catBreadHash } from "@/src/helpers/stringHelpers";
@ -79,6 +84,8 @@ export const inventoryController: RequestHandler = async (request, response) =>
}
}
cleanupInventory(inventory);
inventory.NextRefill = new Date((Math.trunc(Date.now() / 86400000) + 1) * 86400000);
await inventory.save();
}

View File

@ -1671,3 +1671,23 @@ export const setupKahlSyndicate = (inventory: TInventoryDatabaseDocument): void
Tag: "KahlSyndicate"
});
};
export const cleanupInventory = (inventory: TInventoryDatabaseDocument): void => {
let index = inventory.MiscItems.findIndex(x => x.ItemType == "");
if (index != -1) {
inventory.MiscItems.splice(index, 1);
}
index = inventory.Affiliations.findIndex(x => x.Tag == "KahlSyndicate");
if (index != -1 && !inventory.Affiliations[index].WeeklyMissions) {
logger.debug(`KahlSyndicate seems broken, removing it and setting up again`);
inventory.Affiliations.splice(index, 1);
setupKahlSyndicate(inventory);
}
const LibrarySyndicate = inventory.Affiliations.find(x => x.Tag == "LibrarySyndicate");
if (LibrarySyndicate && LibrarySyndicate.FreeFavorsEarned) {
logger.debug(`removing FreeFavorsEarned from LibrarySyndicate`);
LibrarySyndicate.FreeFavorsEarned = undefined;
}
};