fix: loc-pin saving
This commit is contained in:
parent
53ce6ccce2
commit
52d32a67b4
@ -61,6 +61,9 @@ import {
|
|||||||
IKubrowPetDetailsClient,
|
IKubrowPetDetailsClient,
|
||||||
IKubrowPetEggDatabase,
|
IKubrowPetEggDatabase,
|
||||||
IKubrowPetEggClient
|
IKubrowPetEggClient
|
||||||
|
ICustomMarkers,
|
||||||
|
IMarkerInfo,
|
||||||
|
IMarker
|
||||||
} from "../../types/inventoryTypes/inventoryTypes";
|
} from "../../types/inventoryTypes/inventoryTypes";
|
||||||
import { IOid } from "../../types/commonTypes";
|
import { IOid } from "../../types/commonTypes";
|
||||||
import {
|
import {
|
||||||
@ -849,6 +852,35 @@ infestedFoundrySchema.set("toJSON", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const markerSchema = new Schema<IMarker>(
|
||||||
|
{
|
||||||
|
anchorName: String,
|
||||||
|
color: Number,
|
||||||
|
label: String,
|
||||||
|
x: Number,
|
||||||
|
y: Number,
|
||||||
|
z: Number,
|
||||||
|
showInHud: Boolean
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
const markerInfoSchema = new Schema<IMarkerInfo>(
|
||||||
|
{
|
||||||
|
icon: String,
|
||||||
|
markers: [markerSchema]
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
const CustomMarkersSchema = new Schema<ICustomMarkers>(
|
||||||
|
{
|
||||||
|
tag: String,
|
||||||
|
markerInfos: [markerInfoSchema]
|
||||||
|
},
|
||||||
|
{ _id: false }
|
||||||
|
);
|
||||||
|
|
||||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||||
{
|
{
|
||||||
accountOwnerId: Schema.Types.ObjectId,
|
accountOwnerId: Schema.Types.ObjectId,
|
||||||
@ -1133,6 +1165,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
|||||||
//https://warframe.fandom.com/wiki/Incarnon
|
//https://warframe.fandom.com/wiki/Incarnon
|
||||||
EvolutionProgress: { type: [evolutionProgressSchema], default: undefined },
|
EvolutionProgress: { type: [evolutionProgressSchema], default: undefined },
|
||||||
|
|
||||||
|
//https://warframe.fandom.com/wiki/Loc-Pin
|
||||||
|
CustomMarkers: [CustomMarkersSchema],
|
||||||
|
|
||||||
//Unknown and system
|
//Unknown and system
|
||||||
DuviriInfo: DuviriInfoSchema,
|
DuviriInfo: DuviriInfoSchema,
|
||||||
Mailbox: MailboxSchema,
|
Mailbox: MailboxSchema,
|
||||||
|
@ -1057,6 +1057,32 @@ export const updateSyndicate = (
|
|||||||
syndicateUpdate: IMissionInventoryUpdateRequest["AffiliationChanges"]
|
syndicateUpdate: IMissionInventoryUpdateRequest["AffiliationChanges"]
|
||||||
): void => {
|
): void => {
|
||||||
syndicateUpdate?.forEach(affiliation => {
|
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);
|
const syndicate = inventory.Affiliations.find(x => x.Tag == affiliation.Tag);
|
||||||
if (syndicate !== undefined) {
|
if (syndicate !== undefined) {
|
||||||
syndicate.Standing += affiliation.Standing;
|
syndicate.Standing += affiliation.Standing;
|
||||||
@ -1100,4 +1126,126 @@ export const addKeyChainItems = async (
|
|||||||
await addItems(inventory, nonStoreItems);
|
await addItems(inventory, nonStoreItems);
|
||||||
|
|
||||||
return inventoryChanges;
|
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;
|
||||||
|
} else {
|
||||||
|
inventory.CustomMarkers ??= [];
|
||||||
|
inventory.CustomMarkers.push(markers);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -155,6 +155,20 @@ export const addMissionInventoryUpdates = (
|
|||||||
inventory.PlayerSkills.LPP_DRIFTER += value.LPP_DRIFTER;
|
inventory.PlayerSkills.LPP_DRIFTER += value.LPP_DRIFTER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "CustomMarkers": {
|
||||||
|
value.forEach(markers => {
|
||||||
|
const map = inventory.CustomMarkers
|
||||||
|
? inventory.CustomMarkers.find(entry => entry.tag == markers.tag)
|
||||||
|
: undefined;
|
||||||
|
if (map) {
|
||||||
|
map.markerInfos = markers.markerInfos;
|
||||||
|
} else {
|
||||||
|
inventory.CustomMarkers ??= [];
|
||||||
|
inventory.CustomMarkers.push(markers);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Equipment XP updates
|
// Equipment XP updates
|
||||||
if (equipmentKeys.includes(key as TEquipmentKey)) {
|
if (equipmentKeys.includes(key as TEquipmentKey)) {
|
||||||
|
@ -343,6 +343,7 @@ export interface IInventoryClient extends IDailyAffiliations {
|
|||||||
LastInventorySync: IOid;
|
LastInventorySync: IOid;
|
||||||
NextRefill: IMongoDate; // Next time argon crystals will have a decay tick
|
NextRefill: IMongoDate; // Next time argon crystals will have a decay tick
|
||||||
FoundToday?: IMiscItem[]; // for Argon Crystals
|
FoundToday?: IMiscItem[]; // for Argon Crystals
|
||||||
|
CustomMarkers: ICustomMarkers[];
|
||||||
ActiveLandscapeTraps: any[];
|
ActiveLandscapeTraps: any[];
|
||||||
EvolutionProgress?: IEvolutionProgress[];
|
EvolutionProgress?: IEvolutionProgress[];
|
||||||
RepVotes: any[];
|
RepVotes: any[];
|
||||||
@ -1056,3 +1057,23 @@ export interface ICompletedDialogue {
|
|||||||
Booleans: string[];
|
Booleans: string[];
|
||||||
Choices: number[];
|
Choices: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ICustomMarkers {
|
||||||
|
tag: string;
|
||||||
|
markerInfos: IMarkerInfo[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMarkerInfo {
|
||||||
|
icon: string;
|
||||||
|
markers: IMarker[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IMarker {
|
||||||
|
anchorName: string;
|
||||||
|
color: number;
|
||||||
|
label?: string;
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
z: number;
|
||||||
|
showInHud: boolean;
|
||||||
|
}
|
||||||
|
@ -11,6 +11,9 @@ import {
|
|||||||
TSolarMapRegion,
|
TSolarMapRegion,
|
||||||
TEquipmentKey,
|
TEquipmentKey,
|
||||||
IFusionTreasure,
|
IFusionTreasure,
|
||||||
|
IQuestKeyClient,
|
||||||
|
IPlayerSkills,
|
||||||
|
ICustomMarkers,
|
||||||
IPlayerSkills,
|
IPlayerSkills,
|
||||||
IQuestKeyDatabase
|
IQuestKeyDatabase
|
||||||
} from "./inventoryTypes/inventoryTypes";
|
} from "./inventoryTypes/inventoryTypes";
|
||||||
@ -75,6 +78,7 @@ export type IMissionInventoryUpdateRequest = {
|
|||||||
EvolutionProgress?: IEvolutionProgress[];
|
EvolutionProgress?: IEvolutionProgress[];
|
||||||
FocusXpIncreases?: number[];
|
FocusXpIncreases?: number[];
|
||||||
PlayerSkillGains: IPlayerSkills;
|
PlayerSkillGains: IPlayerSkills;
|
||||||
|
CustomMarkers?: ICustomMarkers[];
|
||||||
} & {
|
} & {
|
||||||
[K in TEquipmentKey]?: IEquipmentClient[];
|
[K in TEquipmentKey]?: IEquipmentClient[];
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user