Compare commits
No commits in common. "9de57668ab961eb2c0646b1a44ff6cba731487dd" and "50d687e59a229eac4a5ecad2e8b9134de17b4a5d" have entirely different histories.
9de57668ab
...
50d687e59a
@ -7,7 +7,14 @@ import { getRecipe } from "@/src/services/itemDataService";
|
||||
import { IOid } from "@/src/types/commonTypes";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory, updateCurrency, addItem, addMiscItems, addRecipes } from "@/src/services/inventoryService";
|
||||
import {
|
||||
getInventory,
|
||||
updateCurrency,
|
||||
addItem,
|
||||
addMiscItems,
|
||||
addRecipes,
|
||||
updateCurrencyByAccountId
|
||||
} from "@/src/services/inventoryService";
|
||||
|
||||
export interface IClaimCompletedRecipeRequest {
|
||||
RecipeIds: IOid[];
|
||||
@ -30,6 +37,7 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
// }
|
||||
|
||||
inventory.PendingRecipes.pull(pendingRecipe._id);
|
||||
await inventory.save();
|
||||
|
||||
const recipe = getRecipe(pendingRecipe.ItemType);
|
||||
if (!recipe) {
|
||||
@ -37,10 +45,11 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
}
|
||||
|
||||
if (req.query.cancel) {
|
||||
const inventory = await getInventory(accountId);
|
||||
const currencyChanges = updateCurrency(inventory, recipe.buildPrice * -1, false);
|
||||
addMiscItems(inventory, recipe.ingredients);
|
||||
|
||||
await inventory.save();
|
||||
|
||||
// Not a bug: In the specific case of cancelling a recipe, InventoryChanges are expected to be the root.
|
||||
res.json({
|
||||
...currencyChanges,
|
||||
@ -50,6 +59,7 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
logger.debug("Claiming Recipe", { recipe, pendingRecipe });
|
||||
|
||||
if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
|
||||
const inventory = await getInventory(accountId);
|
||||
inventory.PendingSpectreLoadouts ??= [];
|
||||
inventory.SpectreLoadouts ??= [];
|
||||
|
||||
@ -67,6 +77,7 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
);
|
||||
inventory.SpectreLoadouts.push(inventory.PendingSpectreLoadouts[pendingLoadoutIndex]);
|
||||
inventory.PendingSpectreLoadouts.splice(pendingLoadoutIndex, 1);
|
||||
await inventory.save();
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,14 +92,17 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
|
||||
InventoryChanges = { ...InventoryChanges, Recipes: recipeChanges };
|
||||
|
||||
const inventory = await getInventory(accountId);
|
||||
addRecipes(inventory, recipeChanges);
|
||||
await inventory.save();
|
||||
}
|
||||
if (req.query.rush) {
|
||||
InventoryChanges = {
|
||||
...InventoryChanges,
|
||||
...updateCurrency(inventory, recipe.skipBuildTimePrice, true)
|
||||
...(await updateCurrencyByAccountId(recipe.skipBuildTimePrice, true, accountId))
|
||||
};
|
||||
}
|
||||
const inventory = await getInventory(accountId);
|
||||
InventoryChanges = {
|
||||
...InventoryChanges,
|
||||
...(await addItem(inventory, recipe.resultType, recipe.num)).InventoryChanges
|
||||
|
@ -68,9 +68,7 @@ import {
|
||||
ICalendarProgress,
|
||||
IPendingCouponDatabase,
|
||||
IPendingCouponClient,
|
||||
ILibraryAvailableDailyTaskInfo,
|
||||
IDroneDatabase,
|
||||
IDroneClient
|
||||
ILibraryAvailableDailyTaskInfo
|
||||
} from "../../types/inventoryTypes/inventoryTypes";
|
||||
import { IOid } from "../../types/commonTypes";
|
||||
import {
|
||||
@ -351,27 +349,6 @@ const TypeXPItemSchema = new Schema<ITypeXPItem>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const droneSchema = new Schema<IDroneDatabase>(
|
||||
{
|
||||
ItemType: String,
|
||||
CurrentHP: Number,
|
||||
RepairStart: { type: Date, default: undefined }
|
||||
},
|
||||
{ id: false }
|
||||
);
|
||||
droneSchema.set("toJSON", {
|
||||
virtuals: true,
|
||||
transform(_document, obj) {
|
||||
const client = obj as IDroneClient;
|
||||
const db = obj as IDroneDatabase;
|
||||
|
||||
client.ItemId = toOid(db._id);
|
||||
|
||||
delete obj._id;
|
||||
delete obj.__v;
|
||||
}
|
||||
});
|
||||
|
||||
const challengeProgressSchema = new Schema<IChallengeProgress>(
|
||||
{
|
||||
Progress: Number,
|
||||
@ -532,7 +509,7 @@ const questProgressSchema = new Schema<IQuestStage>(
|
||||
|
||||
const questKeysSchema = new Schema<IQuestKeyDatabase>(
|
||||
{
|
||||
Progress: { type: [questProgressSchema], default: [] },
|
||||
Progress: { type: [questProgressSchema], default: undefined },
|
||||
unlock: Boolean,
|
||||
Completed: Boolean,
|
||||
CustomData: String,
|
||||
@ -1171,8 +1148,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
CompletedSorties: [String],
|
||||
LastSortieReward: [Schema.Types.Mixed],
|
||||
|
||||
// Resource Extractor Drones
|
||||
Drones: [droneSchema],
|
||||
//Resource_Drone[Uselees stuff]
|
||||
Drones: [Schema.Types.Mixed],
|
||||
|
||||
//Active profile ico
|
||||
ActiveAvatarImageType: String,
|
||||
@ -1322,7 +1299,6 @@ export type InventoryDocumentProps = {
|
||||
PendingRecipes: Types.DocumentArray<IPendingRecipeDatabase>;
|
||||
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
|
||||
QuestKeys: Types.DocumentArray<IQuestKeyDatabase>;
|
||||
Drones: Types.DocumentArray<IDroneDatabase>;
|
||||
} & { [K in TEquipmentKey]: Types.DocumentArray<IEquipmentDatabase> };
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
|
@ -24,8 +24,7 @@ import {
|
||||
IKubrowPetEggDatabase,
|
||||
IKubrowPetEggClient,
|
||||
ILibraryAvailableDailyTaskInfo,
|
||||
ICalendarProgress,
|
||||
IDroneClient
|
||||
ICalendarProgress
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IGenericUpdate } from "../types/genericUpdate";
|
||||
import {
|
||||
@ -39,7 +38,6 @@ import { IEquipmentClient, IEquipmentDatabase, IItemConfig } from "../types/inve
|
||||
import {
|
||||
ExportArcanes,
|
||||
ExportCustoms,
|
||||
ExportDrones,
|
||||
ExportFlavour,
|
||||
ExportFusionBundles,
|
||||
ExportGear,
|
||||
@ -58,7 +56,7 @@ import { IKeyChainRequest } from "@/src/controllers/api/giveKeyChainTriggeredIte
|
||||
import { toOid } from "../helpers/inventoryHelpers";
|
||||
import { generateRewardSeed } from "@/src/controllers/api/getNewRewardSeedController";
|
||||
import { addStartingGear } from "@/src/controllers/api/giveStartingGearController";
|
||||
import { addQuestKey, completeQuest } from "@/src/services/questService";
|
||||
import { completeQuest } from "@/src/services/questService";
|
||||
|
||||
export const createInventory = async (
|
||||
accountOwnerId: Types.ObjectId,
|
||||
@ -327,29 +325,15 @@ export const addItem = async (
|
||||
}
|
||||
if (typeName in ExportKeys) {
|
||||
// Note: "/Lotus/Types/Keys/" contains some EmailItems
|
||||
const key = ExportKeys[typeName];
|
||||
|
||||
if (key.chainStages) {
|
||||
const key = addQuestKey(inventory, { ItemType: typeName });
|
||||
if (key) {
|
||||
return { InventoryChanges: { QuestKeys: [key] } };
|
||||
}
|
||||
} else {
|
||||
const key = { ItemType: typeName, ItemCount: quantity };
|
||||
|
||||
const index = inventory.LevelKeys.findIndex(levelKey => levelKey.ItemType == typeName);
|
||||
if (index) {
|
||||
inventory.LevelKeys[index].ItemCount += quantity;
|
||||
} else {
|
||||
inventory.LevelKeys.push(key);
|
||||
}
|
||||
return { InventoryChanges: { LevelKeys: [key] } };
|
||||
}
|
||||
}
|
||||
if (typeName in ExportDrones) {
|
||||
const inventoryChanges = addDrone(inventory, typeName);
|
||||
inventory.QuestKeys.push({ ItemType: typeName });
|
||||
return {
|
||||
InventoryChanges: inventoryChanges
|
||||
InventoryChanges: {
|
||||
QuestKeys: [
|
||||
{
|
||||
ItemType: typeName
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -666,6 +650,20 @@ export const updateCurrency = (
|
||||
return currencyChanges;
|
||||
};
|
||||
|
||||
export const updateCurrencyByAccountId = async (
|
||||
price: number,
|
||||
usePremium: boolean,
|
||||
accountId: string
|
||||
): Promise<ICurrencyChanges> => {
|
||||
if (!isCurrencyTracked(usePremium)) {
|
||||
return {};
|
||||
}
|
||||
const inventory = await getInventory(accountId);
|
||||
const currencyChanges = updateCurrency(inventory, price, usePremium);
|
||||
await inventory.save();
|
||||
return currencyChanges;
|
||||
};
|
||||
|
||||
const standingLimitBinToInventoryKey: Record<
|
||||
Exclude<TStandingLimitBin, "STANDING_LIMIT_BIN_NONE">,
|
||||
keyof IDailyAffiliations
|
||||
@ -825,17 +823,6 @@ const addMotorcycle = (
|
||||
return inventoryChanges;
|
||||
};
|
||||
|
||||
const addDrone = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
typeName: string,
|
||||
inventoryChanges: IInventoryChanges = {}
|
||||
): IInventoryChanges => {
|
||||
const index = inventory.Drones.push({ ItemType: typeName, CurrentHP: ExportDrones[typeName].durability }) - 1;
|
||||
inventoryChanges.Drones ??= [];
|
||||
inventoryChanges.Drones.push(inventory.Drones[index].toJSON<IDroneClient>());
|
||||
return inventoryChanges;
|
||||
};
|
||||
|
||||
//TODO: wrong id is not erroring
|
||||
export const addGearExpByCategory = (
|
||||
inventory: TInventoryDatabaseDocument,
|
||||
|
@ -5,12 +5,7 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
|
||||
import { createMessage } from "@/src/services/inboxService";
|
||||
import { addItem, addKeyChainItems } from "@/src/services/inventoryService";
|
||||
import { getKeyChainMessage, getLevelKeyRewards } from "@/src/services/itemDataService";
|
||||
import {
|
||||
IInventoryDatabase,
|
||||
IQuestKeyClient,
|
||||
IQuestKeyDatabase,
|
||||
IQuestStage
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IInventoryDatabase, IQuestKeyDatabase, IQuestStage } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import { HydratedDocument } from "mongoose";
|
||||
import { ExportKeys } from "warframe-public-export-plus";
|
||||
@ -74,14 +69,12 @@ export const updateQuestStage = (
|
||||
Object.assign(questStage, questStageUpdate);
|
||||
};
|
||||
|
||||
export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase) => {
|
||||
export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase): void => {
|
||||
if (inventory.QuestKeys.some(q => q.ItemType === questKey.ItemType)) {
|
||||
logger.error(`quest key ${questKey.ItemType} already exists`);
|
||||
return;
|
||||
}
|
||||
const index = inventory.QuestKeys.push(questKey);
|
||||
|
||||
return inventory.QuestKeys[index - 1].toJSON<IQuestKeyClient>();
|
||||
inventory.QuestKeys.push(questKey);
|
||||
};
|
||||
|
||||
export const completeQuest = async (inventory: TInventoryDatabaseDocument, questKey: string) => {
|
||||
|
@ -39,7 +39,6 @@ export interface IInventoryDatabase
|
||||
| "DialogueHistory"
|
||||
| "KubrowPetEggs"
|
||||
| "PendingCoupon"
|
||||
| "Drones"
|
||||
| TEquipmentKey
|
||||
>,
|
||||
InventoryDatabaseEquipment {
|
||||
@ -64,7 +63,6 @@ export interface IInventoryDatabase
|
||||
DialogueHistory?: IDialogueHistoryDatabase;
|
||||
KubrowPetEggs?: IKubrowPetEggDatabase[];
|
||||
PendingCoupon?: IPendingCouponDatabase;
|
||||
Drones: IDroneDatabase[];
|
||||
}
|
||||
|
||||
export interface IQuestKeyDatabase {
|
||||
@ -260,7 +258,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
||||
Alignment: IAlignment;
|
||||
CompletedSorties: string[];
|
||||
LastSortieReward: ILastSortieReward[];
|
||||
Drones: IDroneClient[];
|
||||
Drones: IDrone[];
|
||||
StepSequencers: IStepSequencer[];
|
||||
ActiveAvatarImageType: string;
|
||||
ShipDecorations: IConsumable[];
|
||||
@ -510,20 +508,13 @@ export interface IDiscoveredMarker {
|
||||
discoveryState: number[];
|
||||
}
|
||||
|
||||
export interface IDroneClient {
|
||||
export interface IDrone {
|
||||
ItemType: string;
|
||||
CurrentHP: number;
|
||||
ItemId: IOid;
|
||||
RepairStart?: IMongoDate;
|
||||
}
|
||||
|
||||
export interface IDroneDatabase {
|
||||
ItemType: string;
|
||||
CurrentHP: number;
|
||||
_id: Types.ObjectId;
|
||||
RepairStart?: Date;
|
||||
}
|
||||
|
||||
export interface ITypeXPItem {
|
||||
ItemType: string;
|
||||
XP: number;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
|
||||
import { IDroneClient, IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
|
||||
import { IInfestedFoundryClient, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
|
||||
|
||||
export interface IPurchaseRequest {
|
||||
PurchaseParams: IPurchaseParams;
|
||||
@ -32,10 +32,10 @@ export type IInventoryChanges = {
|
||||
[_ in SlotNames]?: IBinChanges;
|
||||
} & {
|
||||
[_ in TEquipmentKey]?: IEquipmentClient[];
|
||||
} & ICurrencyChanges & {
|
||||
InfestedFoundry?: IInfestedFoundryClient;
|
||||
Drones?: IDroneClient[];
|
||||
} & Record<string, IBinChanges | number | object[] | IInfestedFoundryClient>;
|
||||
} & ICurrencyChanges & { InfestedFoundry?: IInfestedFoundryClient } & Record<
|
||||
string,
|
||||
IBinChanges | number | object[] | IInfestedFoundryClient
|
||||
>;
|
||||
|
||||
export interface IAffiliationMods {
|
||||
Tag: string;
|
||||
|
Loading…
x
Reference in New Issue
Block a user