diff --git a/package-lock.json b/package-lock.json index d7524f05..486ac1a0 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.42", + "warframe-public-export-plus": "^0.5.43", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" @@ -4073,9 +4073,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.5.42", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.42.tgz", - "integrity": "sha512-up3P5bLKD42Xkr3o7TX9WUwvpJzK88aQTLZ2bB6QWUHdsJxl/Z3TBn+HSd3eouIDTMVUzbTDeDPosSw7TcLegA==" + "version": "0.5.43", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.43.tgz", + "integrity": "sha512-LeF7HmsjOPsJDtgr66x3iMEIAQgcxKNM54VG895FTemgHLLo34UGDyeS1yIfY67WxxbTUgW3MkHQLlCEJXD14w==" }, "node_modules/warframe-riven-info": { "version": "0.1.2", diff --git a/package.json b/package.json index 1a824fd1..eb4ceaa7 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.42", + "warframe-public-export-plus": "^0.5.43", "warframe-riven-info": "^0.1.2", "winston": "^3.17.0", "winston-daily-rotate-file": "^5.0.0" diff --git a/src/controllers/api/guildTechController.ts b/src/controllers/api/guildTechController.ts index 35dffe2d..90714492 100644 --- a/src/controllers/api/guildTechController.ts +++ b/src/controllers/api/guildTechController.ts @@ -2,7 +2,14 @@ import { RequestHandler } from "express"; import { getGuildForRequestEx, getGuildVault, scaleRequiredCount } from "@/src/services/guildService"; import { ExportDojoRecipes, IDojoResearch } from "warframe-public-export-plus"; import { getAccountIdForRequest } from "@/src/services/loginService"; -import { addMiscItems, addRecipes, getInventory, updateCurrency } from "@/src/services/inventoryService"; +import { + addItem, + addMiscItems, + addRecipes, + combineInventoryChanges, + getInventory, + updateCurrency +} from "@/src/services/inventoryService"; import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes"; import { IInventoryChanges } from "@/src/types/purchaseTypes"; import { config } from "@/src/services/configService"; @@ -127,6 +134,20 @@ export const guildTechController: RequestHandler = async (req, res) => { Recipes: recipeChanges } }); + } else if (action == "Fabricate") { + const payload = data as IGuildTechFabricateRequest; + const recipe = ExportDojoRecipes.fabrications[payload.RecipeType]; + const inventory = await getInventory(accountId); + const inventoryChanges: IInventoryChanges = updateCurrency(inventory, recipe.price, false); + inventoryChanges.MiscItems = recipe.ingredients.map(x => ({ + ItemType: x.ItemType, + ItemCount: x.ItemCount * -1 + })); + addMiscItems(inventory, inventoryChanges.MiscItems); + combineInventoryChanges(inventoryChanges, (await addItem(inventory, recipe.resultType)).InventoryChanges); + await inventory.save(); + // Not a mistake: This response uses `inventoryChanges` instead of `InventoryChanges`. + res.json({ inventoryChanges: inventoryChanges }); } else { throw new Error(`unknown guildTech action: ${data.Action}`); } @@ -144,10 +165,12 @@ const processFundedProject = ( } }; -type TGuildTechRequest = { - Action: string; -} & Partial & - Partial; +type TGuildTechRequest = + | ({ + Action: string; + } & Partial & + Partial) + | IGuildTechFabricateRequest; interface IGuildTechStartFields { Mode: "Guild"; @@ -164,3 +187,9 @@ interface IGuildTechContributeFields { VaultCredits: number; VaultMiscItems: IMiscItem[]; } + +interface IGuildTechFabricateRequest { + Action: "Fabricate"; + Mode: "Guild"; + RecipeType: string; +}