返回提交历史
Modified
src/controllers/api/claimCompletedRecipeController.ts
+24
-0
Modified
src/controllers/api/startRecipeController.ts
+54
-0
Modified
src/models/inventoryModels/inventoryModel.ts
+9
-10
Modified
src/types/inventoryTypes/inventoryTypes.ts
+8
-7
XFEstudio/SpaceNinjaServer
feat: spectre loadouts (#719)
709c2a40
代码差异
4 个文件
+95
-17
@@ -59,6 +59,30 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
59
59
});
60
60
} else {
61
61
logger.debug("Claiming Recipe", { recipe, pendingRecipe });
62
63
if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
64
const inventory = await getInventory(accountId);
65
inventory.PendingSpectreLoadouts ??= [];
66
inventory.SpectreLoadouts ??= [];
67
68
const pendingLoadoutIndex = inventory.PendingSpectreLoadouts.findIndex(
69
x => x.ItemType == recipe.resultType
70
);
71
if (pendingLoadoutIndex != -1) {
72
const loadoutIndex = inventory.SpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
73
if (loadoutIndex != -1) {
74
inventory.SpectreLoadouts.splice(loadoutIndex, 1);
75
}
76
logger.debug(
77
"moving spectre loadout from pending to active",
78
inventory.toJSON().PendingSpectreLoadouts![pendingLoadoutIndex]
79
);
80
inventory.SpectreLoadouts.push(inventory.PendingSpectreLoadouts[pendingLoadoutIndex]);
81
inventory.PendingSpectreLoadouts.splice(pendingLoadoutIndex, 1);
82
await inventory.save();
83
}
84
}
85
62
86
let InventoryChanges = {};
63
87
if (recipe.consumeOnUse) {
64
88
const recipeChanges = [
@@ -6,6 +6,7 @@ import { getRecipe } from "@/src/services/itemDataService";
6
6
import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inventoryService";
7
7
import { unixTimesInMs } from "@/src/constants/timeConstants";
8
8
import { Types } from "mongoose";
9
import { ISpectreLoadout } from "@/src/types/inventoryTypes/inventoryTypes";
9
10
10
11
interface IStartRecipeRequest {
11
12
RecipeName: string;
@@ -43,6 +44,59 @@ export const startRecipeController: RequestHandler = async (req, res) => {
43
44
_id: new Types.ObjectId()
44
45
});
45
46
47
if (recipe.secretIngredientAction == "SIA_SPECTRE_LOADOUT_COPY") {
48
const spectreLoadout: ISpectreLoadout = {
49
ItemType: recipe.resultType,
50
Suits: "",
51
LongGuns: "",
52
Pistols: "",
53
Melee: ""
54
};
55
for (
56
let secretIngredientsIndex = 0;
57
secretIngredientsIndex != recipe.secretIngredients!.length;
58
++secretIngredientsIndex
59
) {
60
const type = recipe.secretIngredients![secretIngredientsIndex].ItemType;
61
const oid = startRecipeRequest.Ids[recipe.ingredients.length + secretIngredientsIndex];
62
if (oid == "ffffffffffffffffffffffff") {
63
// user chose to preserve the active loadout
64
break;
65
}
66
if (type == "/Lotus/Types/Game/PowerSuits/PlayerPowerSuit") {
67
const item = inventory.Suits.find(x => x._id.toString() == oid)!;
68
spectreLoadout.Suits = item.ItemType;
69
} else if (type == "/Lotus/Weapons/Tenno/Pistol/LotusPistol") {
70
const item = inventory.Pistols.find(x => x._id.toString() == oid)!;
71
spectreLoadout.Pistols = item.ItemType;
72
spectreLoadout.PistolsModularParts = item.ModularParts;
73
} else if (type == "/Lotus/Weapons/Tenno/LotusLongGun") {
74
const item = inventory.LongGuns.find(x => x._id.toString() == oid)!;
75
spectreLoadout.LongGuns = item.ItemType;
76
spectreLoadout.LongGunsModularParts = item.ModularParts;
77
} else {
78
console.assert(type == "/Lotus/Types/Game/LotusMeleeWeapon");
79
const item = inventory.Melee.find(x => x._id.toString() == oid)!;
80
spectreLoadout.Melee = item.ItemType;
81
spectreLoadout.MeleeModularParts = item.ModularParts;
82
}
83
}
84
if (
85
spectreLoadout.Suits != "" &&
86
spectreLoadout.LongGuns != "" &&
87
spectreLoadout.Pistols != "" &&
88
spectreLoadout.Melee != ""
89
) {
90
inventory.PendingSpectreLoadouts ??= [];
91
const existingIndex = inventory.PendingSpectreLoadouts.findIndex(x => x.ItemType == recipe.resultType);
92
if (existingIndex != -1) {
93
inventory.PendingSpectreLoadouts.splice(existingIndex, 1);
94
}
95
inventory.PendingSpectreLoadouts.push(spectreLoadout);
96
logger.debug("pending spectre loadout", spectreLoadout);
97
}
98
}
99
46
100
const newInventory = await inventory.save();
47
101
48
102
res.json({
@@ -548,13 +548,14 @@ const fusionTreasuresSchema = new Schema<IFusionTreasure>().add(typeCountSchema)
548
548
549
549
const spectreLoadoutsSchema = new Schema<ISpectreLoadout>(
550
550
{
551
ItemType: String,
552
Suits: String,
551
553
LongGuns: String,
552
Melee: String,
554
LongGunsModularParts: { type: [String], default: undefined },
553
555
Pistols: String,
554
PistolsFeatures: Number,
555
PistolsModularParts: [String],
556
Suits: String,
557
ItemType: String
556
PistolsModularParts: { type: [String], default: undefined },
557
Melee: String,
558
MeleeModularParts: { type: [String], default: undefined }
558
559
},
559
560
{ _id: false }
560
561
);
@@ -936,11 +937,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
936
937
QualifyingInvasions: [Schema.Types.Mixed],
937
938
FactionScores: [Number],
938
939
939
//Have only Suit+Pistols+LongGuns+Melee+ItemType(BronzeSpectre,GoldSpectre,PlatinumSpectreArmy,SilverSpectreArmy)
940
//"/Lotus/Types/Game/SpectreArmies/BronzeSpectreArmy": "Vapor Specter Regiment",
941
SpectreLoadouts: [spectreLoadoutsSchema],
942
//If you want change Spectre Gear id
943
PendingSpectreLoadouts: [Schema.Types.Mixed],
940
// https://warframe.fandom.com/wiki/Specter_(Tenno)
941
PendingSpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
942
SpectreLoadouts: { type: [spectreLoadoutsSchema], default: undefined },
944
943
945
944
//New Quest Email
946
945
EmailItems: [TypeXPItemSchema],
@@ -203,8 +203,8 @@ export interface IInventoryResponse {
203
203
SpaceMelee: IEquipmentDatabase[];
204
204
SpaceGuns: IEquipmentDatabase[];
205
205
ArchwingEnabled: boolean;
206
PendingSpectreLoadouts: any[];
207
SpectreLoadouts: ISpectreLoadout[];
206
PendingSpectreLoadouts?: ISpectreLoadout[];
207
SpectreLoadouts?: ISpectreLoadout[];
208
208
SentinelWeapons: IEquipmentDatabase[];
209
209
Sentinels: IEquipmentDatabase[];
210
210
EmailItems: ITypeCount[];
@@ -871,13 +871,14 @@ export interface IShipInventory {
871
871
}
872
872
873
873
export interface ISpectreLoadout {
874
ItemType: string;
875
Suits: string;
874
876
LongGuns: string;
875
Melee: string;
877
LongGunsModularParts?: string[];
876
878
Pistols: string;
877
PistolsFeatures: number;
878
PistolsModularParts: string[];
879
Suits: string;
880
ItemType: string;
879
PistolsModularParts?: string[];
880
Melee: string;
881
MeleeModularParts?: string[];
881
882
}
882
883
883
884
export interface IStepSequencer {