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