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,
|
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
|
||||||
},
|
},
|
||||||
@ -525,7 +525,13 @@ weaponSkinsSchema.virtual("ItemId").get(function () {
|
|||||||
return { $oid: this._id.toString() };
|
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>(
|
const tauntHistorySchema = new Schema<ITauntHistory>(
|
||||||
{
|
{
|
||||||
@ -976,6 +982,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,
|
||||||
|
IWeaponSkinClient
|
||||||
} 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<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 = (
|
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 {}
|
||||||
@ -137,7 +139,7 @@ export interface IInventoryResponse {
|
|||||||
LastRegionPlayed: string;
|
LastRegionPlayed: string;
|
||||||
XPInfo: ITypeXPItem[];
|
XPInfo: ITypeXPItem[];
|
||||||
Recipes: ITypeCount[];
|
Recipes: ITypeCount[];
|
||||||
WeaponSkins: IWeaponSkin[];
|
WeaponSkins: IWeaponSkinClient[];
|
||||||
PendingRecipes: IPendingRecipeResponse[];
|
PendingRecipes: IPendingRecipeResponse[];
|
||||||
TrainingDate: IMongoDate;
|
TrainingDate: IMongoDate;
|
||||||
PlayerLevel: number;
|
PlayerLevel: number;
|
||||||
@ -847,8 +849,11 @@ export interface ITauntHistory {
|
|||||||
state: string;
|
state: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWeaponSkin {
|
export interface IWeaponSkinDatabase {
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IWeaponSkinClient extends IWeaponSkinDatabase {
|
||||||
ItemId: IOid;
|
ItemId: IOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user