This commit is contained in:
@@ -61,19 +61,19 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
throw new Error(`no pending recipe found with id ${fromOid(recipeId)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//check recipe is indeed ready to be completed
|
||||
// if (pendingRecipe.CompletionDate > new Date()) {
|
||||
// throw new Error(`recipe ${pendingRecipe._id} is not ready to be completed`);
|
||||
// }
|
||||
|
||||
|
||||
inventory.PendingRecipes.pull(pendingRecipe._id);
|
||||
|
||||
|
||||
const recipe = getRecipe(pendingRecipe.ItemType);
|
||||
if (!recipe) {
|
||||
throw new Error(`no completed item found for recipe ${pendingRecipe._id.toString()}`);
|
||||
}
|
||||
|
||||
|
||||
if (req.query.cancel) {
|
||||
const inventoryChanges: IInventoryChanges = {};
|
||||
await refundRecipeIngredients(inventory, inventoryChanges, recipe, pendingRecipe);
|
||||
@@ -81,7 +81,7 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
res.json(inventoryChanges); // Not a bug: In the specific case of cancelling a recipe, InventoryChanges are expected to be the root.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await claimCompletedRecipe(account, inventory, recipe, pendingRecipe, resp, req.query.rush);
|
||||
}
|
||||
} else {
|
||||
@@ -165,9 +165,12 @@ const claimCompletedRecipe = async (
|
||||
const progress = secondsElapsed / recipe.buildTime;
|
||||
logger.debug(`rushing recipe at ${Math.trunc(progress * 100)}% completion`);
|
||||
// U18 introduced rush cost scaling, don't use it for older versions.
|
||||
if (account.BuildLabel && version_compare(account.BuildLabel, "2015.12.03.00.00") >= 0) { // Haven't found the real build label for U18.0.0 yet, but this works
|
||||
if (account.BuildLabel && version_compare(account.BuildLabel, "2015.12.03.00.00") >= 0) {
|
||||
// Haven't found the real build label for U18.0.0 yet, but this works
|
||||
cost =
|
||||
progress > 0.5 ? Math.round(recipe.skipBuildTimePrice * (1 - (progress - 0.5))) : recipe.skipBuildTimePrice;
|
||||
progress > 0.5
|
||||
? Math.round(recipe.skipBuildTimePrice * (1 - (progress - 0.5)))
|
||||
: recipe.skipBuildTimePrice;
|
||||
}
|
||||
combineInventoryChanges(resp.InventoryChanges, updateCurrency(inventory, cost, true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user