diff --git a/package-lock.json b/package-lock.json index cdd0ef07..ae4317a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.2", - "warframe-public-export-plus": "^0.5.17", + "warframe-public-export-plus": "^0.5.18", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" @@ -3778,9 +3778,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.17", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.17.tgz", - "integrity": "sha512-AWOfUxDHz+UmpbA9ZUGLIrP+3eQOiVq9tw1FXgx7ySkJLEnZUsoi3wn0IFiavSy2iE6JQIyCiSIZCJQTaCV6kA==" + "version": "0.5.18", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.18.tgz", + "integrity": "sha512-wUaW5Ua5tXHOYkKJxbealdCcTnRLUN7UCkvYOJEwlB/H14EBzDaqxg4engGqzbq4H8fmttyp3EUo4vazSaxZWg==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index a04dfe24..ed389137 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "copyfiles": "^2.4.1", "express": "^5", "mongoose": "^8.9.2", - "warframe-public-export-plus": "^0.5.17", + "warframe-public-export-plus": "^0.5.18", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" diff --git a/src/controllers/api/fishmongerController.ts b/src/controllers/api/fishmongerController.ts index 3d572948..e834540c 100644 --- a/src/controllers/api/fishmongerController.ts +++ b/src/controllers/api/fishmongerController.ts @@ -6,30 +6,48 @@ import { RequestHandler } from "express"; import { ExportResources } from "warframe-public-export-plus"; export const fishmongerController: RequestHandler = async (req, res) => { - if (!req.query.dissect) { - throw new Error("expected fishmonger request to be for dissection"); - } const accountId = await getAccountIdForRequest(req); const inventory = await getInventory(accountId); const body = getJSONfromString(String(req.body)) as IFishmongerRequest; const miscItemChanges: IMiscItem[] = []; + let syndicateTag: string | undefined; + let standingChange = 0; for (const fish of body.Fish) { - for (const part of ExportResources[fish.ItemType].dissectionParts!) { - const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType); - if (partItem) { - partItem.ItemCount += part.ItemCount; - } else { - miscItemChanges.push(part); + const fishData = ExportResources[fish.ItemType]; + if (req.query.dissect == "1") { + for (const part of fishData.dissectionParts!) { + const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType); + if (partItem) { + partItem.ItemCount += part.ItemCount; + } else { + miscItemChanges.push(part); + } } + } else { + syndicateTag = fishData.syndicateTag!; + standingChange += fishData.standingBonus!; } miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 }); } addMiscItems(inventory, miscItemChanges); + if (standingChange && syndicateTag) { + const syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag); + if (syndicate !== undefined) { + syndicate.Standing += standingChange; + } else { + inventory.Affiliations.push({ + Tag: syndicateTag, + Standing: standingChange + }); + } + } await inventory.save(); res.json({ InventoryChanges: { MiscItems: miscItemChanges - } + }, + SyndicateTag: syndicateTag, + StandingChange: standingChange }); };