rebase fix
This commit is contained in:
parent
89a47767fa
commit
d7dbf393bf
@ -60,7 +60,7 @@ import {
|
||||
ITraits,
|
||||
IKubrowPetDetailsClient,
|
||||
IKubrowPetEggDatabase,
|
||||
IKubrowPetEggClient
|
||||
IKubrowPetEggClient,
|
||||
ICustomMarkers,
|
||||
IMarkerInfo,
|
||||
IMarker
|
||||
|
@ -1057,32 +1057,6 @@ export const updateSyndicate = (
|
||||
syndicateUpdate: IMissionInventoryUpdateRequest["AffiliationChanges"]
|
||||
): void => {
|
||||
syndicateUpdate?.forEach(affiliation => {
|
||||
export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => {
|
||||
const {
|
||||
RawUpgrades,
|
||||
MiscItems,
|
||||
RegularCredits,
|
||||
ChallengeProgress,
|
||||
FusionPoints,
|
||||
Consumables,
|
||||
Recipes,
|
||||
Missions,
|
||||
FusionTreasures,
|
||||
AffiliationChanges,
|
||||
EvolutionProgress,
|
||||
LastRegionPlayed,
|
||||
CustomMarkers
|
||||
} = data;
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// credits
|
||||
inventory.RegularCredits += RegularCredits || 0;
|
||||
|
||||
// endo
|
||||
inventory.FusionPoints += FusionPoints || 0;
|
||||
|
||||
// syndicate
|
||||
AffiliationChanges?.forEach(affiliation => {
|
||||
const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag);
|
||||
if (syndicate !== undefined) {
|
||||
syndicate.Standing += affiliation.Standing;
|
||||
@ -1126,128 +1100,4 @@ export const addKeyChainItems = async (
|
||||
await addItems(inventory, nonStoreItems);
|
||||
|
||||
return inventoryChanges;
|
||||
|
||||
// Gear XP
|
||||
equipmentKeys.forEach(key => addGearExpByCategory(inventory, data[key], key));
|
||||
|
||||
// Incarnon Challenges
|
||||
if (EvolutionProgress) {
|
||||
for (const evoProgress of EvolutionProgress) {
|
||||
const entry = inventory.EvolutionProgress
|
||||
? inventory.EvolutionProgress.find(entry => entry.ItemType == evoProgress.ItemType)
|
||||
: undefined;
|
||||
if (entry) {
|
||||
entry.Progress = evoProgress.Progress;
|
||||
entry.Rank = evoProgress.Rank;
|
||||
} else {
|
||||
inventory.EvolutionProgress ??= [];
|
||||
inventory.EvolutionProgress.push(evoProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LastRegionPlayed
|
||||
if (LastRegionPlayed) {
|
||||
inventory.LastRegionPlayed = LastRegionPlayed;
|
||||
}
|
||||
|
||||
if (CustomMarkers) {
|
||||
CustomMarkers.forEach(markers => {
|
||||
const map = inventory.CustomMarkers
|
||||
? inventory.CustomMarkers.find(entry => entry.tag == markers.tag)
|
||||
: undefined;
|
||||
if (map) {
|
||||
map.markerInfos = markers.markerInfos;
|
||||
inventory.markModified("CustomMarkers");
|
||||
} else {
|
||||
inventory.CustomMarkers ??= [];
|
||||
inventory.CustomMarkers.push(markers);
|
||||
inventory.markModified("CustomMarkers");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// other
|
||||
addMods(inventory, RawUpgrades);
|
||||
addMiscItems(inventory, MiscItems);
|
||||
addConsumables(inventory, Consumables);
|
||||
addRecipes(inventory, Recipes);
|
||||
addChallenges(inventory, ChallengeProgress);
|
||||
addFusionTreasures(inventory, FusionTreasures);
|
||||
if (Missions) {
|
||||
addMissionComplete(inventory, Missions);
|
||||
}
|
||||
|
||||
const changedInventory = await inventory.save();
|
||||
return changedInventory.toJSON();
|
||||
};
|
||||
|
||||
export const addBooster = async (ItemType: string, time: number, accountId: string): Promise<void> => {
|
||||
const currentTime = Math.floor(Date.now() / 1000) - 129600; // Value is wrong without 129600. Figure out why, please. :)
|
||||
|
||||
const inventory = await getInventory(accountId);
|
||||
const { Boosters } = inventory;
|
||||
|
||||
const itemIndex = Boosters.findIndex(booster => booster.ItemType === ItemType);
|
||||
|
||||
if (itemIndex !== -1) {
|
||||
const existingBooster = Boosters[itemIndex];
|
||||
existingBooster.ExpiryDate = Math.max(existingBooster.ExpiryDate, currentTime) + time;
|
||||
inventory.markModified(`Boosters.${itemIndex}.ExpiryDate`);
|
||||
} else {
|
||||
Boosters.push({ ItemType, ExpiryDate: currentTime + time }) - 1;
|
||||
}
|
||||
|
||||
await inventory.save();
|
||||
};
|
||||
|
||||
export const upgradeMod = async (artifactsData: IArtifactsRequest, accountId: string): Promise<string | undefined> => {
|
||||
const { Upgrade, LevelDiff, Cost, FusionPointCost } = artifactsData;
|
||||
try {
|
||||
const inventory = await getInventory(accountId);
|
||||
const { Upgrades, RawUpgrades } = inventory;
|
||||
const { ItemType, UpgradeFingerprint, ItemId } = Upgrade;
|
||||
|
||||
const safeUpgradeFingerprint = UpgradeFingerprint || '{"lvl":0}';
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const parsedUpgradeFingerprint = JSON.parse(safeUpgradeFingerprint);
|
||||
parsedUpgradeFingerprint.lvl += LevelDiff;
|
||||
const stringifiedUpgradeFingerprint = JSON.stringify(parsedUpgradeFingerprint);
|
||||
|
||||
let itemIndex = Upgrades.findIndex(upgrade => upgrade._id?.equals(ItemId!.$oid));
|
||||
|
||||
if (itemIndex !== -1) {
|
||||
Upgrades[itemIndex].UpgradeFingerprint = stringifiedUpgradeFingerprint;
|
||||
inventory.markModified(`Upgrades.${itemIndex}.UpgradeFingerprint`);
|
||||
} else {
|
||||
itemIndex =
|
||||
Upgrades.push({
|
||||
UpgradeFingerprint: stringifiedUpgradeFingerprint,
|
||||
ItemType
|
||||
}) - 1;
|
||||
|
||||
const rawItemIndex = RawUpgrades.findIndex(rawUpgrade => rawUpgrade.ItemType === ItemType);
|
||||
RawUpgrades[rawItemIndex].ItemCount--;
|
||||
if (RawUpgrades[rawItemIndex].ItemCount > 0) {
|
||||
inventory.markModified(`RawUpgrades.${rawItemIndex}.UpgradeFingerprint`);
|
||||
} else {
|
||||
RawUpgrades.splice(rawItemIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
inventory.RegularCredits -= Cost;
|
||||
inventory.FusionPoints -= FusionPointCost;
|
||||
|
||||
const changedInventory = await inventory.save();
|
||||
const itemId = changedInventory.toJSON().Upgrades[itemIndex]?.ItemId?.$oid;
|
||||
|
||||
if (!itemId) {
|
||||
throw new Error("Item Id not found in upgradeMod");
|
||||
}
|
||||
|
||||
return itemId;
|
||||
} catch (error) {
|
||||
console.error("Error in upgradeMod:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user