diff --git a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java index df5809ca4a2..75d49d917d8 100644 --- a/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java +++ b/forge-gui-mobile/src/forge/adventure/data/AdventureEventData.java @@ -606,7 +606,7 @@ public class AdventureEventData implements Serializable { description += "\n"; } description += "Prizes\n3 round wins: 500 gold\n2 round wins: 200 gold\n1 round win: 100 gold\n"; - description += "Finishing event will award an unsellable copy of each card in your Jumpstart deck."; + description += "Participating in this event will award a valueless copy of each card in your Jumpstart deck."; } return description; } diff --git a/forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java b/forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java index 1f05efa48c8..36ead8ceeaf 100644 --- a/forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java +++ b/forge-gui-mobile/src/forge/adventure/player/AdventurePlayer.java @@ -908,14 +908,45 @@ public class AdventurePlayer implements Serializable, SaveFileContent { } public int cardSellPrice(PaperCard card) { + int valuable = cards.count(card) - noSellCards.count(card); + if (valuable == 0) { + return 0; + } + + int basePrice = (int) (CardUtil.getCardPrice(card) * difficultyData.sellFactor); + float townPriceModifier = currentLocationChanges == null ? 1f : currentLocationChanges.getTownPriceModifier(); - return (int) (CardUtil.getCardPrice(card) * difficultyData.sellFactor * (2.0f - townPriceModifier)); + return (int) (basePrice * difficultyData.sellFactor * (2.0f - townPriceModifier)); } - public void sellCard(PaperCard card, Integer result) { - float price = cardSellPrice(card) * result; - cards.remove(card, result); - addGold((int) price); + public int sellCard(PaperCard card, Integer result, boolean addGold) { + // When selling cards, always try to sell cards worth something before selling cards that aren't worth anything + if (result == null || result < 1) return 0; + + float earned = 0; + + int valuableCount = cards.count(card) - noSellCards.count(card); + int noValueToSell = result - valuableCount; + int amountValuableToSell = Math.min(result, valuableCount); + + if (amountValuableToSell > 0) { + earned += cardSellPrice(card) * amountValuableToSell; + cards.remove(card, amountValuableToSell); + } + if (noValueToSell > 0) { + cards.remove(card, noValueToSell); + noSellCards.remove(card, noValueToSell); + } + + if (addGold) { + addGold((int) earned); + } + + return (int) earned; + } + + public int sellOneCard(PaperCard card) { + return sellCard(card, 1, false); } public void removeItem(String name) { @@ -1166,8 +1197,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent { ItemPool sellableCards = new ItemPool<>(PaperCard.class); sellableCards.addAllFlat(cards.toFlatList()); - // 1. Remove cards you can't sell - sellableCards.removeAll(noSellCards); + // Nosell cards used to be filtered out here. Instead we're going to replace their value with 0 + // 1a. Potentially return here if we want to give config option to sell cards from decks // but would need to update the decks on sell, not just the catalog @@ -1175,11 +1206,7 @@ public class AdventurePlayer implements Serializable, SaveFileContent { Map maxCardCounts = new HashMap<>(); for (int i = 0; i < NUMBER_OF_DECKS; i++) { for (final Map.Entry cp : decks[i].getAllCardsInASinglePool()) { - - int count = cp.getValue() - noSellCards.count(cp.getKey()); - - if (count <= 0) continue; - + int count = cp.getValue(); if (count > maxCardCounts.getOrDefault(cp.getKey(), 0)) { maxCardCounts.put(cp.getKey(), cp.getValue()); } @@ -1213,9 +1240,8 @@ public class AdventurePlayer implements Serializable, SaveFileContent { public void doAutosell() { int profit = 0; for (PaperCard cardToSell : autoSellCards.toFlatList()) { - profit += AdventurePlayer.current().cardSellPrice(cardToSell); + profit += AdventurePlayer.current().sellOneCard(cardToSell); autoSellCards.remove(cardToSell); - cards.remove(cardToSell, 1); } addGold(profit); //do this as one transaction so as not to get multiple copies of sound effect } diff --git a/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java b/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java index 1494b5be804..500e3d4b941 100644 --- a/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java +++ b/forge-gui-mobile/src/forge/adventure/scene/AdventureDeckEditor.java @@ -151,7 +151,7 @@ public class AdventureDeckEditor extends TabPageScreen { if (!cardManager.isInfinite()) { removeCard(card, result); } - AdventurePlayer.current().sellCard(card, result); + AdventurePlayer.current().sellCard(card, result, true); lblGold.setText(String.valueOf(AdventurePlayer.current().getGold())); } }); @@ -601,7 +601,7 @@ public class AdventureDeckEditor extends TabPageScreen { public void run(Boolean result) { if (result) { for (Map.Entry entry : catalogPage.cardManager.getFilteredItems()) { - AdventurePlayer.current().sellCard(entry.getKey(), entry.getValue()); + AdventurePlayer.current().sellCard(entry.getKey(), entry.getValue(), true); } catalogPage.refresh(); lblGold.setText(String.valueOf(AdventurePlayer.current().getGold())); diff --git a/forge-gui-mobile/src/forge/adventure/util/AdventureEventController.java b/forge-gui-mobile/src/forge/adventure/util/AdventureEventController.java index a44aee75d04..ddba538c198 100644 --- a/forge-gui-mobile/src/forge/adventure/util/AdventureEventController.java +++ b/forge-gui-mobile/src/forge/adventure/util/AdventureEventController.java @@ -98,6 +98,7 @@ public class AdventureEventController implements Serializable { AdventureEventData e; + // TODO After a certain amount of wins, stop offering jump start events if (random.nextInt(10) <= 2) { e = new AdventureEventData(eventSeed, EventFormat.Jumpstart); } else { diff --git a/forge-gui/res/adventure/common/custom_cards/sliver_queen_boss_effect.txt b/forge-gui/res/adventure/common/custom_cards/sliver_queen_boss_effect.txt index c5fe4ca5d9d..1de6587e731 100644 --- a/forge-gui/res/adventure/common/custom_cards/sliver_queen_boss_effect.txt +++ b/forge-gui/res/adventure/common/custom_cards/sliver_queen_boss_effect.txt @@ -10,4 +10,4 @@ SVar:DBChoose:DB$ ChooseCard | AtRandom$ True | Choices$ Creature.nonToken+OppCt SVar:DBCopy:DB$ CopyPermanent | Defined$ ChosenCard | AddTypes$ Sliver | SubAbility$ DBCleanup SVar:DBCleanup:DB$ Cleanup | ClearChosenCard$ True SVar:DBSeek:DB$ Seek | Type$ Card.Sliver | SpellDescription$ Seek a Sliver card. -Oracle:{4}: Create a 1/1 colorless Sliver creature token. Every player may activate this ability but only once each turn. \n At the gebinning of your upkeep, choose one at random\n• Create a 1/1 colorless Sliver creature token.\nCreate a token of a random nontoken creature your opponent controls. That creature becomes a Sliver in addition to its other types.\n• Seek a Sliver card. +Oracle:{4}: Create a 1/1 colorless Sliver creature token. Every player may activate this ability but only once each turn. \n At the beginning of your upkeep, choose one at random\n• Create a 1/1 colorless Sliver creature token.\nCreate a token of a random nontoken creature your opponent controls. That creature becomes a Sliver in addition to its other types.\n• Seek a Sliver card.