返回提交历史
Modified
src/controllers/api/gildWeaponController.ts
+30
-11
XFEstudio/XFESpaceNinjaServer
fix: consume resources & standing required for gilding (#1132)
Fixes #1122 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1132
814f4cfd
代码差异
1 个文件
+30
-11
@@ -1,29 +1,29 @@
1
1
import { RequestHandler } from "express";
2
2
import { getAccountIdForRequest } from "@/src/services/loginService";
3
3
import { getJSONfromString } from "@/src/helpers/stringHelpers";
4
import { getInventory } from "@/src/services/inventoryService";
4
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
5
5
import { WeaponTypeInternal } from "@/src/services/itemDataService";
6
import { ArtifactPolarity, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
6
import { ArtifactPolarity, EquipmentFeatures, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
7
import { ExportRecipes } from "warframe-public-export-plus";
8
import { IInventoryChanges } from "@/src/types/purchaseTypes";
7
9
8
10
const modularWeaponCategory: (WeaponTypeInternal | "Hoverboards")[] = [
9
11
"LongGuns",
10
12
"Pistols",
11
13
"Melee",
12
14
"OperatorAmps",
13
"Hoverboards" // Not sure about hoverboards just coppied from modual crafting
15
"Hoverboards"
14
16
];
15
17
16
18
interface IGildWeaponRequest {
17
19
ItemName: string;
18
Recipe: string; // /Lotus/Weapons/SolarisUnited/LotusGildKitgunBlueprint
20
Recipe: string; // e.g. /Lotus/Weapons/SolarisUnited/LotusGildKitgunBlueprint
19
21
PolarizeSlot?: number;
20
22
PolarizeValue?: ArtifactPolarity;
21
23
ItemId: string;
22
24
Category: WeaponTypeInternal | "Hoverboards";
23
25
}
24
26
25
// In export there no recipes for gild action, so reputation and ressources only consumed visually
26
27
27
export const gildWeaponController: RequestHandler = async (req, res) => {
28
28
const accountId = await getAccountIdForRequest(req);
29
29
const data = getJSONfromString<IGildWeaponRequest>(String(req.body));
@@ -40,7 +40,8 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
40
40
}
41
41
42
42
const weapon = inventory[data.Category][weaponIndex];
43
weapon.Features = EquipmentFeatures.GILDED; // maybe 9 idk if DOUBLE_CAPACITY is also given
43
weapon.Features ??= 0;
44
weapon.Features |= EquipmentFeatures.GILDED;
44
45
weapon.ItemName = data.ItemName;
45
46
weapon.XP = 0;
46
47
if (data.Category != "OperatorAmps" && data.PolarizeSlot && data.PolarizeValue) {
@@ -52,11 +53,29 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
52
53
];
53
54
}
54
55
inventory[data.Category][weaponIndex] = weapon;
55
await inventory.save();
56
const inventoryChanges: IInventoryChanges = {};
57
inventoryChanges[data.Category] = [weapon.toJSON<IEquipmentClient>()];
58
59
const recipe = ExportRecipes[data.Recipe];
60
inventoryChanges.MiscItems = recipe.secretIngredients!.map(ingredient => ({
61
ItemType: ingredient.ItemType,
62
ItemCount: ingredient.ItemCount * -1
63
}));
64
addMiscItems(inventory, inventoryChanges.MiscItems);
56
65
66
const affiliationMods = [];
67
if (recipe.syndicateStandingChange) {
68
const affiliation = inventory.Affiliations.find(x => x.Tag == recipe.syndicateStandingChange!.tag)!;
69
affiliation.Standing += recipe.syndicateStandingChange.value;
70
affiliationMods.push({
71
Tag: recipe.syndicateStandingChange.tag,
72
Standing: recipe.syndicateStandingChange.value
73
});
74
}
75
76
await inventory.save();
57
77
res.json({
58
InventoryChanges: {
59
[data.Category]: [weapon]
60
}
78
InventoryChanges: inventoryChanges,
79
AffiliationMods: affiliationMods
61
80
});
62
81
};