Skip to content

Commit

Permalink
Fixed prices that were too low
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Sep 6, 2022
1 parent 79bc39f commit 9f9ef0a
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/helpers/pile-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,25 +440,6 @@ export function getItemPrices(item, {

itemFlagData = itemFlagData || getItemFlagData(item);

const overallCost = Number(getProperty(item.toObject(), game.itempiles.ITEM_PRICE_ATTRIBUTE));
const hasOtherPrices = itemFlagData.prices.filter(priceGroup => priceGroup.length).length > 0;

if (itemFlagData?.free || (!itemFlagData.disableNormalCost && overallCost === 0 && !hasOtherPrices)) {
priceData.push({
free: true,
basePrices: [],
basePriceString: "",
prices: [],
priceString: "",
totalCost: 0,
baseCost: 0,
primary: true,
maxQuantity: Infinity,
quantity
})
return priceData;
}

let merchant = sellerFlagData ? seller : buyer;

// Retrieve the item price modifiers
Expand All @@ -481,6 +462,9 @@ export function getItemPrices(item, {
return priceData;
}

const overallCost = Number(getProperty(item.toObject(), game.itempiles.ITEM_PRICE_ATTRIBUTE));
const hasOtherPrices = itemFlagData.prices.filter(priceGroup => priceGroup.length).length > 0;

const currencyList = getActorCurrencyList(merchant);
const currencies = getActorCurrencies(merchant, { currencyList, getAll: true });

Expand All @@ -489,6 +473,22 @@ export function getItemPrices(item, {
const smallestExchangeRate = Math.min(...currencies.map(currency => currency.exchangeRate));
const decimals = smallestExchangeRate.toString().split(".")[1].length;

if (itemFlagData?.free || (!itemFlagData.disableNormalCost && (overallCost === 0 || overallCost < smallestExchangeRate) && !hasOtherPrices)) {
priceData.push({
free: true,
basePrices: [],
basePriceString: "",
prices: [],
priceString: "",
totalCost: 0,
baseCost: 0,
primary: true,
maxQuantity: Infinity,
quantity
})
return priceData;
}

// If the item does include its normal cost, we calculate that here
if (!itemFlagData.disableNormalCost) {

Expand Down

0 comments on commit 9f9ef0a

Please sign in to comment.