chore: get rid of instances of markModified #908

Merged
OrdisPrime merged 3 commits from yeet-markModified into main 2025-02-06 04:39:02 -08:00
4 changed files with 18 additions and 18 deletions

View File

@ -12,7 +12,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
const { Upgrade, LevelDiff, Cost, FusionPointCost } = artifactsData; const { Upgrade, LevelDiff, Cost, FusionPointCost } = artifactsData;
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
const { Upgrades, RawUpgrades } = inventory; const { Upgrades } = inventory;
const { ItemType, UpgradeFingerprint, ItemId } = Upgrade; const { ItemType, UpgradeFingerprint, ItemId } = Upgrade;
const safeUpgradeFingerprint = UpgradeFingerprint || '{"lvl":0}'; const safeUpgradeFingerprint = UpgradeFingerprint || '{"lvl":0}';
@ -32,13 +32,7 @@ export const artifactsController: RequestHandler = async (req, res) => {
ItemType ItemType
}) - 1; }) - 1;
const rawItemIndex = RawUpgrades.findIndex(rawUpgrade => rawUpgrade.ItemType === ItemType); addMods(inventory, [{ ItemType, ItemCount: -1 }]);
RawUpgrades[rawItemIndex].ItemCount--;
if (RawUpgrades[rawItemIndex].ItemCount > 0) {
inventory.markModified(`RawUpgrades.${rawItemIndex}.UpgradeFingerprint`);
} else {
RawUpgrades.splice(rawItemIndex, 1);
}
} }
if (!config.infiniteCredits) { if (!config.infiniteCredits) {

View File

@ -25,6 +25,7 @@ import {
ISettings, ISettings,
IInfestedFoundryDatabase, IInfestedFoundryDatabase,
IHelminthResource, IHelminthResource,
IMissionDatabase,
IConsumedSuit, IConsumedSuit,
IQuestStage, IQuestStage,
IQuestKeyDatabase, IQuestKeyDatabase,
@ -482,6 +483,15 @@ const helminthResourceSchema = new Schema<IHelminthResource>(
{ _id: false } { _id: false }
); );
const missionSchema = new Schema<IMissionDatabase>(
{
Tag: String,
Completes: { type: Number, default: 0 },
Tier: { type: Number, required: false }
},
{ _id: false }
);
const questProgressSchema = new Schema<IQuestStage>( const questProgressSchema = new Schema<IQuestStage>(
{ {
c: Number, c: Number,
@ -1010,7 +1020,7 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
CrewShipSalvagedWeapons: [Schema.Types.Mixed], CrewShipSalvagedWeapons: [Schema.Types.Mixed],
//Complete Mission\Quests //Complete Mission\Quests
Missions: [Schema.Types.Mixed], Missions: [missionSchema],
QuestKeys: [questKeysSchema], QuestKeys: [questKeysSchema],
ActiveQuest: { type: String, default: "/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain" }, //TODO: check after mission starting gear ActiveQuest: { type: String, default: "/Lotus/Types/Keys/VorsPrize/VorsPrizeQuestKeyChain" }, //TODO: check after mission starting gear
//item like DojoKey or Boss missions key //item like DojoKey or Boss missions key

View File

@ -906,7 +906,6 @@ export const addShipDecorations = (
if (itemIndex !== -1) { if (itemIndex !== -1) {
ShipDecorations[itemIndex].ItemCount += ItemCount; ShipDecorations[itemIndex].ItemCount += ItemCount;
inventory.markModified(`ShipDecorations.${itemIndex}.ItemCount`);
} else { } else {
ShipDecorations.push({ ItemCount, ItemType }); ShipDecorations.push({ ItemCount, ItemType });
} }
@ -921,7 +920,6 @@ export const addConsumables = (inventory: TInventoryDatabaseDocument, itemsArray
if (itemIndex !== -1) { if (itemIndex !== -1) {
Consumables[itemIndex].ItemCount += ItemCount; Consumables[itemIndex].ItemCount += ItemCount;
inventory.markModified(`Consumables.${itemIndex}.ItemCount`);
} else { } else {
Consumables.push({ ItemCount, ItemType }); Consumables.push({ ItemCount, ItemType });
} }
@ -967,7 +965,6 @@ export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: IT
if (itemIndex !== -1) { if (itemIndex !== -1) {
Recipes[itemIndex].ItemCount += ItemCount; Recipes[itemIndex].ItemCount += ItemCount;
inventory.markModified(`Recipes.${itemIndex}.ItemCount`);
} else { } else {
Recipes.push({ ItemCount, ItemType }); Recipes.push({ ItemCount, ItemType });
} }
@ -1006,7 +1003,6 @@ export const addFusionTreasures = (
if (itemIndex !== -1) { if (itemIndex !== -1) {
FusionTreasures[itemIndex].ItemCount += ItemCount; FusionTreasures[itemIndex].ItemCount += ItemCount;
inventory.markModified(`FusionTreasures.${itemIndex}.ItemCount`);
} else { } else {
FusionTreasures.push({ ItemCount, ItemType, Sockets }); FusionTreasures.push({ ItemCount, ItemType, Sockets });
} }
@ -1077,7 +1073,6 @@ export const addChallenges = (
if (itemIndex !== -1) { if (itemIndex !== -1) {
category[itemIndex].Progress += Progress; category[itemIndex].Progress += Progress;
inventory.markModified(`ChallengeProgress.${itemIndex}.ItemCount`);
} else { } else {
category.push({ Name, Progress }); category.push({ Name, Progress });
} }
@ -1090,7 +1085,6 @@ export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag,
if (itemIndex !== -1) { if (itemIndex !== -1) {
Missions[itemIndex].Completes += Completes; Missions[itemIndex].Completes += Completes;
inventory.markModified(`Missions.${itemIndex}.Completes`);
} else { } else {
Missions.push({ Tag, Completes }); Missions.push({ Tag, Completes });
} }
@ -1106,7 +1100,6 @@ export const addBooster = (ItemType: string, time: number, inventory: TInventory
if (itemIndex !== -1) { if (itemIndex !== -1) {
const existingBooster = Boosters[itemIndex]; const existingBooster = Boosters[itemIndex];
existingBooster.ExpiryDate = Math.max(existingBooster.ExpiryDate, currentTime) + time; existingBooster.ExpiryDate = Math.max(existingBooster.ExpiryDate, currentTime) + time;
inventory.markModified(`Boosters.${itemIndex}.ExpiryDate`);
} else { } else {
Boosters.push({ ItemType, ExpiryDate: currentTime + time }); Boosters.push({ ItemType, ExpiryDate: currentTime + time });
} }

View File

@ -753,10 +753,13 @@ export interface ILotusCustomization extends IItemConfig {
Persona: string; Persona: string;
} }
export interface IMission { export interface IMissionDatabase {
Tag: string;
Completes: number; Completes: number;
Tier?: number; Tier?: number;
Tag: string; }
export interface IMission extends IMissionDatabase {
RewardsCooldownTime?: IMongoDate; RewardsCooldownTime?: IMongoDate;
} }