fix: ayatan statue saving (#461)

This commit is contained in:
AMelonInsideLemon 2024-07-03 23:01:35 +02:00 committed by GitHub
parent f8a805d84f
commit 07c84214ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 4 deletions

View File

@ -16,7 +16,8 @@ import {
InventorySlot, InventorySlot,
IWeaponSkinClient, IWeaponSkinClient,
TEquipmentKey, TEquipmentKey,
equipmentKeys equipmentKeys,
IFusionTreasure
} from "@/src/types/inventoryTypes/inventoryTypes"; } from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate } from "../types/genericUpdate"; import { IGenericUpdate } from "../types/genericUpdate";
import { import {
@ -650,6 +651,26 @@ export const addMods = (inventory: IInventoryDatabaseDocument, itemsArray: IRawU
}); });
}; };
export const addFusionTreasures = (
inventory: IInventoryDatabaseDocument,
itemsArray: IFusionTreasure[] | undefined
) => {
const { FusionTreasures } = inventory;
itemsArray?.forEach(({ ItemType, ItemCount, Sockets }) => {
const itemIndex = FusionTreasures.findIndex(i => {
i.ItemType === ItemType;
i.Sockets === Sockets;
});
if (itemIndex !== -1) {
FusionTreasures[itemIndex].ItemCount += ItemCount;
inventory.markModified(`FusionTreasures.${itemIndex}.ItemCount`);
} else {
FusionTreasures.push({ ItemCount, ItemType, Sockets });
}
});
};
export const updateChallengeProgress = async (challenges: IUpdateChallengeProgressRequest, accountId: string) => { export const updateChallengeProgress = async (challenges: IUpdateChallengeProgressRequest, accountId: string) => {
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
@ -704,8 +725,17 @@ const addMissionComplete = (inventory: IInventoryDatabaseDocument, { Tag, Comple
}; };
export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => { export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => {
const { RawUpgrades, MiscItems, RegularCredits, ChallengeProgress, FusionPoints, Consumables, Recipes, Missions } = const {
data; RawUpgrades,
MiscItems,
RegularCredits,
ChallengeProgress,
FusionPoints,
Consumables,
Recipes,
Missions,
FusionTreasures
} = data;
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
// credits // credits
@ -762,6 +792,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
addConsumables(inventory, Consumables); addConsumables(inventory, Consumables);
addRecipes(inventory, Recipes); addRecipes(inventory, Recipes);
addChallenges(inventory, ChallengeProgress); addChallenges(inventory, ChallengeProgress);
addFusionTreasures(inventory, FusionTreasures);
if (Missions) { if (Missions) {
addMissionComplete(inventory, Missions); addMissionComplete(inventory, Missions);
} }

View File

@ -12,7 +12,8 @@ import {
IRawUpgrade, IRawUpgrade,
ISeasonChallenge, ISeasonChallenge,
TSolarMapRegion, TSolarMapRegion,
TEquipmentKey TEquipmentKey,
IFusionTreasure
} from "./inventoryTypes/inventoryTypes"; } from "./inventoryTypes/inventoryTypes";
export interface IArtifactsRequest { export interface IArtifactsRequest {
@ -61,6 +62,7 @@ export interface IMissionInventoryUpdateRequest {
RawUpgrades?: IRawUpgrade[]; RawUpgrades?: IRawUpgrade[];
MiscItems?: IMiscItem[]; MiscItems?: IMiscItem[];
Consumables?: IConsumable[]; Consumables?: IConsumable[];
FusionTreasures?: IFusionTreasure[];
Recipes?: IConsumable[]; Recipes?: IConsumable[];
RegularCredits?: number; RegularCredits?: number;
ChallengeProgress?: IChallengeProgress[]; ChallengeProgress?: IChallengeProgress[];