From 23f8901505a081101298be5505fe2f22d37a2fb4 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 31 Mar 2025 04:14:35 -0700 Subject: [PATCH] fix: reduce platinum cost of rushing recipes based on progress (#1393) Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1393 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/api/claimCompletedRecipeController.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/controllers/api/claimCompletedRecipeController.ts b/src/controllers/api/claimCompletedRecipeController.ts index 2d3c480f..f95a950f 100644 --- a/src/controllers/api/claimCompletedRecipeController.ts +++ b/src/controllers/api/claimCompletedRecipeController.ts @@ -116,9 +116,15 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) = ]); } if (req.query.rush) { + const end = Math.trunc(pendingRecipe.CompletionDate.getTime() / 1000); + const start = end - recipe.buildTime; + const secondsElapsed = Math.trunc(Date.now() / 1000) - start; + const progress = secondsElapsed / recipe.buildTime; + logger.debug(`rushing recipe at ${Math.trunc(progress * 100)}% completion`); + const cost = Math.round(recipe.skipBuildTimePrice * (1 - (progress - 0.5))); InventoryChanges = { ...InventoryChanges, - ...updateCurrency(inventory, recipe.skipBuildTimePrice, true) + ...updateCurrency(inventory, cost, true) }; } if (recipe.secretIngredientAction != "SIA_UNBRAND") {