返回提交历史
Modified
src/services/inventoryService.ts
+7
-9
Modified
src/services/missionInventoryUpdateService.ts
+47
-39
Modified
src/types/requestTypes.ts
+3
-0
XFEstudio/XFESpaceNinjaServer
feat: handle KeyToRemove in EOM upload (#1491)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1491 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
7f805a1d
代码差异
3 个文件
+57
-48
@@ -538,15 +538,9 @@ export const addItem = async (
538
538
if (!key) return {};
539
539
return { QuestKeys: [key] };
540
540
} else {
541
const key = { ItemType: typeName, ItemCount: quantity };
542
543
const index = inventory.LevelKeys.findIndex(levelKey => levelKey.ItemType == typeName);
544
if (index != -1) {
545
inventory.LevelKeys[index].ItemCount += quantity;
546
} else {
547
inventory.LevelKeys.push(key);
548
}
549
return { LevelKeys: [key] };
541
const levelKeyChanges = [{ ItemType: typeName, ItemCount: quantity }];
542
addLevelKeys(inventory, levelKeyChanges);
543
return { LevelKeys: levelKeyChanges };
550
544
}
551
545
}
552
546
if (typeName in ExportDrones) {
@@ -1240,6 +1234,10 @@ export const addRecipes = (inventory: TInventoryDatabaseDocument, itemsArray: IT
1240
1234
applyArrayChanges(inventory.Recipes, itemsArray);
1241
1235
};
1242
1236
1237
export const addLevelKeys = (inventory: TInventoryDatabaseDocument, itemsArray: ITypeCount[]): void => {
1238
applyArrayChanges(inventory.LevelKeys, itemsArray);
1239
};
1240
1243
1241
export const addMods = (inventory: TInventoryDatabaseDocument, itemsArray: IRawUpgrade[]): void => {
1244
1242
const { RawUpgrades } = inventory;
1245
1243
@@ -22,6 +22,7 @@ import {
22
22
addFusionTreasures,
23
23
addGearExpByCategory,
24
24
addItem,
25
addLevelKeys,
25
26
addMiscItems,
26
27
addMissionComplete,
27
28
addMods,
@@ -77,19 +78,52 @@ export const addMissionInventoryUpdates = async (
77
78
inventoryUpdates: IMissionInventoryUpdateRequest
78
79
): Promise<IInventoryChanges> => {
79
80
const inventoryChanges: IInventoryChanges = {};
80
if (
81
inventoryUpdates.EndOfMatchUpload &&
82
inventoryUpdates.Missions &&
83
inventoryUpdates.Missions.Tag in ExportRegions
84
) {
85
const node = ExportRegions[inventoryUpdates.Missions.Tag];
86
if (node.miscItemFee) {
87
addMiscItems(inventory, [
88
{
89
ItemType: node.miscItemFee.ItemType,
90
ItemCount: node.miscItemFee.ItemCount * -1
91
}
92
]);
81
if (inventoryUpdates.EndOfMatchUpload) {
82
if (inventoryUpdates.Missions && inventoryUpdates.Missions.Tag in ExportRegions) {
83
const node = ExportRegions[inventoryUpdates.Missions.Tag];
84
if (node.miscItemFee) {
85
addMiscItems(inventory, [
86
{
87
ItemType: node.miscItemFee.ItemType,
88
ItemCount: node.miscItemFee.ItemCount * -1
89
}
90
]);
91
}
92
}
93
if (inventoryUpdates.KeyToRemove) {
94
if (!inventoryUpdates.KeyOwner || inventory.accountOwnerId.equals(inventoryUpdates.KeyOwner)) {
95
addLevelKeys(inventory, [
96
{
97
ItemType: inventoryUpdates.KeyToRemove,
98
ItemCount: -1
99
}
100
]);
101
}
102
}
103
if (
104
inventoryUpdates.MissionFailed &&
105
inventoryUpdates.MissionStatus == "GS_FAILURE" &&
106
inventoryUpdates.ObjectiveReached &&
107
!inventoryUpdates.LockedWeaponGroup
108
) {
109
const loadout = (await Loadout.findById(inventory.LoadOutPresets, "NORMAL"))!;
110
const config = loadout.NORMAL.id(inventory.CurrentLoadOutIds[0].$oid)!;
111
const SuitId = new Types.ObjectId(config.s!.ItemId.$oid);
112
113
inventory.BrandedSuits ??= [];
114
if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
115
inventory.BrandedSuits.push(SuitId);
116
117
await createMessage(inventory.accountOwnerId, [
118
{
119
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
120
msg: "/Lotus/Language/G1Quests/BrandedMessage",
121
sub: "/Lotus/Language/G1Quests/BrandedTitle",
122
att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
123
highPriority: true // TOVERIFY: I cannot find any content of this within the last 10 years so I can only assume that highPriority is set (it certainly would make sense), but I just don't know for sure that it is so on live.
124
}
125
]);
126
}
93
127
}
94
128
}
95
129
if (inventoryUpdates.RewardInfo) {
@@ -110,32 +144,6 @@ export const addMissionInventoryUpdates = async (
110
144
inventory.NemesisAbandonedRewards = inventoryUpdates.RewardInfo.NemesisAbandonedRewards;
111
145
}
112
146
}
113
if (
114
inventoryUpdates.MissionFailed &&
115
inventoryUpdates.MissionStatus == "GS_FAILURE" &&
116
inventoryUpdates.EndOfMatchUpload &&
117
inventoryUpdates.ObjectiveReached &&
118
!inventoryUpdates.LockedWeaponGroup
119
) {
120
const loadout = (await Loadout.findById(inventory.LoadOutPresets, "NORMAL"))!;
121
const config = loadout.NORMAL.id(inventory.CurrentLoadOutIds[0].$oid)!;
122
const SuitId = new Types.ObjectId(config.s!.ItemId.$oid);
123
124
inventory.BrandedSuits ??= [];
125
if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
126
inventory.BrandedSuits.push(SuitId);
127
128
await createMessage(inventory.accountOwnerId, [
129
{
130
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
131
msg: "/Lotus/Language/G1Quests/BrandedMessage",
132
sub: "/Lotus/Language/G1Quests/BrandedTitle",
133
att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
134
highPriority: true // TOVERIFY: I cannot find any content of this within the last 10 years so I can only assume that highPriority is set (it certainly would make sense), but I just don't know for sure that it is so on live.
135
}
136
]);
137
}
138
}
139
147
for (const [key, value] of getEntriesUnsafe(inventoryUpdates)) {
140
148
if (value === undefined) {
141
149
logger.error(`Inventory update key ${key} has no value `);
@@ -49,6 +49,9 @@ export type IMissionInventoryUpdateRequest = {
49
49
rewardsMultiplier?: number;
50
50
GoalTag: string;
51
51
LevelKeyName: string;
52
KeyOwner?: string;
53
KeyRemovalHash?: string;
54
KeyToRemove?: string;
52
55
ActiveBoosters?: IBooster[];
53
56
RawUpgrades?: IRawUpgrade[];
54
57
FusionTreasures?: IFusionTreasure[];