Skip to content

Commit

Permalink
Create updatePrices.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aryan9190 authored Aug 27, 2024
1 parent 108bae9 commit 20d3ebb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/updatePrices.ts
Original file line number Diff line number Diff line change
@@ -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.');
};

0 comments on commit 20d3ebb

Please sign in to comment.