feat: fabricate research #1150
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -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",
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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 = {
 | 
			
		||||
type TGuildTechRequest =
 | 
			
		||||
    | ({
 | 
			
		||||
          Action: string;
 | 
			
		||||
      } & Partial<IGuildTechStartFields> &
 | 
			
		||||
    Partial<IGuildTechContributeFields>;
 | 
			
		||||
          Partial<IGuildTechContributeFields>)
 | 
			
		||||
    | IGuildTechFabricateRequest;
 | 
			
		||||
 | 
			
		||||
interface IGuildTechStartFields {
 | 
			
		||||
    Mode: "Guild";
 | 
			
		||||
@ -164,3 +187,9 @@ interface IGuildTechContributeFields {
 | 
			
		||||
    VaultCredits: number;
 | 
			
		||||
    VaultMiscItems: IMiscItem[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface IGuildTechFabricateRequest {
 | 
			
		||||
    Action: "Fabricate";
 | 
			
		||||
    Mode: "Guild";
 | 
			
		||||
    RecipeType: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user