fix: consume resources & standing required for gilding
All checks were successful
Build / build (20) (push) Successful in 41s
Build / build (18) (push) Successful in 1m3s
Build / build (18) (pull_request) Successful in 42s
Build / build (20) (pull_request) Successful in 59s
Build / build (22) (push) Successful in 1m13s
Build / build (22) (pull_request) Successful in 42s

This commit is contained in:
Sainan 2025-03-09 11:39:52 +01:00
parent d5feec2c37
commit 4e42a36c2b

View File

@ -1,29 +1,29 @@
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService"; import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers"; import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService"; import { addMiscItems, getInventory } from "@/src/services/inventoryService";
import { WeaponTypeInternal } from "@/src/services/itemDataService"; import { WeaponTypeInternal } from "@/src/services/itemDataService";
import { ArtifactPolarity, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes"; import { ArtifactPolarity, EquipmentFeatures, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ExportRecipes } from "warframe-public-export-plus";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
const modularWeaponCategory: (WeaponTypeInternal | "Hoverboards")[] = [ const modularWeaponCategory: (WeaponTypeInternal | "Hoverboards")[] = [
"LongGuns", "LongGuns",
"Pistols", "Pistols",
"Melee", "Melee",
"OperatorAmps", "OperatorAmps",
"Hoverboards" // Not sure about hoverboards just coppied from modual crafting "Hoverboards"
]; ];
interface IGildWeaponRequest { interface IGildWeaponRequest {
ItemName: string; ItemName: string;
Recipe: string; // /Lotus/Weapons/SolarisUnited/LotusGildKitgunBlueprint Recipe: string; // e.g. /Lotus/Weapons/SolarisUnited/LotusGildKitgunBlueprint
PolarizeSlot?: number; PolarizeSlot?: number;
PolarizeValue?: ArtifactPolarity; PolarizeValue?: ArtifactPolarity;
ItemId: string; ItemId: string;
Category: WeaponTypeInternal | "Hoverboards"; Category: WeaponTypeInternal | "Hoverboards";
} }
// In export there no recipes for gild action, so reputation and ressources only consumed visually
export const gildWeaponController: RequestHandler = async (req, res) => { export const gildWeaponController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req); const accountId = await getAccountIdForRequest(req);
const data = getJSONfromString<IGildWeaponRequest>(String(req.body)); const data = getJSONfromString<IGildWeaponRequest>(String(req.body));
@ -40,7 +40,8 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
} }
const weapon = inventory[data.Category][weaponIndex]; const weapon = inventory[data.Category][weaponIndex];
weapon.Features = EquipmentFeatures.GILDED; // maybe 9 idk if DOUBLE_CAPACITY is also given weapon.Features ??= 0;
weapon.Features |= EquipmentFeatures.GILDED;
weapon.ItemName = data.ItemName; weapon.ItemName = data.ItemName;
weapon.XP = 0; weapon.XP = 0;
if (data.Category != "OperatorAmps" && data.PolarizeSlot && data.PolarizeValue) { if (data.Category != "OperatorAmps" && data.PolarizeSlot && data.PolarizeValue) {
@ -52,11 +53,29 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
]; ];
} }
inventory[data.Category][weaponIndex] = weapon; inventory[data.Category][weaponIndex] = weapon;
await inventory.save(); const inventoryChanges: IInventoryChanges = {};
inventoryChanges[data.Category] = [weapon.toJSON<IEquipmentClient>()];
const recipe = ExportRecipes[data.Recipe];
inventoryChanges.MiscItems = recipe.secretIngredients!.map(ingredient => ({
ItemType: ingredient.ItemType,
ItemCount: ingredient.ItemCount * -1
}));
addMiscItems(inventory, inventoryChanges.MiscItems);
const affiliationMods = [];
if (recipe.syndicateStandingChange) {
const affiliation = inventory.Affiliations.find(x => x.Tag == recipe.syndicateStandingChange!.tag)!;
affiliation.Standing += recipe.syndicateStandingChange.value;
affiliationMods.push({
Tag: recipe.syndicateStandingChange.tag,
Standing: recipe.syndicateStandingChange.value
});
}
await inventory.save();
res.json({ res.json({
InventoryChanges: { InventoryChanges: inventoryChanges,
[data.Category]: [weapon] AffiliationMods: affiliationMods
}
}); });
}; };