forked from OpenWF/SpaceNinjaServer
feat: implement purchasing of skins (#353)
Co-authored-by: Sainan <Sainan@users.noreply.github.com> Co-authored-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
This commit is contained in:
parent
e34cb305ad
commit
8e8c77a3d5
@ -31,7 +31,7 @@ import {
|
||||
IQuestKeyResponse,
|
||||
IFusionTreasure,
|
||||
ISpectreLoadout,
|
||||
IWeaponSkin,
|
||||
IWeaponSkinDatabase,
|
||||
ITauntHistory,
|
||||
IPeriodicMissionCompletionDatabase,
|
||||
IPeriodicMissionCompletionResponse,
|
||||
@ -514,7 +514,7 @@ const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
|
||||
{ _id: false }
|
||||
);
|
||||
|
||||
const weaponSkinsSchema = new Schema<IWeaponSkin>(
|
||||
const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
|
||||
{
|
||||
ItemType: String
|
||||
},
|
||||
@ -525,7 +525,13 @@ weaponSkinsSchema.virtual("ItemId").get(function () {
|
||||
return { $oid: this._id.toString() };
|
||||
});
|
||||
|
||||
weaponSkinsSchema.set("toJSON", { virtuals: true });
|
||||
weaponSkinsSchema.set("toJSON", {
|
||||
virtuals: true,
|
||||
transform(_doc, ret, _options) {
|
||||
delete ret._id;
|
||||
delete ret.__v;
|
||||
}
|
||||
});
|
||||
|
||||
const tauntHistorySchema = new Schema<ITauntHistory>(
|
||||
{
|
||||
@ -976,6 +982,7 @@ type InventoryDocumentProps = {
|
||||
SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
|
||||
SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
|
||||
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
|
||||
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
|
@ -13,7 +13,8 @@ import {
|
||||
IRawUpgrade,
|
||||
ISeasonChallenge,
|
||||
ITypeCount,
|
||||
InventorySlot
|
||||
InventorySlot,
|
||||
IWeaponSkinClient
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IGenericUpdate } from "../types/genericUpdate";
|
||||
import {
|
||||
@ -26,7 +27,7 @@ import { logger } from "@/src/utils/logger";
|
||||
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
|
||||
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
|
||||
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 (
|
||||
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
|
||||
switch (typeName.substr(1).split("/")[1]) {
|
||||
@ -445,12 +453,18 @@ export const addWeapon = async (
|
||||
|
||||
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizatonName }) - 1;
|
||||
const changedInventory = await inventory.save();
|
||||
return changedInventory.FlavourItems[flavourItemIndex].toJSON();
|
||||
};
|
||||
|
||||
export const addSkin = async (typeName: string, accountId: string): Promise<IWeaponSkinClient> => {
|
||||
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 = (
|
||||
inventory: IInventoryDatabaseDocument,
|
||||
gearArray: IEquipmentClient[] | undefined,
|
||||
|
@ -24,6 +24,7 @@ export interface IInventoryDatabase
|
||||
| "QuestKeys"
|
||||
| "BlessingCooldown"
|
||||
| "Ships"
|
||||
| "WeaponSkins"
|
||||
> {
|
||||
accountOwnerId: Types.ObjectId;
|
||||
Created: Date;
|
||||
@ -35,6 +36,7 @@ export interface IInventoryDatabase
|
||||
QuestKeys: IQuestKeyDatabase[];
|
||||
BlessingCooldown: Date;
|
||||
Ships: Types.ObjectId[];
|
||||
WeaponSkins: IWeaponSkinDatabase[];
|
||||
}
|
||||
|
||||
export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
|
||||
@ -137,7 +139,7 @@ export interface IInventoryResponse {
|
||||
LastRegionPlayed: string;
|
||||
XPInfo: ITypeXPItem[];
|
||||
Recipes: ITypeCount[];
|
||||
WeaponSkins: IWeaponSkin[];
|
||||
WeaponSkins: IWeaponSkinClient[];
|
||||
PendingRecipes: IPendingRecipeResponse[];
|
||||
TrainingDate: IMongoDate;
|
||||
PlayerLevel: number;
|
||||
@ -847,8 +849,11 @@ export interface ITauntHistory {
|
||||
state: string;
|
||||
}
|
||||
|
||||
export interface IWeaponSkin {
|
||||
export interface IWeaponSkinDatabase {
|
||||
ItemType: string;
|
||||
}
|
||||
|
||||
export interface IWeaponSkinClient extends IWeaponSkinDatabase {
|
||||
ItemId: IOid;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user