fix: not being able to purchase or craft some recipes (#314)
This commit is contained in:
parent
f15105a048
commit
e8d7e17611
@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import { logger } from "@/src/utils/logger";
|
||||
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
|
||||
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
|
||||
import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
|
||||
import { ExportRecipes } from "warframe-public-export-plus";
|
||||
|
||||
export const createInventory = async (
|
||||
accountOwnerId: Types.ObjectId,
|
||||
@ -70,6 +71,25 @@ export const addItem = async (
|
||||
typeName: string,
|
||||
quantity: number = 1
|
||||
): Promise<{ InventoryChanges: object }> => {
|
||||
// Strict typing
|
||||
if (typeName in ExportRecipes) {
|
||||
const inventory = await getInventory(accountId);
|
||||
const recipeChanges = [
|
||||
{
|
||||
ItemType: typeName,
|
||||
ItemCount: quantity
|
||||
} satisfies ITypeCount
|
||||
];
|
||||
addRecipes(inventory, recipeChanges);
|
||||
await inventory.save();
|
||||
return {
|
||||
InventoryChanges: {
|
||||
Recipes: recipeChanges
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Path-based duck typing
|
||||
switch (typeName.substr(1).split("/")[1]) {
|
||||
case "Powersuits":
|
||||
if (typeName.includes("EntratiMech")) {
|
||||
@ -187,24 +207,6 @@ export const addItem = async (
|
||||
}
|
||||
}
|
||||
}
|
||||
case "Recipes":
|
||||
case "Consumables": {
|
||||
// Blueprints for Ciphers, Antitoxins
|
||||
const inventory = await getInventory(accountId);
|
||||
const recipeChanges = [
|
||||
{
|
||||
ItemType: typeName,
|
||||
ItemCount: quantity
|
||||
} satisfies ITypeCount
|
||||
];
|
||||
addRecipes(inventory, recipeChanges);
|
||||
await inventory.save();
|
||||
return {
|
||||
InventoryChanges: {
|
||||
Recipes: recipeChanges
|
||||
}
|
||||
};
|
||||
}
|
||||
case "Restoratives": // Codex Scanner, Remote Observer, Starburst
|
||||
const inventory = await getInventory(accountId);
|
||||
const consumablesChanges = [
|
||||
|
@ -1,8 +1,15 @@
|
||||
import { getIndexAfter } from "@/src/helpers/stringHelpers";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items";
|
||||
import Items, { 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">;
|
||||
@ -100,13 +107,9 @@ export const blueprintNames = Object.fromEntries(
|
||||
.map(name => [name, craftNames[name]])
|
||||
);
|
||||
|
||||
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) => {
|
||||
|
@ -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`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user