diff --git a/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java b/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java index d672ebfae5b..6cf3cead630 100644 --- a/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java +++ b/forge-gui/src/main/java/forge/gamemodes/quest/QuestSpellShop.java @@ -127,6 +127,10 @@ public class QuestSpellShop { value *= foilMultiplier; } + if (value == 0) { + value = 1; // no freebies for the shop or the player, things should cost at least 1 credit + } + return value; } @@ -145,7 +149,7 @@ public class QuestSpellShop { public static final Function, Object> fnPriceSellGet = new Function, Object>() { @Override public Object apply(final Entry from) { - return (int) (multiplier * getCardValue(from.getKey())); + return Math.max((int) (multiplier * getCardValue(from.getKey())), 1); } }; public static final Function, Comparable> fnDeckCompare = new Function, Comparable>() { @@ -296,7 +300,7 @@ public class QuestSpellShop { for (Entry itemEntry : items) { final InventoryItem item = itemEntry.getKey(); if (item instanceof PaperCard) { - totalValue += itemEntry.getValue() * Math.min((int) (multiplier * getCardValue(item)), sellPriceLimit); + totalValue += itemEntry.getValue() * Math.max(Math.min((int) (multiplier * getCardValue(item)), sellPriceLimit), 1); } } return totalValue; @@ -314,7 +318,7 @@ public class QuestSpellShop { if (item instanceof PaperCard) { final int qty = itemEntry.getValue(); itemsToSell.add(item, qty); - totalReceived += qty * Math.min((int) (multiplier * getCardValue(item)), sellPriceLimit); + totalReceived += qty * Math.max(Math.min((int) (multiplier * getCardValue(item)), sellPriceLimit), 1); } } @@ -337,7 +341,8 @@ public class QuestSpellShop { for (Entry itemEntry : itemsToSell) { final PaperCard card = (PaperCard) itemEntry.getKey(); - final int pricePerCard = Math.min((int) (multiplier * getCardValue(card)), FModel.getQuest().getCards().getSellPriceLimit()); + final int pricePerCard = Math.max(Math.min((int) (multiplier * getCardValue(card)), 1), + FModel.getQuest().getCards().getSellPriceLimit()); sellCard(card, itemEntry.getValue(), pricePerCard); @@ -391,7 +396,8 @@ public class QuestSpellShop { } PaperCard card = (PaperCard)item.getKey(); - final int pricePerCard = Math.min((int) (multiplier * getCardValue(card)), FModel.getQuest().getCards().getSellPriceLimit()); + final int pricePerCard = Math.max(Math.min((int) (multiplier * getCardValue(card)), 1), + FModel.getQuest().getCards().getSellPriceLimit()); sellCard(card, item.getValue(), pricePerCard);