mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Quest mode: fix cards bought and sold for 0 credits (#2362)
* - Fix cards bought and sold for 0 credits in Quest mode. * - Fix multiplier pulling the price below 1 credit. * - Remove a debug line.
This commit is contained in:
@@ -127,6 +127,10 @@ public class QuestSpellShop {
|
|||||||
value *= foilMultiplier;
|
value *= foilMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value == 0) {
|
||||||
|
value = 1; // no freebies for the shop or the player, things should cost at least 1 credit
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +149,7 @@ public class QuestSpellShop {
|
|||||||
public static final Function<Entry<? extends InventoryItem, Integer>, Object> fnPriceSellGet = new Function<Entry<? extends InventoryItem, Integer>, Object>() {
|
public static final Function<Entry<? extends InventoryItem, Integer>, Object> fnPriceSellGet = new Function<Entry<? extends InventoryItem, Integer>, Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
|
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
|
||||||
return (int) (multiplier * getCardValue(from.getKey()));
|
return Math.max((int) (multiplier * getCardValue(from.getKey())), 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final Function<Entry<InventoryItem, Integer>, Comparable<?>> fnDeckCompare = new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
|
public static final Function<Entry<InventoryItem, Integer>, Comparable<?>> fnDeckCompare = new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
|
||||||
@@ -296,7 +300,7 @@ public class QuestSpellShop {
|
|||||||
for (Entry<InventoryItem, Integer> itemEntry : items) {
|
for (Entry<InventoryItem, Integer> itemEntry : items) {
|
||||||
final InventoryItem item = itemEntry.getKey();
|
final InventoryItem item = itemEntry.getKey();
|
||||||
if (item instanceof PaperCard) {
|
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;
|
return totalValue;
|
||||||
@@ -314,7 +318,7 @@ public class QuestSpellShop {
|
|||||||
if (item instanceof PaperCard) {
|
if (item instanceof PaperCard) {
|
||||||
final int qty = itemEntry.getValue();
|
final int qty = itemEntry.getValue();
|
||||||
itemsToSell.add(item, qty);
|
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<InventoryItem, Integer> itemEntry : itemsToSell) {
|
for (Entry<InventoryItem, Integer> itemEntry : itemsToSell) {
|
||||||
|
|
||||||
final PaperCard card = (PaperCard) itemEntry.getKey();
|
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);
|
sellCard(card, itemEntry.getValue(), pricePerCard);
|
||||||
|
|
||||||
@@ -391,7 +396,8 @@ public class QuestSpellShop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PaperCard card = (PaperCard)item.getKey();
|
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);
|
sellCard(card, item.getValue(), pricePerCard);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user