feat: implement purchasing of skins
This commit is contained in:
parent
ae3fe49d95
commit
7752d60c31
@ -31,7 +31,7 @@ import {
|
|||||||
IQuestKeyResponse,
|
IQuestKeyResponse,
|
||||||
IFusionTreasure,
|
IFusionTreasure,
|
||||||
ISpectreLoadout,
|
ISpectreLoadout,
|
||||||
IWeaponSkin,
|
IWeaponSkinDatabase,
|
||||||
ITauntHistory,
|
ITauntHistory,
|
||||||
IPeriodicMissionCompletionDatabase,
|
IPeriodicMissionCompletionDatabase,
|
||||||
IPeriodicMissionCompletionResponse,
|
IPeriodicMissionCompletionResponse,
|
||||||
@ -514,7 +514,7 @@ const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
|
|||||||
{ _id: false }
|
{ _id: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
const weaponSkinsSchema = new Schema<IWeaponSkin>(
|
const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
|
||||||
{
|
{
|
||||||
ItemType: String
|
ItemType: String
|
||||||
},
|
},
|
||||||
@ -976,6 +976,7 @@ type InventoryDocumentProps = {
|
|||||||
SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
|
SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
|
SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
|
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
|
||||||
|
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
@ -13,7 +13,8 @@ import {
|
|||||||
IRawUpgrade,
|
IRawUpgrade,
|
||||||
ISeasonChallenge,
|
ISeasonChallenge,
|
||||||
ITypeCount,
|
ITypeCount,
|
||||||
InventorySlot
|
InventorySlot,
|
||||||
|
IWeaponSkin
|
||||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IGenericUpdate } from "../types/genericUpdate";
|
import { IGenericUpdate } from "../types/genericUpdate";
|
||||||
import {
|
import {
|
||||||
@ -26,7 +27,7 @@ import { logger } from "@/src/utils/logger";
|
|||||||
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
|
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
|
||||||
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
|
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
|
||||||
import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
|
import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
|
||||||
import { ExportRecipes, ExportResources } from "warframe-public-export-plus";
|
import { ExportCustoms, ExportRecipes, ExportResources } from "warframe-public-export-plus";
|
||||||
|
|
||||||
export const createInventory = async (
|
export const createInventory = async (
|
||||||
accountOwnerId: Types.ObjectId,
|
accountOwnerId: Types.ObjectId,
|
||||||
@ -104,6 +105,13 @@ export const addItem = async (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (typeName in ExportCustoms) {
|
||||||
|
return {
|
||||||
|
InventoryChanges: {
|
||||||
|
WeaponSkins: [ await addSkin(typeName, accountId) ]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Path-based duck typing
|
// Path-based duck typing
|
||||||
switch (typeName.substr(1).split("/")[1]) {
|
switch (typeName.substr(1).split("/")[1]) {
|
||||||
@ -445,12 +453,18 @@ export const addWeapon = async (
|
|||||||
|
|
||||||
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
|
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
|
|
||||||
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizatonName }) - 1;
|
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizatonName }) - 1;
|
||||||
const changedInventory = await inventory.save();
|
const changedInventory = await inventory.save();
|
||||||
return changedInventory.FlavourItems[flavourItemIndex].toJSON();
|
return changedInventory.FlavourItems[flavourItemIndex].toJSON();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addSkin = async (typeName: string, accountId: string): Promise<IWeaponSkin> => {
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
|
||||||
|
const changedInventory = await inventory.save();
|
||||||
|
return changedInventory.WeaponSkins[index].toJSON();
|
||||||
|
};
|
||||||
|
|
||||||
const addGearExpByCategory = (
|
const addGearExpByCategory = (
|
||||||
inventory: IInventoryDatabaseDocument,
|
inventory: IInventoryDatabaseDocument,
|
||||||
gearArray: IEquipmentClient[] | undefined,
|
gearArray: IEquipmentClient[] | undefined,
|
||||||
|
@ -24,6 +24,7 @@ export interface IInventoryDatabase
|
|||||||
| "QuestKeys"
|
| "QuestKeys"
|
||||||
| "BlessingCooldown"
|
| "BlessingCooldown"
|
||||||
| "Ships"
|
| "Ships"
|
||||||
|
| "WeaponSkins"
|
||||||
> {
|
> {
|
||||||
accountOwnerId: Types.ObjectId;
|
accountOwnerId: Types.ObjectId;
|
||||||
Created: Date;
|
Created: Date;
|
||||||
@ -35,6 +36,7 @@ export interface IInventoryDatabase
|
|||||||
QuestKeys: IQuestKeyDatabase[];
|
QuestKeys: IQuestKeyDatabase[];
|
||||||
BlessingCooldown: Date;
|
BlessingCooldown: Date;
|
||||||
Ships: Types.ObjectId[];
|
Ships: Types.ObjectId[];
|
||||||
|
WeaponSkins: IWeaponSkinDatabase[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
|
export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
|
||||||
@ -846,8 +848,11 @@ export interface ITauntHistory {
|
|||||||
state: string;
|
state: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWeaponSkin {
|
export interface IWeaponSkinDatabase {
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IWeaponSkin extends IWeaponSkinDatabase {
|
||||||
ItemId: IOid;
|
ItemId: IOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user