feat: trade in modular weapons for standing
All checks were successful
Build / build (22) (push) Successful in 41s
Build / build (20) (push) Successful in 1m1s
Build / build (18) (push) Successful in 1m3s
Build / build (18) (pull_request) Successful in 42s
Build / build (20) (pull_request) Successful in 1m1s
Build / build (22) (pull_request) Successful in 56s

This commit is contained in:
Sainan 2025-03-13 12:27:49 +01:00
parent 292ac9d41b
commit 14167bfdf8
3 changed files with 47 additions and 13 deletions

8
package-lock.json generated
View File

@ -17,7 +17,7 @@
"mongoose": "^8.11.0",
"morgan": "^1.10.0",
"typescript": ">=4.7.4 <5.6.0",
"warframe-public-export-plus": "^0.5.43",
"warframe-public-export-plus": "^0.5.44",
"warframe-riven-info": "^0.1.2",
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0"
@ -4006,9 +4006,9 @@
}
},
"node_modules/warframe-public-export-plus": {
"version": "0.5.43",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.43.tgz",
"integrity": "sha512-LeF7HmsjOPsJDtgr66x3iMEIAQgcxKNM54VG895FTemgHLLo34UGDyeS1yIfY67WxxbTUgW3MkHQLlCEJXD14w=="
"version": "0.5.44",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.44.tgz",
"integrity": "sha512-0EH3CQBCuuELiLBL1brc/o6Qx8CK723TJF5o68VXc60ha93Juo6LQ+dV+QgzFvVQ5RZTjBLtKB4MP8qw3YHCUQ=="
},
"node_modules/warframe-riven-info": {
"version": "0.1.2",

View File

@ -22,7 +22,7 @@
"mongoose": "^8.11.0",
"morgan": "^1.10.0",
"typescript": ">=4.7.4 <5.6.0",
"warframe-public-export-plus": "^0.5.43",
"warframe-public-export-plus": "^0.5.44",
"warframe-riven-info": "^0.1.2",
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0"

View File

@ -1,10 +1,19 @@
import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { addMiscItems, getInventory, getStandingLimit, updateStandingLimit } from "@/src/services/inventoryService";
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
import {
addMiscItems,
freeUpSlot,
getInventory,
getStandingLimit,
updateStandingLimit
} from "@/src/services/inventoryService";
import { IMiscItem, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
import { IOid } from "@/src/types/commonTypes";
import { ExportSyndicates } from "warframe-public-export-plus";
import { ExportSyndicates, ExportWeapons } from "warframe-public-export-plus";
import { getMaxStanding } from "@/src/helpers/syndicateStandingHelper";
import { logger } from "@/src/utils/logger";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
export const syndicateStandingBonusController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -12,6 +21,7 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
const syndicateMeta = ExportSyndicates[request.Operation.AffiliationTag];
// Process items
let gainedStanding = 0;
request.Operation.Items.forEach(item => {
const medallion = (syndicateMeta.medallions ?? []).find(medallion => medallion.itemType == item.ItemType);
@ -21,9 +31,35 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
item.ItemCount *= -1;
});
const inventory = await getInventory(accountId);
addMiscItems(inventory, request.Operation.Items);
const inventoryChanges: IInventoryChanges = {};
inventoryChanges.MiscItems = request.Operation.Items;
// Process modular weapon
if (request.Operation.ModularWeaponId.$oid != "000000000000000000000000") {
const category = req.query.Category as "LongGuns" | "Pistols" | "Melee" | "OperatorAmps";
const weapon = inventory[category].id(request.Operation.ModularWeaponId.$oid)!;
if (gainedStanding !== 0) {
throw new Error(`modular weapon standing bonus should be mutually exclusive`);
}
weapon.ModularParts!.forEach(part => {
const partStandingBonus = ExportWeapons[part].donationStandingBonus;
if (partStandingBonus === undefined) {
throw new Error(`no standing bonus for ${part}`);
}
logger.debug(`modular weapon part ${part} gives ${partStandingBonus} standing`);
gainedStanding += partStandingBonus;
});
if (weapon.Features && (weapon.Features & EquipmentFeatures.GILDED) != 0) {
gainedStanding *= 2;
}
inventoryChanges.RemovedIdItems = [{ ItemId: request.Operation.ModularWeaponId }];
inventory[category].pull({ _id: request.Operation.ModularWeaponId.$oid });
const slotBin = category == "OperatorAmps" ? InventorySlot.AMPS : InventorySlot.WEAPONS;
freeUpSlot(inventory, slotBin);
inventoryChanges[slotBin] = { count: -1, platinum: 0, Slots: 1 };
}
let syndicate = inventory.Affiliations.find(x => x.Tag == request.Operation.AffiliationTag);
if (!syndicate) {
@ -50,9 +86,7 @@ export const syndicateStandingBonusController: RequestHandler = async (req, res)
await inventory.save();
res.json({
InventoryChanges: {
MiscItems: request.Operation.Items
},
InventoryChanges: inventoryChanges,
AffiliationMods: [
{
Tag: request.Operation.AffiliationTag,
@ -67,6 +101,6 @@ interface ISyndicateStandingBonusRequest {
AffiliationTag: string;
AlternateBonusReward: ""; // ???
Items: IMiscItem[];
ModularWeaponId: IOid;
};
ModularWeaponId: IOid; // Seems to just be "000000000000000000000000", also note there's a "Category" query field
}