diff --git a/package-lock.json b/package-lock.json index a9e619d9..a9c49d28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index eb4ceaa7..16610896 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/controllers/api/syndicateStandingBonusController.ts b/src/controllers/api/syndicateStandingBonusController.ts index 6899ee3e..4067e9db 100644 --- a/src/controllers/api/syndicateStandingBonusController.ts +++ b/src/controllers/api/syndicateStandingBonusController.ts @@ -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 }