From 8c7f78ec19eb4e42a50588fcbd046ebd1d126139 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Wed, 14 Sep 2011 22:14:16 +0000 Subject: [PATCH] fixed type for boosterpack, base price set to $3.95, fixed text, removed unused imports --- .../java/forge/card/BoosterGenerator.java | 3 --- .../forge/gui/deckeditor/DeckEditorShop.java | 4 +++- .../forge/gui/deckeditor/PresetColumns.java | 5 ++-- src/main/java/forge/item/BoosterPack.java | 24 +++++++++++++++---- src/main/java/forge/item/CardPrinted.java | 1 + src/main/java/forge/item/InventoryItem.java | 2 ++ 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/forge/card/BoosterGenerator.java b/src/main/java/forge/card/BoosterGenerator.java index bfc607fb3d3..a415058fe56 100644 --- a/src/main/java/forge/card/BoosterGenerator.java +++ b/src/main/java/forge/card/BoosterGenerator.java @@ -1,7 +1,5 @@ package forge.card; -import forge.Constant; -import forge.FileUtil; import forge.MyRandom; import forge.deck.Deck; import forge.item.CardDb; @@ -9,7 +7,6 @@ import forge.item.CardPrinted; import java.security.InvalidParameterException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map.Entry; diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java index c2d20c6cc39..677dd7d7e02 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java @@ -255,6 +255,8 @@ public final class DeckEditorShop extends DeckEditorBase { case MythicRare: return Integer.valueOf(600); default: return Integer.valueOf(15); } + } else if (card instanceof BoosterPack) { + return 395; } return 1337; } @@ -278,7 +280,7 @@ public final class DeckEditorShop extends DeckEditorBase { List newCards = booster.getCards(); for (CardPrinted card : newCards) { bottom.addCard(card); } - CardListViewer c = new CardListViewer(booster.getName(), "You have found the following new cards inside booster", newCards); + CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards); c.show(); questData.getCards().buyBooster(booster, value); diff --git a/src/main/java/forge/gui/deckeditor/PresetColumns.java b/src/main/java/forge/gui/deckeditor/PresetColumns.java index 26eeceb48dc..6a01213277d 100644 --- a/src/main/java/forge/gui/deckeditor/PresetColumns.java +++ b/src/main/java/forge/gui/deckeditor/PresetColumns.java @@ -20,7 +20,6 @@ public abstract class PresetColumns { private static CardManaCost toManaCost(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : CardManaCost.empty; } private static CardColor toColor(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getColor() : CardColor.nullColor; } - private static String toType(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getType().toString() : i.getClass().toString(); } private static String toPTL(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getPTorLoyalty() : ""; } private static CardRarity toRarity(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getRarity() : CardRarity.Unknown; } private static CardSet toSetCmp(InventoryItem i) { return i instanceof InventoryItemFromSet ? SetUtils.getSetByCode(((InventoryItemFromSet) i).getSet()) : CardSet.unknown; } @@ -63,10 +62,10 @@ public abstract class PresetColumns { @SuppressWarnings("rawtypes") public static final Lambda1> fnTypeCompare = new Lambda1>() { @Override - public Comparable apply(final Entry from) { return toType(from.getKey()); } }; + public Comparable apply(final Entry from) { return from.getKey().getType(); } }; public static final Lambda1> fnTypeGet = new Lambda1>() { @Override - public Object apply(final Entry from) { return toType(from.getKey()); } }; + public Object apply(final Entry from) { return from.getKey().getType(); } }; @SuppressWarnings("rawtypes") public static final Lambda1> fnStatsCompare = diff --git a/src/main/java/forge/item/BoosterPack.java b/src/main/java/forge/item/BoosterPack.java index 49f173a8835..5f044ecdafc 100644 --- a/src/main/java/forge/item/BoosterPack.java +++ b/src/main/java/forge/item/BoosterPack.java @@ -4,6 +4,7 @@ import java.util.List; import forge.SetUtils; import forge.card.BoosterGenerator; +import forge.card.CardSet; /** * TODO: Write javadoc for this type. @@ -11,17 +12,22 @@ import forge.card.BoosterGenerator; */ public class BoosterPack implements InventoryItemFromSet { - private final String cardSet; + private final CardSet cardSet; private final String name; private List cards = null; public BoosterPack(String set) { - cardSet = set; - name = SetUtils.getSetByCodeOrThrow(set).getName() + " booster"; + this(SetUtils.getSetByCodeOrThrow(set)); } - @Override public String getSet() { return cardSet; } + public BoosterPack(CardSet set) { + cardSet = set; + name = cardSet.getName() + " Booster Pack"; + } + + + @Override public String getSet() { return cardSet.getCode(); } @Override public String getName() { return name; } @Override public String getImageFilename() { @@ -32,7 +38,7 @@ public class BoosterPack implements InventoryItemFromSet { public List getCards() { if (null == cards) { - BoosterGenerator gen = new BoosterGenerator(SetUtils.getSetByCode(cardSet)); + BoosterGenerator gen = new BoosterGenerator(cardSet); cards = gen.getBoosterPack(); // TODO: Add land here! } @@ -63,6 +69,14 @@ public class BoosterPack implements InventoryItemFromSet { return false; return true; } + + /* (non-Javadoc) + * @see forge.item.InventoryItem#getType() + */ + @Override + public String getType() { + return "Booster Pack"; + } diff --git a/src/main/java/forge/item/CardPrinted.java b/src/main/java/forge/item/CardPrinted.java index bed2f55f1ff..4f0f6acd874 100644 --- a/src/main/java/forge/item/CardPrinted.java +++ b/src/main/java/forge/item/CardPrinted.java @@ -50,6 +50,7 @@ public final class CardPrinted implements Comparable, InventoryItem if (imageFilename == null) { imageFilename = CardUtil.buildFilename(this); } return imageFilename; } + public String getType() { return card.getType().toString(); } // Lambda to get rules for selects from list of printed cards public static final Lambda1 fnGetRules = new Lambda1() { diff --git a/src/main/java/forge/item/InventoryItem.java b/src/main/java/forge/item/InventoryItem.java index 6cf35906719..fed89ffe542 100644 --- a/src/main/java/forge/item/InventoryItem.java +++ b/src/main/java/forge/item/InventoryItem.java @@ -9,4 +9,6 @@ public interface InventoryItem /* extends Comparable */ { String getName(); /** An inventory item has to provide a picture. */ String getImageFilename(); + /** Return type as a string */ + String getType(); }