fix: not being able to purchase or craft some recipes #314

Merged
Sainan merged 3 commits from fix-recipes into main 2024-06-17 07:41:02 -07:00
3 changed files with 18 additions and 15 deletions
Showing only changes of commit 9a0e4e42d7 - Show all commits

View File

@ -48,6 +48,9 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
res.json({});
} else {
logger.debug("Claiming Recipe", { buildable, pendingRecipe });
if (buildable.consumeOnUse) {
// TODO: Remove one instance of this recipe, and include that in InventoryChanges.
}
let currencyChanges = {};
if (req.query.rush && buildable.skipBuildTimePrice) {
currencyChanges = await updateCurrency(buildable.skipBuildTimePrice, true, accountId);
@ -55,7 +58,7 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
res.json({
InventoryChanges: {
...currencyChanges,
...(await addItem(accountId, buildable.uniqueName, buildable.buildQuantity)).InventoryChanges
...(await addItem(accountId, buildable.resultType, buildable.num)).InventoryChanges
}
});
}

View File

@ -2,7 +2,14 @@ import { getIndexAfter } from "@/src/helpers/stringHelpers";
import { logger } from "@/src/utils/logger";
import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items";
import badItems from "@/static/json/exclude-mods.json";
import { dict_en, ExportWarframes, ExportWeapons, IPowersuit } from "warframe-public-export-plus";
import {
dict_en,
ExportRecipes,
ExportWarframes,
ExportWeapons,
IPowersuit,
IRecipe
} from "warframe-public-export-plus";
export type MinWarframe = Omit<Warframe, "patchlogs">;
export type MinWeapon = Omit<Weapon, "patchlogs">;
@ -102,11 +109,9 @@ export const blueprintNames = Object.fromEntries(
const buildables = items.filter(item => !!(item as Buildable).components);
export const getItemByBlueprint = (uniqueName: string): (MinItem & Buildable) | undefined => {
const item = buildables.find(item =>
(item as Buildable).components?.find(component => component.uniqueName === uniqueName)
);
return item;
// Gets a recipe by its uniqueName
export const getItemByBlueprint = (uniqueName: string): IRecipe | undefined => {
return ExportRecipes[uniqueName];
};
export const getExalted = (uniqueName: string) => {

View File

@ -34,9 +34,9 @@ export const startRecipe = async (recipeName: string, accountId: string) => {
throw new Error(`unknown recipe ${recipeName}`);
}
const componentsNeeded = recipe.components?.map(component => ({
uniqueName: component.uniqueName,
count: component.itemCount
const componentsNeeded = recipe.ingredients.map(component => ({
uniqueName: component.ItemType,
count: component.ItemCount
}));
if (!componentsNeeded) {
@ -47,11 +47,6 @@ export const startRecipe = async (recipeName: string, accountId: string) => {
//TODO: consume components used
//await updateResources(accountId, componentsNeeded);
//might be redundant
if (recipe.consumeOnBuild) {
//consume
}
if (!recipe.buildTime) {
logger.error(`recipe ${recipeName} has no build time`);
throw new Error(`recipe ${recipeName} has no build time`);