From 42ebac91ffc6b83a6a149bf7db88dabb74e0fb9f Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Wed, 14 Sep 2011 23:07:06 +0000 Subject: [PATCH] texts; the bottom table shows the real price that will be paid for cards being sold --- .../java/forge/gui/deckeditor/DeckEditorShop.java | 15 ++++++++------- .../java/net/slightlymagic/maxmtg/Predicate.java | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java index 677dd7d7e02..fe8f10ba053 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java @@ -105,8 +105,8 @@ public final class DeckEditorShop extends DeckEditorBase { String maxSellingPrice = ""; int maxSellPrice = questData.getCards().getSellPriceLimit(); - if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format(" Max selling price: %d", maxSellPrice); } - sellPercentageLabel.setText("(Sell percentage: " + formatter.format(multiPercent) + "% of value)" + maxSellingPrice); + if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format("Max selling price: %d", maxSellPrice); } + sellPercentageLabel.setText("(You can sell cards at " + formatter.format(multiPercent) + "% of their value)
" + maxSellingPrice + ""); top.sort(1, true); bottom.sort(1, true); @@ -150,7 +150,7 @@ public final class DeckEditorShop extends DeckEditorBase { columnsBelow.add(new TableColumnInfo("#Dk", 30, fnDeckCompare, fnDeckGet)); columnsBelow.add(new TableColumnInfo("New", 30, questData.getCards().fnNewCompare, questData.getCards().fnNewGet)); - columnsBelow.add(new TableColumnInfo("Price", 40, fnPriceCompare, fnPriceGet)); + columnsBelow.add(new TableColumnInfo("Price", 40, fnPriceCompare, fnPriceSellGet)); bottom.setup(columnsBelow, cardView); this.setSize(1024, 768); @@ -277,13 +277,11 @@ public final class DeckEditorShop extends DeckEditorBase { } else if (item instanceof BoosterPack) { top.removeCard(item); BoosterPack booster = (BoosterPack) item; - + questData.getCards().buyBooster(booster, value); List newCards = booster.getCards(); for (CardPrinted card : newCards) { bottom.addCard(card); } CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards); c.show(); - - questData.getCards().buyBooster(booster, value); } creditsLabel.setText("Total credits: " + questData.getCredits()); @@ -318,7 +316,10 @@ public final class DeckEditorShop extends DeckEditorBase { private final Lambda1> fnPriceGet = new Lambda1>() { @Override public Object apply(final Entry from) { return getCardValue(from.getKey()); } }; - + private final Lambda1> fnPriceSellGet = + new Lambda1>() { @Override + public Object apply(final Entry from) { return (int) (multiplier * getCardValue(from.getKey())); } }; + @SuppressWarnings("rawtypes") private final Lambda1> fnDeckCompare = new Lambda1>() { @Override diff --git a/src/main/java/net/slightlymagic/maxmtg/Predicate.java b/src/main/java/net/slightlymagic/maxmtg/Predicate.java index fe3db346479..ede6b2948fd 100644 --- a/src/main/java/net/slightlymagic/maxmtg/Predicate.java +++ b/src/main/java/net/slightlymagic/maxmtg/Predicate.java @@ -10,6 +10,9 @@ import net.slightlymagic.braids.util.lambda.Lambda1; * Predicate class allows to select items or type , which are or contain an object of type , * 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 * * @param - class to check condition against