texts; the bottom table shows the real price that will be paid for cards being sold

This commit is contained in:
Maxmtg
2011-09-14 23:07:06 +00:00
parent c353e9568f
commit 42ebac91ff
2 changed files with 11 additions and 7 deletions

View File

@@ -106,7 +106,7 @@ public final class DeckEditorShop extends DeckEditorBase {
int maxSellPrice = questData.getCards().getSellPriceLimit(); int maxSellPrice = questData.getCards().getSellPriceLimit();
if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format("Max selling price: %d", maxSellPrice); } if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format("Max selling price: %d", maxSellPrice); }
sellPercentageLabel.setText("(Sell percentage: " + formatter.format(multiPercent) + "% of value)" + maxSellingPrice); sellPercentageLabel.setText("<html>(You can sell cards at " + formatter.format(multiPercent) + "% of their value)<br>" + maxSellingPrice + "</html>");
top.sort(1, true); top.sort(1, true);
bottom.sort(1, true); bottom.sort(1, true);
@@ -150,7 +150,7 @@ public final class DeckEditorShop extends DeckEditorBase {
columnsBelow.add(new TableColumnInfo<InventoryItem>("#Dk", 30, fnDeckCompare, fnDeckGet)); columnsBelow.add(new TableColumnInfo<InventoryItem>("#Dk", 30, fnDeckCompare, fnDeckGet));
columnsBelow.add(new TableColumnInfo<InventoryItem>("New", 30, questData.getCards().fnNewCompare, questData.getCards().fnNewGet)); columnsBelow.add(new TableColumnInfo<InventoryItem>("New", 30, questData.getCards().fnNewCompare, questData.getCards().fnNewGet));
columnsBelow.add(new TableColumnInfo<InventoryItem>("Price", 40, fnPriceCompare, fnPriceGet)); columnsBelow.add(new TableColumnInfo<InventoryItem>("Price", 40, fnPriceCompare, fnPriceSellGet));
bottom.setup(columnsBelow, cardView); bottom.setup(columnsBelow, cardView);
this.setSize(1024, 768); this.setSize(1024, 768);
@@ -277,13 +277,11 @@ public final class DeckEditorShop extends DeckEditorBase {
} else if (item instanceof BoosterPack) { } else if (item instanceof BoosterPack) {
top.removeCard(item); top.removeCard(item);
BoosterPack booster = (BoosterPack) item; BoosterPack booster = (BoosterPack) item;
questData.getCards().buyBooster(booster, value);
List<CardPrinted> newCards = booster.getCards(); List<CardPrinted> newCards = booster.getCards();
for (CardPrinted card : newCards) { bottom.addCard(card); } for (CardPrinted card : newCards) { bottom.addCard(card); }
CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards); CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards);
c.show(); c.show();
questData.getCards().buyBooster(booster, value);
} }
creditsLabel.setText("Total credits: " + questData.getCredits()); creditsLabel.setText("Total credits: " + questData.getCredits());
@@ -318,6 +316,9 @@ public final class DeckEditorShop extends DeckEditorBase {
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceGet = private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceGet =
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
public Object apply(final Entry<InventoryItem, Integer> from) { return getCardValue(from.getKey()); } }; public Object apply(final Entry<InventoryItem, Integer> from) { return getCardValue(from.getKey()); } };
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceSellGet =
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
public Object apply(final Entry<InventoryItem, Integer> from) { return (int) (multiplier * getCardValue(from.getKey())); } };
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnDeckCompare = private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnDeckCompare =

View File

@@ -10,6 +10,9 @@ import net.slightlymagic.braids.util.lambda.Lambda1;
* Predicate class allows to select items or type <U>, which are or contain an object of type <T>, * Predicate class allows to select items or type <U>, which are or contain an object of type <T>,
* matching to some criteria set by predicate. No need to write that simple operations by hand. * matching to some criteria set by predicate. No need to write that simple operations by hand.
* *
* PS: com.google.common.base.Predicates contains almost the same functionality, except for they keep filtering,
* transformations aside from the predicate in class Iterables
*
* @author Max * @author Max
* *
* @param <T> - class to check condition against * @param <T> - class to check condition against