feat: fabricate research
All checks were successful
Build / build (22) (push) Successful in 1m3s
Build / build (20) (pull_request) Successful in 40s
Build / build (22) (pull_request) Successful in 1m2s
Build / build (18) (push) Successful in 45s
Build / build (20) (push) Successful in 1m0s
Build / build (18) (pull_request) Successful in 1m4s

This commit is contained in:
Sainan 2025-03-11 12:50:56 +01:00
parent cf62320857
commit 79ac6eef40
3 changed files with 39 additions and 10 deletions

8
package-lock.json generated
View File

@ -17,7 +17,7 @@
"mongoose": "^8.11.0", "mongoose": "^8.11.0",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"typescript": ">=4.7.4 <5.6.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", "warframe-riven-info": "^0.1.2",
"winston": "^3.17.0", "winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0" "winston-daily-rotate-file": "^5.0.0"
@ -4073,9 +4073,9 @@
} }
}, },
"node_modules/warframe-public-export-plus": { "node_modules/warframe-public-export-plus": {
"version": "0.5.42", "version": "0.5.43",
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.42.tgz", "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.43.tgz",
"integrity": "sha512-up3P5bLKD42Xkr3o7TX9WUwvpJzK88aQTLZ2bB6QWUHdsJxl/Z3TBn+HSd3eouIDTMVUzbTDeDPosSw7TcLegA==" "integrity": "sha512-LeF7HmsjOPsJDtgr66x3iMEIAQgcxKNM54VG895FTemgHLLo34UGDyeS1yIfY67WxxbTUgW3MkHQLlCEJXD14w=="
}, },
"node_modules/warframe-riven-info": { "node_modules/warframe-riven-info": {
"version": "0.1.2", "version": "0.1.2",

View File

@ -22,7 +22,7 @@
"mongoose": "^8.11.0", "mongoose": "^8.11.0",
"morgan": "^1.10.0", "morgan": "^1.10.0",
"typescript": ">=4.7.4 <5.6.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", "warframe-riven-info": "^0.1.2",
"winston": "^3.17.0", "winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0" "winston-daily-rotate-file": "^5.0.0"

View File

@ -2,7 +2,14 @@ import { RequestHandler } from "express";
import { getGuildForRequestEx, getGuildVault, scaleRequiredCount } from "@/src/services/guildService"; import { getGuildForRequestEx, getGuildVault, scaleRequiredCount } from "@/src/services/guildService";
import { ExportDojoRecipes, IDojoResearch } from "warframe-public-export-plus"; import { ExportDojoRecipes, IDojoResearch } from "warframe-public-export-plus";
import { getAccountIdForRequest } from "@/src/services/loginService"; 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 { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
import { IInventoryChanges } from "@/src/types/purchaseTypes"; import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { config } from "@/src/services/configService"; import { config } from "@/src/services/configService";
@ -127,6 +134,20 @@ export const guildTechController: RequestHandler = async (req, res) => {
Recipes: recipeChanges 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 { } else {
throw new Error(`unknown guildTech action: ${data.Action}`); throw new Error(`unknown guildTech action: ${data.Action}`);
} }
@ -144,10 +165,12 @@ const processFundedProject = (
} }
}; };
type TGuildTechRequest = { type TGuildTechRequest =
Action: string; | ({
} & Partial<IGuildTechStartFields> & Action: string;
Partial<IGuildTechContributeFields>; } & Partial<IGuildTechStartFields> &
Partial<IGuildTechContributeFields>)
| IGuildTechFabricateRequest;
interface IGuildTechStartFields { interface IGuildTechStartFields {
Mode: "Guild"; Mode: "Guild";
@ -164,3 +187,9 @@ interface IGuildTechContributeFields {
VaultCredits: number; VaultCredits: number;
VaultMiscItems: IMiscItem[]; VaultMiscItems: IMiscItem[];
} }
interface IGuildTechFabricateRequest {
Action: "Fabricate";
Mode: "Guild";
RecipeType: string;
}