mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Allow jumpstart/"nosell" cards to be sold for 0 credits
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<PaperCard> 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<PaperCard, Integer> maxCardCounts = new HashMap<>();
|
||||
for (int i = 0; i < NUMBER_OF_DECKS; i++) {
|
||||
for (final Map.Entry<PaperCard, Integer> 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
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
||||
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<AdventureDeckEditor> {
|
||||
public void run(Boolean result) {
|
||||
if (result) {
|
||||
for (Map.Entry<PaperCard, Integer> 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()));
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user