From 20d3ebb8f1d4b01ec636a2e17d2f8f1dc785f44b Mon Sep 17 00:00:00 2001 From: aryan9190 <115806023+aryan9190@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:22:10 +0530 Subject: [PATCH] Create updatePrices.ts --- src/updatePrices.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/updatePrices.ts diff --git a/src/updatePrices.ts b/src/updatePrices.ts new file mode 100644 index 0000000..59efd96 --- /dev/null +++ b/src/updatePrices.ts @@ -0,0 +1,14 @@ +import { farmItems } from './items'; + +export const updatePrices = () => { + farmItems.forEach(item => { + const variance = item.genstore_price_variance || 0.05; // Default 5% variance + const priceFluctuation = item.genstore_sell_to_player_price * variance; + const newPrice = item.genstore_sell_to_player_price + (Math.random() > 0.5 ? priceFluctuation : -priceFluctuation); + + item.genstore_sell_to_player_price = parseFloat(newPrice.toFixed(2)); + item.genstore_buy_from_player_price = parseFloat((newPrice * 0.5).toFixed(2)); // Example: Buy price is half of sell price + }); + + console.log('Prices have been updated.'); +};