Compare commits
No commits in common. "8dd17014fbef7d2f66f8b693d59d197f4be02522" and "c3a9b42fa2443f83bc7a7050b8c371317d60bd5f" have entirely different histories.
8dd17014fb
...
c3a9b42fa2
@ -8,6 +8,7 @@ import { HydratedDocument, Types } from "mongoose";
|
|||||||
import { SlotNames, IInventoryChanges, IBinChanges, slotNames } from "@/src/types/purchaseTypes";
|
import { SlotNames, IInventoryChanges, IBinChanges, slotNames } from "@/src/types/purchaseTypes";
|
||||||
import {
|
import {
|
||||||
IChallengeProgress,
|
IChallengeProgress,
|
||||||
|
IConsumable,
|
||||||
IFlavourItem,
|
IFlavourItem,
|
||||||
IMiscItem,
|
IMiscItem,
|
||||||
IMission,
|
IMission,
|
||||||
@ -377,7 +378,7 @@ export const addItem = async (
|
|||||||
{
|
{
|
||||||
ItemType: typeName,
|
ItemType: typeName,
|
||||||
ItemCount: quantity
|
ItemCount: quantity
|
||||||
} satisfies ITypeCount
|
} satisfies IConsumable
|
||||||
];
|
];
|
||||||
addConsumables(inventory, consumablesChanges);
|
addConsumables(inventory, consumablesChanges);
|
||||||
return {
|
return {
|
||||||
@ -1101,42 +1102,74 @@ export const addMiscItems = (inventory: TInventoryDatabaseDocument, itemsArray:
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyArrayChanges = (arr: ITypeCount[], changes: ITypeCount[]): void => {
|
export const addShipDecorations = (inventory: TInventoryDatabaseDocument, itemsArray: IConsumable[]): void => {
|
||||||
for (const change of changes) {
|
const { ShipDecorations } = inventory;
|
||||||
if (change.ItemCount != 0) {
|
|
||||||
let itemIndex = arr.findIndex(x => x.ItemType === change.ItemType);
|
|
||||||
if (itemIndex == -1) {
|
|
||||||
itemIndex = arr.push({ ItemType: change.ItemType, ItemCount: 0 }) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
arr[itemIndex].ItemCount += change.ItemCount;
|
itemsArray.forEach(({ ItemCount, ItemType }) => {
|
||||||
if (arr[itemIndex].ItemCount == 0) {
|
const itemIndex = ShipDecorations.findIndex(miscItem => miscItem.ItemType === ItemType);
|
||||||
arr.splice(itemIndex, 1);
|
|
||||||
} else if (arr[itemIndex].ItemCount <= 0) {
|
if (itemIndex !== -1) {
|
||||||
logger.warn(`account now owns a negative amount of ${change.ItemType}`);
|
ShipDecorations[itemIndex].ItemCount += ItemCount;
|
||||||
}
|
} else {
|
||||||
|
ShipDecorations.push({ ItemCount, ItemType });
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addShipDecorations = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
export const addConsumables = (inventory: TInventoryDatabaseDocument, itemsArray: IConsumable[]): void => {
|
||||||
applyArrayChanges(inventory.ShipDecorations, itemsArray);
|
const { Consumables } = inventory;
|
||||||
};
|
|
||||||
|
|
||||||
export const addConsumables = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
itemsArray.forEach(({ ItemCount, ItemType }) => {
|
||||||
applyArrayChanges(inventory.Consumables, itemsArray);
|
const itemIndex = Consumables.findIndex(i => i.ItemType === ItemType);
|
||||||
|
|
||||||
|
if (itemIndex !== -1) {
|
||||||
|
Consumables[itemIndex].ItemCount += ItemCount;
|
||||||
|
} else {
|
||||||
|
Consumables.push({ ItemCount, ItemType });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addCrewShipRawSalvage = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
export const addCrewShipRawSalvage = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
||||||
applyArrayChanges(inventory.CrewShipRawSalvage, itemsArray);
|
const { CrewShipRawSalvage } = inventory;
|
||||||
|
|
||||||
|
itemsArray.forEach(({ ItemCount, ItemType }) => {
|
||||||
|
const itemIndex = CrewShipRawSalvage.findIndex(i => i.ItemType === ItemType);
|
||||||
|
|
||||||
|
if (itemIndex !== -1) {
|
||||||
|
CrewShipRawSalvage[itemIndex].ItemCount += ItemCount;
|
||||||
|
} else {
|
||||||
|
CrewShipRawSalvage.push({ ItemCount, ItemType });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addCrewShipAmmo = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
export const addCrewShipAmmo = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
||||||
applyArrayChanges(inventory.CrewShipAmmo, itemsArray);
|
const { CrewShipAmmo } = inventory;
|
||||||
|
|
||||||
|
itemsArray.forEach(({ ItemCount, ItemType }) => {
|
||||||
|
const itemIndex = CrewShipAmmo.findIndex(i => i.ItemType === ItemType);
|
||||||
|
|
||||||
|
if (itemIndex !== -1) {
|
||||||
|
CrewShipAmmo[itemIndex].ItemCount += ItemCount;
|
||||||
|
} else {
|
||||||
|
CrewShipAmmo.push({ ItemCount, ItemType });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
|
||||||
applyArrayChanges(inventory.Recipes, itemsArray);
|
const { Recipes } = inventory;
|
||||||
|
|
||||||
|
itemsArray.forEach(({ ItemCount, ItemType }) => {
|
||||||
|
const itemIndex = Recipes.findIndex(i => i.ItemType === ItemType);
|
||||||
|
|
||||||
|
if (itemIndex !== -1) {
|
||||||
|
Recipes[itemIndex].ItemCount += ItemCount;
|
||||||
|
} else {
|
||||||
|
Recipes.push({ ItemCount, ItemType });
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawUpgrade[]): void => {
|
export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawUpgrade[]): void => {
|
||||||
|
@ -236,8 +236,8 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
|||||||
FusionTreasures: IFusionTreasure[];
|
FusionTreasures: IFusionTreasure[];
|
||||||
WebFlags: IWebFlags;
|
WebFlags: IWebFlags;
|
||||||
CompletedAlerts: string[];
|
CompletedAlerts: string[];
|
||||||
Consumables: ITypeCount[];
|
Consumables: IConsumable[];
|
||||||
LevelKeys: ITypeCount[];
|
LevelKeys: IConsumable[];
|
||||||
TauntHistory?: ITaunt[];
|
TauntHistory?: ITaunt[];
|
||||||
StoryModeChoice: string;
|
StoryModeChoice: string;
|
||||||
PeriodicMissionCompletions: IPeriodicMissionCompletionDatabase[];
|
PeriodicMissionCompletions: IPeriodicMissionCompletionDatabase[];
|
||||||
@ -265,7 +265,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
|||||||
Drones: IDroneClient[];
|
Drones: IDroneClient[];
|
||||||
StepSequencers: IStepSequencer[];
|
StepSequencers: IStepSequencer[];
|
||||||
ActiveAvatarImageType: string;
|
ActiveAvatarImageType: string;
|
||||||
ShipDecorations: ITypeCount[];
|
ShipDecorations: IConsumable[];
|
||||||
DiscoveredMarkers: IDiscoveredMarker[];
|
DiscoveredMarkers: IDiscoveredMarker[];
|
||||||
CompletedJobs: ICompletedJob[];
|
CompletedJobs: ICompletedJob[];
|
||||||
FocusAbility?: string;
|
FocusAbility?: string;
|
||||||
@ -293,7 +293,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
|||||||
Settings: ISettings;
|
Settings: ISettings;
|
||||||
PersonalTechProjects: IPersonalTechProject[];
|
PersonalTechProjects: IPersonalTechProject[];
|
||||||
PlayerSkills: IPlayerSkills;
|
PlayerSkills: IPlayerSkills;
|
||||||
CrewShipAmmo: ITypeCount[];
|
CrewShipAmmo: IConsumable[];
|
||||||
CrewShipSalvagedWeaponSkins: IUpgradeClient[];
|
CrewShipSalvagedWeaponSkins: IUpgradeClient[];
|
||||||
CrewShipWeapons: ICrewShipWeaponClient[];
|
CrewShipWeapons: ICrewShipWeaponClient[];
|
||||||
CrewShipSalvagedWeapons: IEquipmentClient[];
|
CrewShipSalvagedWeapons: IEquipmentClient[];
|
||||||
@ -303,7 +303,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
|||||||
SubscribedToEmailsPersonalized: number;
|
SubscribedToEmailsPersonalized: number;
|
||||||
InfestedFoundry?: IInfestedFoundryClient;
|
InfestedFoundry?: IInfestedFoundryClient;
|
||||||
BlessingCooldown?: IMongoDate;
|
BlessingCooldown?: IMongoDate;
|
||||||
CrewShipRawSalvage: ITypeCount[];
|
CrewShipRawSalvage: IConsumable[];
|
||||||
CrewMembers: ICrewMember[];
|
CrewMembers: ICrewMember[];
|
||||||
LotusCustomization: ILotusCustomization;
|
LotusCustomization: ILotusCustomization;
|
||||||
UseAdultOperatorLoadout?: boolean;
|
UseAdultOperatorLoadout?: boolean;
|
||||||
@ -417,6 +417,11 @@ export interface ICompletedJob {
|
|||||||
StageCompletions: number[];
|
StageCompletions: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IConsumable {
|
||||||
|
ItemCount: number;
|
||||||
|
ItemType: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ICrewMember {
|
export interface ICrewMember {
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
NemesisFingerprint: number;
|
NemesisFingerprint: number;
|
||||||
@ -886,7 +891,7 @@ export enum GettingSlotOrderInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IGiving {
|
export interface IGiving {
|
||||||
RawUpgrades: ITypeCount[];
|
RawUpgrades: IConsumable[];
|
||||||
_SlotOrderInfo: GivingSlotOrderInfo[];
|
_SlotOrderInfo: GivingSlotOrderInfo[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -919,7 +924,7 @@ export interface IPersonalTechProject {
|
|||||||
State: number;
|
State: number;
|
||||||
ReqCredits: number;
|
ReqCredits: number;
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
ReqItems: ITypeCount[];
|
ReqItems: IConsumable[];
|
||||||
CompletionDate?: IMongoDate;
|
CompletionDate?: IMongoDate;
|
||||||
ItemId: IOid;
|
ItemId: IOid;
|
||||||
ProductCategory?: string;
|
ProductCategory?: string;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user