返回提交历史
Modified
src/models/inventoryModels/inventoryModel.ts
+10
-3
Modified
src/services/inventoryService.ts
+17
-3
Modified
src/types/inventoryTypes/inventoryTypes.ts
+7
-2
XFEstudio/XFESpaceNinjaServer
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>
8e8c77a3
代码差异
3 个文件
+34
-8
@@ -31,7 +31,7 @@ import {
31
31
IQuestKeyResponse,
32
32
IFusionTreasure,
33
33
ISpectreLoadout,
34
IWeaponSkin,
34
IWeaponSkinDatabase,
35
35
ITauntHistory,
36
36
IPeriodicMissionCompletionDatabase,
37
37
IPeriodicMissionCompletionResponse,
@@ -514,7 +514,7 @@ const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
514
514
{ _id: false }
515
515
);
516
516
517
const weaponSkinsSchema = new Schema<IWeaponSkin>(
517
const weaponSkinsSchema = new Schema<IWeaponSkinDatabase>(
518
518
{
519
519
ItemType: String
520
520
},
@@ -525,7 +525,13 @@ weaponSkinsSchema.virtual("ItemId").get(function () {
525
525
return { $oid: this._id.toString() };
526
526
});
527
527
528
weaponSkinsSchema.set("toJSON", { virtuals: true });
528
weaponSkinsSchema.set("toJSON", {
529
virtuals: true,
530
transform(_doc, ret, _options) {
531
delete ret._id;
532
delete ret.__v;
533
}
534
});
529
535
530
536
const tauntHistorySchema = new Schema<ITauntHistory>(
531
537
{
@@ -976,6 +982,7 @@ type InventoryDocumentProps = {
976
982
SpaceMelee: Types.DocumentArray<IEquipmentDatabase>;
977
983
SentinelWeapons: Types.DocumentArray<IEquipmentDatabase>;
978
984
Hoverboards: Types.DocumentArray<IEquipmentDatabase>;
985
WeaponSkins: Types.DocumentArray<IWeaponSkinDatabase>;
979
986
};
980
987
981
988
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -13,7 +13,8 @@ import {
13
13
IRawUpgrade,
14
14
ISeasonChallenge,
15
15
ITypeCount,
16
InventorySlot
16
InventorySlot,
17
IWeaponSkinClient
17
18
} from "@/src/types/inventoryTypes/inventoryTypes";
18
19
import { IGenericUpdate } from "../types/genericUpdate";
19
20
import {
@@ -26,7 +27,7 @@ import { logger } from "@/src/utils/logger";
26
27
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
27
28
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
28
29
import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
29
import { ExportRecipes, ExportResources } from "warframe-public-export-plus";
30
import { ExportCustoms, ExportRecipes, ExportResources } from "warframe-public-export-plus";
30
31
31
32
export const createInventory = async (
32
33
accountOwnerId: Types.ObjectId,
@@ -104,6 +105,13 @@ export const addItem = async (
104
105
}
105
106
};
106
107
}
108
if (typeName in ExportCustoms) {
109
return {
110
InventoryChanges: {
111
WeaponSkins: [await addSkin(typeName, accountId)]
112
}
113
};
114
}
107
115
108
116
// Path-based duck typing
109
117
switch (typeName.substr(1).split("/")[1]) {
@@ -445,12 +453,18 @@ export const addWeapon = async (
445
453
446
454
export const addCustomization = async (customizatonName: string, accountId: string): Promise<IFlavourItem> => {
447
455
const inventory = await getInventory(accountId);
448
449
456
const flavourItemIndex = inventory.FlavourItems.push({ ItemType: customizatonName }) - 1;
450
457
const changedInventory = await inventory.save();
451
458
return changedInventory.FlavourItems[flavourItemIndex].toJSON();
452
459
};
453
460
461
export const addSkin = async (typeName: string, accountId: string): Promise<IWeaponSkinClient> => {
462
const inventory = await getInventory(accountId);
463
const index = inventory.WeaponSkins.push({ ItemType: typeName }) - 1;
464
const changedInventory = await inventory.save();
465
return changedInventory.WeaponSkins[index].toJSON();
466
};
467
454
468
const addGearExpByCategory = (
455
469
inventory: IInventoryDatabaseDocument,
456
470
gearArray: IEquipmentClient[] | undefined,
@@ -24,6 +24,7 @@ export interface IInventoryDatabase
24
24
| "QuestKeys"
25
25
| "BlessingCooldown"
26
26
| "Ships"
27
| "WeaponSkins"
27
28
> {
28
29
accountOwnerId: Types.ObjectId;
29
30
Created: Date;
@@ -35,6 +36,7 @@ export interface IInventoryDatabase
35
36
QuestKeys: IQuestKeyDatabase[];
36
37
BlessingCooldown: Date;
37
38
Ships: Types.ObjectId[];
39
WeaponSkins: IWeaponSkinDatabase[];
38
40
}
39
41
40
42
export interface IInventoryResponseDocument extends IInventoryResponse, Document {}
@@ -137,7 +139,7 @@ export interface IInventoryResponse {
137
139
LastRegionPlayed: string;
138
140
XPInfo: ITypeXPItem[];
139
141
Recipes: ITypeCount[];
140
WeaponSkins: IWeaponSkin[];
142
WeaponSkins: IWeaponSkinClient[];
141
143
PendingRecipes: IPendingRecipeResponse[];
142
144
TrainingDate: IMongoDate;
143
145
PlayerLevel: number;
@@ -847,8 +849,11 @@ export interface ITauntHistory {
847
849
state: string;
848
850
}
849
851
850
export interface IWeaponSkin {
852
export interface IWeaponSkinDatabase {
851
853
ItemType: string;
854
}
855
856
export interface IWeaponSkinClient extends IWeaponSkinDatabase {
852
857
ItemId: IOid;
853
858
}
854
859