From ff3e861303ba1148b880a12ff8b80b295a0892bd Mon Sep 17 00:00:00 2001 From: myk Date: Tue, 5 Mar 2013 22:23:20 +0000 Subject: [PATCH] show information for non-card items in spell shop card details panel --- src/main/java/forge/card/BoosterData.java | 175 +++++++----------- .../java/forge/card/BoosterGenerator.java | 2 +- src/main/java/forge/card/FatPackData.java | 72 ++++--- src/main/java/forge/card/PackData.java | 52 ++++++ src/main/java/forge/gui/CardDetailPanel.java | 60 ++++-- .../forge/gui/match/controllers/CDetail.java | 17 +- src/main/java/forge/item/BoosterPack.java | 36 +--- src/main/java/forge/item/CardPrinted.java | 5 + src/main/java/forge/item/CardToken.java | 2 + src/main/java/forge/item/FatPack.java | 29 +-- .../java/forge/item/InventoryItemFromSet.java | 16 +- src/main/java/forge/item/OpenablePack.java | 72 +------ src/main/java/forge/item/PreconDeck.java | 1 + .../forge/util/storage/StorageReaderFile.java | 6 +- 14 files changed, 234 insertions(+), 311 deletions(-) create mode 100644 src/main/java/forge/card/PackData.java diff --git a/src/main/java/forge/card/BoosterData.java b/src/main/java/forge/card/BoosterData.java index b1294a3d3fa..1552ac5397a 100644 --- a/src/main/java/forge/card/BoosterData.java +++ b/src/main/java/forge/card/BoosterData.java @@ -1,6 +1,5 @@ package forge.card; -import com.google.common.base.Function; import com.google.common.base.Predicate; import forge.item.CardPrinted; @@ -8,44 +7,15 @@ import forge.item.IPaperCard; import forge.util.FileSection; import forge.util.storage.StorageReaderFile; - -/** - * The Class BoosterData. - */ -public class BoosterData { - private final String edition; - public final String getEdition() { - return edition; - } - private final String landEdition; - public final String getLandEdition() { - return landEdition; - } - +public class BoosterData extends PackData { private final int nCommon; private final int nUncommon; private final int nRare; private final int nSpecial; private final int nDoubleFaced; - private final int nLand; private final int foilRate; private static final int CARDS_PER_BOOSTER = 15; - // private final String landCode; - /** - * Instantiates a new booster data. - * - * @param nC - * the n c - * @param nU - * the n u - * @param nR - * the n r - * @param nS - * the n s - * @param nDF - * the n df - */ public BoosterData(final String edition, final String editionLand, final int nC, final int nU, final int nR, final int nS, final int nDF) { // if this booster has more that 10 cards, there must be a land in // 15th slot unless it's already taken @@ -53,132 +23,116 @@ public class BoosterData { - nS - nDF : 0, 68); } - /** - * Instantiates a new booster data. - * - * @param nC - * the n c - * @param nU - * the n u - * @param nR - * the n r - * @param nS - * the n s - * @param nDF - * the n df - * @param nL - * the n l - * @param oneFoilPer - * the one foil per - */ public BoosterData(final String edition0, final String editionLand, final int nC, final int nU, final int nR, final int nS, final int nDF, final int nL, final int oneFoilPer) { + super(edition0, editionLand, nL > 0 ? nL : 0); this.nCommon = nC; this.nUncommon = nU; this.nRare = nR; this.nSpecial = nS; this.nDoubleFaced = nDF; - this.nLand = nL > 0 ? nL : 0; this.foilRate = oneFoilPer; - this.edition = edition0; - this.landEdition = editionLand; } - /** - * Gets the common. - * - * @return the common - */ public final int getCommon() { return this.nCommon; } public final Predicate getEditionFilter() { - return IPaperCard.Predicates.printedInSets(edition); + return IPaperCard.Predicates.printedInSets(getEdition()); } public final Predicate getLandEditionFilter() { - return IPaperCard.Predicates.printedInSets(landEdition); + return IPaperCard.Predicates.printedInSets(getLandEdition()); } - /** - * Gets the uncommon. - * - * @return the uncommon - */ + public final int getUncommon() { return this.nUncommon; } - /** - * Gets the rare. - * - * @return the rare - */ public final int getRare() { return this.nRare; } - /** - * Gets the special. - * - * @return the special - */ public final int getSpecial() { return this.nSpecial; } - /** - * Gets the double faced. - * - * @return the double faced - */ public final int getDoubleFaced() { return this.nDoubleFaced; } - /** - * Gets the land. - * - * @return the land - */ - public final int getLand() { - return this.nLand; - } - - /** - * Gets the total. - * - * @return the total - */ public final int getTotal() { - return this.nCommon + this.nUncommon + this.nRare + this.nSpecial + this.nDoubleFaced + this.nLand; + return this.nCommon + this.nUncommon + this.nRare + this.nSpecial + this.nDoubleFaced + getCntLands(); } - /** - * Gets the foil chance. - * - * @return the foil chance - */ public final int getFoilChance() { return this.foilRate; } - - public static final Function FN_GET_CODE = new Function() { - - @Override - public String apply(BoosterData arg1) { - return arg1.edition; + + private void _append(StringBuilder s, int val, String name) { + if (0 >= val) { + return; } - }; + s.append(val).append(' ').append(name); + if (1 < val) { + s.append('s'); + } + s.append(", "); + } + + @Override + public String toString() { + int total = getTotal(); + + if (0 >= total) { + return "no cards"; + } + + StringBuilder s = new StringBuilder(); + + _append(s, total, "card"); + if (0 < total) { + // remove comma + s.deleteCharAt(s.length() - 2); + } + + s.append("consisting of "); + _append(s, nSpecial, "special"); + _append(s, nDoubleFaced, "double faced card"); + _append(s, nRare, "rare"); + _append(s, nUncommon, "uncommon"); + _append(s, nCommon, "common"); + if (getEdition().equalsIgnoreCase(getLandEdition())) { + _append(s, getCntLands(), "land"); + } else if (0 < getCntLands()) { + s.append(getCntLands()).append("land"); + if (1 < getCntLands()) { + s.append("s"); + } + s.append("from edition: ").append(getLandEdition()).append(", "); + } + + // trim the last comma and space + s.replace(s.length() - 2, s.length(), ""); + + // put an 'and' before the previous comma + int lastCommaIdx = s.lastIndexOf(","); + if (0 < lastCommaIdx) { + s.replace(lastCommaIdx+1, lastCommaIdx+1, " and"); + } + + if (0 < foilRate) { + s.append(", with a foil rate of 1 in ").append(foilRate); + } + + return s.toString(); + } public static final class Reader extends StorageReaderFile { - public Reader(String pathname) { super(pathname, BoosterData.FN_GET_CODE); } - /* (non-Javadoc) - * @see forge.util.StorageReaderFile#read(java.lang.String) - */ @Override protected BoosterData read(String line, int i) { final FileSection section = FileSection.parse(line, ":", "|"); @@ -194,6 +148,7 @@ public class BoosterData { if (editionLand == null) { editionLand = edition; } + return new BoosterData(edition, editionLand, nC, nU, nR, nS, nDf, nLand, nFoilRate); } } diff --git a/src/main/java/forge/card/BoosterGenerator.java b/src/main/java/forge/card/BoosterGenerator.java index e67fa5e84dd..fbbb3362cc3 100644 --- a/src/main/java/forge/card/BoosterGenerator.java +++ b/src/main/java/forge/card/BoosterGenerator.java @@ -213,7 +213,7 @@ public class BoosterGenerator { */ public final List getBoosterPack(BoosterData booster) { return this.getBoosterPack(booster.getCommon(), booster.getUncommon(), booster.getRare(), 0, 0, booster.getSpecial(), - booster.getDoubleFaced(), 0, booster.getLand()); + booster.getDoubleFaced(), 0, booster.getCntLands()); } /** diff --git a/src/main/java/forge/card/FatPackData.java b/src/main/java/forge/card/FatPackData.java index ac0c1998b4d..c03e038351f 100644 --- a/src/main/java/forge/card/FatPackData.java +++ b/src/main/java/forge/card/FatPackData.java @@ -1,7 +1,5 @@ package forge.card; -import com.google.common.base.Function; - import forge.util.FileSection; import forge.util.storage.StorageReaderFile; @@ -9,53 +7,23 @@ import forge.util.storage.StorageReaderFile; * TODO: Write javadoc for this type. * */ -public class FatPackData { - private final String edition; - public final String getEdition() { - return edition; - } - - private final String landsEdition; - public final String getLandsEdition() { - return landsEdition == null ? edition : landsEdition; - } - +public class FatPackData extends PackData { + private final int cntBoosters; public int getCntBoosters() { return cntBoosters; } - public int getCntLands() { - return cntLands; - } - - private final int cntBoosters; - private final int cntLands; - - public FatPackData(String edition0, String landsEdition0, int nBoosters, int nBasicLands) + public FatPackData(String edition0, String landEdition0, int nBoosters, int nBasicLands) { + super(edition0, landEdition0, nBasicLands); cntBoosters = nBoosters; - cntLands = nBasicLands; - edition = edition0; - landsEdition = landsEdition0; } - public static final Function FN_GET_CODE = new Function() { - - @Override - public String apply(FatPackData arg1) { - return arg1.edition; - } - }; - public static final class Reader extends StorageReaderFile { - public Reader(String pathname) { - super(pathname, FatPackData.FN_GET_CODE); + super(pathname, PackData.FN_GET_CODE); } - /* (non-Javadoc) - * @see forge.util.StorageReaderFile#read(java.lang.String) - */ @Override protected FatPackData read(String line, int i) { final FileSection section = FileSection.parse(line, ":", "|"); @@ -64,4 +32,34 @@ public class FatPackData { return new FatPackData(section.get("Set"), section.get("LandSet"), nBoosters, nLand); } } + + @Override + public String toString() { + if (0 >= cntBoosters) { + return "no cards"; + } + + StringBuilder s = new StringBuilder(); + + if (0 < getCntLands()) { + s.append(getCntLands()).append(" land"); + if (1 < getCntLands()) { + s.append("s"); + } + + if (!getEdition().equalsIgnoreCase(getLandEdition())) { + s.append(" from edition: ").append(getLandEdition()); + } + + if (0 < cntBoosters) { + s.append(" and "); + } + } + + if (0 < cntBoosters) { + s.append(cntBoosters).append(" booster packs, each containing "); + } + + return s.toString(); + } } diff --git a/src/main/java/forge/card/PackData.java b/src/main/java/forge/card/PackData.java new file mode 100644 index 00000000000..64e9b7d9332 --- /dev/null +++ b/src/main/java/forge/card/PackData.java @@ -0,0 +1,52 @@ +/* + * Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package forge.card; + +import com.google.common.base.Function; + +public class PackData { + private final String edition; + public final String getEdition() { + return edition; + } + + private final String landEdition; + public final String getLandEdition() { + return landEdition == null ? edition : landEdition; + } + + private final int cntLands; + public int getCntLands() { + return cntLands; + } + + public PackData(String edition0, String landEdition0, int nBasicLands) + { + edition = edition0; + landEdition = landEdition0; + cntLands = nBasicLands; + } + + public static final Function FN_GET_CODE = new Function() { + @Override + public String apply(PackData arg1) { + return arg1.edition; + } + }; +} diff --git a/src/main/java/forge/gui/CardDetailPanel.java b/src/main/java/forge/gui/CardDetailPanel.java index 0b9b022dbb2..88bc82ebe13 100644 --- a/src/main/java/forge/gui/CardDetailPanel.java +++ b/src/main/java/forge/gui/CardDetailPanel.java @@ -33,6 +33,8 @@ import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; +import org.apache.commons.lang3.StringUtils; + import forge.Card; import forge.CounterType; import forge.GameEntity; @@ -45,6 +47,7 @@ import forge.gui.toolbox.FPanel; import forge.gui.toolbox.FScrollPane; import forge.gui.toolbox.FSkin; import forge.gui.toolbox.FTextArea; +import forge.item.InventoryItemFromSet; /** * The class CardDetailPanel. Shows the details of a card. @@ -66,18 +69,11 @@ public class CardDetailPanel extends FPanel { private final FTextArea cdArea; private final FScrollPane scrArea; - /** - *

- * Constructor for CardDetailPanel. - *

- * - * @param card - * a {@link forge.Card} object. - */ public CardDetailPanel(final Card card) { super(); this.setLayout(new GridBagLayout()); this.setBorder(new EtchedBorder()); + this.setBorderToggle(false); GridBagConstraints labelConstrains = new GridBagConstraints(); labelConstrains.fill = GridBagConstraints.BOTH; @@ -126,6 +122,9 @@ public class CardDetailPanel extends FPanel { //4, 12 this.cdArea = new FTextArea(); + this.cdArea.setFont(new java.awt.Font("Dialog", 0, 14)); + this.cdArea.setBorder(new EmptyBorder(4, 4, 4, 4)); + this.cdArea.setOpaque(false); this.scrArea = new FScrollPane(this.cdArea); GridBagConstraints areaConstraints = new GridBagConstraints(); @@ -135,10 +134,6 @@ public class CardDetailPanel extends FPanel { areaConstraints.weightx = 1.0; areaConstraints.weighty = 1.0; this.add(scrArea, areaConstraints); - this.cdArea.setLineWrap(true); - this.cdArea.setWrapStyleWord(true); - this.cdArea.setEditable(false); - this.cdArea.setBorder(new EmptyBorder(4, 4, 4, 4)); this.nameCostLabel.setFont(new java.awt.Font("Dialog", 0, 14)); this.typeLabel.setFont(new java.awt.Font("Dialog", 0, 14)); @@ -149,15 +144,49 @@ public class CardDetailPanel extends FPanel { f = f.deriveFont(java.awt.Font.BOLD); this.setInfoLabel.setFont(f); - this.cdArea.setFont(new java.awt.Font("Dialog", 0, 14)); - this.setCard(card); } + public final void setItem(InventoryItemFromSet item) { + nameCostLabel.setText(item.getName()); + typeLabel.setVisible(false); + powerToughnessLabel.setVisible(false); + idLabel.setText(null); + cdArea.setText(item.getDescription()); + setBorder(GuiDisplayUtil.getBorder(null)); + + String set = item.getEdition(); + setInfoLabel.setText(set); + setInfoLabel.setToolTipText(""); + if (StringUtils.isEmpty(set)) { + setInfoLabel.setOpaque(false); + setInfoLabel.setBorder(null); + } else { + CardEdition edition = Singletons.getModel().getEditions().get(set); + if (null != edition) { + setInfoLabel.setToolTipText(edition.getName()); + } + + this.setInfoLabel.setOpaque(true); + this.setInfoLabel.setBackground(Color.BLACK); + this.setInfoLabel.setForeground(Color.WHITE); + this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); + } + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + scrArea.getVerticalScrollBar().setValue(scrArea.getVerticalScrollBar().getMinimum()); + } + }); + } + /** {@inheritDoc} */ public final void setCard(final Card card) { this.nameCostLabel.setText(""); + this.typeLabel.setVisible(true); this.typeLabel.setText(""); + this.powerToughnessLabel.setVisible(true); this.powerToughnessLabel.setText(""); this.idLabel.setText(""); this.setInfoLabel.setText(""); @@ -167,8 +196,9 @@ public class CardDetailPanel extends FPanel { this.cdArea.setText(""); this.setBorder(GuiDisplayUtil.getBorder(card)); - if ( null == card ) + if (null == card) { return; + } final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer()); if (canShowThis) { diff --git a/src/main/java/forge/gui/match/controllers/CDetail.java b/src/main/java/forge/gui/match/controllers/CDetail.java index 496efd221dd..e6df851a1fc 100644 --- a/src/main/java/forge/gui/match/controllers/CDetail.java +++ b/src/main/java/forge/gui/match/controllers/CDetail.java @@ -26,6 +26,7 @@ import forge.gui.framework.ICDoc; import forge.gui.match.views.VDetail; import forge.item.IPaperCard; import forge.item.InventoryItem; +import forge.item.InventoryItemFromSet; /** * @@ -38,7 +39,6 @@ public enum CDetail implements ICDoc { SINGLETON_INSTANCE; private VDetail view = VDetail.SINGLETON_INSTANCE; - //private InventoryItem item = null; /** * Shows card details and/or picture in sidebar cardview tabber. @@ -52,16 +52,15 @@ public enum CDetail implements ICDoc { } public void showCard(InventoryItem item) { - if ( item instanceof IPaperCard ) { + if (item instanceof IPaperCard) { showCard(((IPaperCard)item).getMatchingForgeCard()); - return; + } else if (item instanceof InventoryItemFromSet) { + view.getLblFlipcard().setVisible(false); + view.getPnlDetail().setItem((InventoryItemFromSet)item); + view.getParentCell().repaintSelf(); + } else { + showCard((Card)null); } - - // TODO If we want to display an Items Written Text in the Detail Panel we need to add something into CardDetailPanel - //this.item = item; - view.getLblFlipcard().setVisible(false); - view.getPnlDetail().setCard(null); - view.getParentCell().repaintSelf(); } /* (non-Javadoc) diff --git a/src/main/java/forge/item/BoosterPack.java b/src/main/java/forge/item/BoosterPack.java index f04671e72ee..c79592316ad 100644 --- a/src/main/java/forge/item/BoosterPack.java +++ b/src/main/java/forge/item/BoosterPack.java @@ -15,8 +15,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package forge.item; +package forge.item; import com.google.common.base.Function; @@ -25,13 +25,7 @@ import forge.Singletons; import forge.card.BoosterData; import forge.card.CardEdition; -/** - * TODO Write javadoc for this type. - * - */ public class BoosterPack extends OpenablePack { - - /** The Constant fnFromSet. */ public static final Function FN_FROM_SET = new Function() { @Override public BoosterPack apply(final CardEdition arg1) { @@ -40,26 +34,10 @@ public class BoosterPack extends OpenablePack { } }; - /** - * Instantiates a new booster pack. - * - * @param set - * the set - */ public BoosterPack(final String name0, final BoosterData boosterData) { super(name0, boosterData); } - /* - * (non-Javadoc) - * - * @see forge.item.InventoryItemFromSet#getImageFilename() - */ - /** - * Gets the image filename. - * - * @return String - */ @Override public final String getImageFilename() { return ImageCache.SEALED_PRODUCT + "booster/" + this.contents.getEdition() + ".png"; @@ -70,20 +48,8 @@ public class BoosterPack extends OpenablePack { return "Booster Pack"; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - /** - * Clone. - * - * @return Object - */ @Override public final Object clone() { return new BoosterPack(name, contents); } - - } diff --git a/src/main/java/forge/item/CardPrinted.java b/src/main/java/forge/item/CardPrinted.java index b5f21d62022..06e2b43d810 100644 --- a/src/main/java/forge/item/CardPrinted.java +++ b/src/main/java/forge/item/CardPrinted.java @@ -69,6 +69,11 @@ public final class CardPrinted implements Comparable, InventoryItemF public String getName() { return this.name; } + + @Override + public String getDescription() { + return name; + } /* * (non-Javadoc) diff --git a/src/main/java/forge/item/CardToken.java b/src/main/java/forge/item/CardToken.java index 4bdd47fe8ff..80aa2399c6e 100644 --- a/src/main/java/forge/item/CardToken.java +++ b/src/main/java/forge/item/CardToken.java @@ -23,6 +23,8 @@ public class CardToken implements InventoryItemFromSet, IPaperCard { } @Override public String getName() { return name; } + @Override public String getDescription() { return name; } + @Override public String getEdition() { return edition; } @Override public int getArtIndex() { return 0; } // This might change however diff --git a/src/main/java/forge/item/FatPack.java b/src/main/java/forge/item/FatPack.java index a89744d7b68..8ae69aa3722 100644 --- a/src/main/java/forge/item/FatPack.java +++ b/src/main/java/forge/item/FatPack.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package forge.item; import java.util.ArrayList; @@ -27,10 +28,6 @@ import forge.Singletons; import forge.card.CardEdition; import forge.card.FatPackData; -/** - * TODO Write javadoc for this type. - * - */ public class FatPack extends OpenablePack { /** The Constant fnFromSet. */ @@ -44,17 +41,15 @@ public class FatPack extends OpenablePack { private final FatPackData fpData; - /** - * Instantiates a new booster pack. - * - * @param set - * the set - */ public FatPack(final String name0, final FatPackData fpData0) { super(name0, Singletons.getModel().getBoosters().get(fpData0.getEdition())); fpData = fpData0; } + @Override + public String getDescription() { + return fpData.toString() + contents.toString(); + } @Override public final String getImageFilename() { @@ -73,20 +68,10 @@ public class FatPack extends OpenablePack { for (int i = 0; i < fpData.getCntBoosters(); i++) { result.addAll(super.generate()); } - result.addAll(getRandomBasicLands(fpData.getLandsEdition(), fpData.getCntLands())); + result.addAll(getRandomBasicLands(fpData.getLandEdition(), fpData.getCntLands())); return result; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#clone() - */ - /** - * Clone. - * - * @return Object - */ @Override public final Object clone() { return new FatPack(name, fpData); @@ -96,6 +81,4 @@ public class FatPack extends OpenablePack { public int getTotalCards() { return super.getTotalCards() * fpData.getCntBoosters() + fpData.getCntLands(); } - - } diff --git a/src/main/java/forge/item/InventoryItemFromSet.java b/src/main/java/forge/item/InventoryItemFromSet.java index 6d206633dde..1a7992b1168 100644 --- a/src/main/java/forge/item/InventoryItemFromSet.java +++ b/src/main/java/forge/item/InventoryItemFromSet.java @@ -22,22 +22,10 @@ package forge.item; * CardPrinted, Booster, Pets, Plants... etc */ public interface InventoryItemFromSet extends InventoryItem { - /** - * An inventory item has to provide a name. - * - * @return the name + * The description to display for the item */ - @Override - String getName(); - - /** - * An inventory item has to provide a picture. - * - * @return the image filename - */ - @Override - String getImageFilename(); + String getDescription(); /** * An item belonging to a set should return its set as well. diff --git a/src/main/java/forge/item/OpenablePack.java b/src/main/java/forge/item/OpenablePack.java index 15ec9ebc2df..c3a05bb5cac 100644 --- a/src/main/java/forge/item/OpenablePack.java +++ b/src/main/java/forge/item/OpenablePack.java @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package forge.item; import java.util.List; @@ -28,73 +29,46 @@ import forge.card.BoosterGenerator; import forge.card.CardRulesPredicates; import forge.util.Aggregates; -/** - * TODO: Write javadoc for this type. - */ public abstract class OpenablePack implements InventoryItemFromSet { - - /** The contents. */ protected final BoosterData contents; - /** The name. */ protected final String name; private List cards = null; private BoosterGenerator generator = null; - /** - * Instantiates a new openable pack. - * - * @param name0 the name0 - * @param boosterData the booster data - */ public OpenablePack(final String name0, final BoosterData boosterData) { this.contents = boosterData; this.name = name0; } - /* (non-Javadoc) - * @see forge.item.InventoryItemFromSet#getName() - */ @Override public final String getName() { return this.name + " " + this.getItemType(); } - /* (non-Javadoc) - * @see forge.item.InventoryItemFromSet#getEdition() - */ + @Override + public String getDescription() { + return contents.toString(); + } + @Override public final String getEdition() { return this.contents.getEdition(); } - /** - * Gets the cards. - * - * @return the cards - */ public final List getCards() { if (null == this.cards) { this.cards = this.generate(); } + return this.cards; } - /** - * Gets the total cards. - * - * @return the total cards - */ public int getTotalCards() { return this.contents.getTotal(); } - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ @Override public final boolean equals(final Object obj) { if (this == obj) { @@ -117,16 +91,6 @@ public abstract class OpenablePack implements InventoryItemFromSet { return true; } - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - /** - * Hash code. - * - * @return int - */ @Override public final int hashCode() { final int prime = 31; @@ -135,47 +99,27 @@ public abstract class OpenablePack implements InventoryItemFromSet { return result; } - /** - * Generate. - * - * @return the list - */ protected List generate() { if (null == this.generator) { this.generator = new BoosterGenerator(this.contents.getEditionFilter()); } final List myCards = this.generator.getBoosterPack(this.contents); - final int cntLands = this.contents.getLand(); + final int cntLands = this.contents.getCntLands(); if (cntLands > 0) { myCards.add(this.getRandomBasicLand(this.contents.getLandEdition())); } return myCards; } - - /** - * Gets the random basic land. - * - * @param set the set - * @return the random basic land - */ protected CardPrinted getRandomBasicLand(final String setCode) { return this.getRandomBasicLands(setCode, 1).get(0); } - /** - * Gets the random basic lands. - * - * @param set the set - * @param count the count - * @return the random basic lands - */ protected List getRandomBasicLands(final String setCode, final int count) { Predicate cardsRule = Predicates.and( IPaperCard.Predicates.printedInSets(setCode), Predicates.compose(CardRulesPredicates.Presets.IS_BASIC_LAND, CardPrinted.FN_GET_RULES)); return Aggregates.random(Iterables.filter(CardDb.instance().getAllCards(), cardsRule), count); } - } diff --git a/src/main/java/forge/item/PreconDeck.java b/src/main/java/forge/item/PreconDeck.java index 0143c4a6f0f..3057a8072c4 100644 --- a/src/main/java/forge/item/PreconDeck.java +++ b/src/main/java/forge/item/PreconDeck.java @@ -133,6 +133,7 @@ public class PreconDeck implements InventoryItemFromSet { * * @return the description */ + @Override public final String getDescription() { return this.description; } diff --git a/src/main/java/forge/util/storage/StorageReaderFile.java b/src/main/java/forge/util/storage/StorageReaderFile.java index ae743e7010c..b8fa69965a0 100644 --- a/src/main/java/forge/util/storage/StorageReaderFile.java +++ b/src/main/java/forge/util/storage/StorageReaderFile.java @@ -40,7 +40,7 @@ import forge.util.IItemReader; public abstract class StorageReaderFile implements IItemReader { private final File file; - private final Function keySelector; + private final Function keySelector; /** * Instantiates a new storage reader file. @@ -48,7 +48,7 @@ public abstract class StorageReaderFile implements IItemReader { * @param pathname the pathname * @param keySelector0 the key selector0 */ - public StorageReaderFile(final String pathname, final Function keySelector0) { + public StorageReaderFile(final String pathname, final Function keySelector0) { this(new File(pathname), keySelector0); } @@ -58,7 +58,7 @@ public abstract class StorageReaderFile implements IItemReader { * @param file0 the file0 * @param keySelector0 the key selector0 */ - public StorageReaderFile(final File file0, final Function keySelector0) { + public StorageReaderFile(final File file0, final Function keySelector0) { this.file = file0; this.keySelector = keySelector0; }