From 36f37b103c71df1343baabd0d92a69971d3c9099 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Mon, 18 Feb 2013 08:28:35 +0000 Subject: [PATCH] CardPrinted - getCard() field that returns CardRules instance is now known as getRules() getRules() method from CardRules was renamed to getOracleText() --- src/main/java/forge/Card.java | 4 +- src/main/java/forge/CardUtil.java | 4 +- .../java/forge/card/BoosterGenerator.java | 6 +-- .../forge/card/CardRuleCharacteristics.java | 10 ++-- src/main/java/forge/card/CardRules.java | 13 +++-- src/main/java/forge/card/CardRulesReader.java | 2 +- src/main/java/forge/card/MtgDataParser.java | 2 +- .../forge/card/cardfactory/CardFactory.java | 2 +- src/main/java/forge/deck/Deck.java | 6 +-- src/main/java/forge/deck/DeckFormat.java | 6 +-- src/main/java/forge/deck/DeckgenUtil.java | 8 +-- .../generate/GenerateColoredDeckBase.java | 10 ++-- .../java/forge/deck/io/DeckSerializer.java | 2 +- src/main/java/forge/game/GameNew.java | 6 +-- .../java/forge/game/MatchStartHelper.java | 4 +- .../forge/game/limited/BoosterDraftAI.java | 4 +- .../java/forge/game/limited/DeckColors.java | 2 +- .../java/forge/game/limited/LimitedDeck.java | 50 +++++++++---------- .../java/forge/game/limited/SealedDeck.java | 2 +- .../gui/GuiMigrateLocalMWSSetPicturesHQ.java | 2 +- .../controllers/CEditorQuestCardShop.java | 2 +- .../deckeditor/controllers/CStatistics.java | 2 +- .../gui/deckeditor/tables/SColumnUtil.java | 20 ++++---- .../gui/download/GuiDownloadPicturesLQ.java | 2 +- .../download/GuiDownloadSetPicturesLQ.java | 8 +-- .../gui/home/variant/CSubmenuArchenemy.java | 2 +- .../gui/home/variant/CSubmenuPlanechase.java | 2 +- .../gui/home/variant/VSubmenuVanguard.java | 8 +-- src/main/java/forge/item/CardDb.java | 2 +- src/main/java/forge/item/CardPrinted.java | 2 +- src/main/java/forge/item/ItemPoolView.java | 2 +- src/test/java/forge/item/DeckHintsTest.java | 10 ++-- 32 files changed, 103 insertions(+), 104 deletions(-) diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 938b979a7e9..7911a40fd42 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -2063,9 +2063,9 @@ public class Card extends GameEntity implements Comparable { if (this.isType("Vanguard")) { final CardPrinted avatar = CardDb.getCard(this); sb.append("Hand Modifier: "); - sb.append(avatar.getCard().getHand()); + sb.append(avatar.getRules().getHand()); sb.append("\r\nLife Modifier: "); - sb.append(avatar.getCard().getLife()); + sb.append(avatar.getRules().getLife()); sb.append("\r\n\r\n"); } sb.append(this.getAbilityText()); diff --git a/src/main/java/forge/CardUtil.java b/src/main/java/forge/CardUtil.java index 8b2b601fd6c..3bb65bbf6b3 100644 --- a/src/main/java/forge/CardUtil.java +++ b/src/main/java/forge/CardUtil.java @@ -183,7 +183,7 @@ public final class CardUtil { * @return the string */ public static String buildFilename(final CardPrinted card) { - final int maxIndex = card.getCard().getEditionInfo(card.getEdition()).getCopiesCount(); + final int maxIndex = card.getRules().getEditionInfo(card.getEdition()).getCopiesCount(); return CardUtil.buildFilename(card.getName(), card.getEdition(), card.getArtIndex(), maxIndex, false); } @@ -197,7 +197,7 @@ public final class CardUtil { * @return the string */ public static String buildFilename(final CardPrinted card, final String nameToUse) { - final int maxIndex = card.getCard().getEditionInfo(card.getEdition()).getCopiesCount(); + final int maxIndex = card.getRules().getEditionInfo(card.getEdition()).getCopiesCount(); return CardUtil.buildFilename(nameToUse, card.getEdition(), card.getArtIndex(), maxIndex, false); } diff --git a/src/main/java/forge/card/BoosterGenerator.java b/src/main/java/forge/card/BoosterGenerator.java index 970614eb1ca..a298c265ba6 100644 --- a/src/main/java/forge/card/BoosterGenerator.java +++ b/src/main/java/forge/card/BoosterGenerator.java @@ -301,14 +301,14 @@ public class BoosterGenerator { } private void addToRarity(final CardPrinted c) { - if (c.getCard().isAltState()) { + if (c.getRules().isAltState()) { return; } - Map> targetList = c.getCard().isDoubleFaced() ? twoFacedByRarity : singleFacedByRarity; + Map> targetList = c.getRules().isDoubleFaced() ? twoFacedByRarity : singleFacedByRarity; targetList.get(c.getRarity()).add(c); - if (!c.getCard().getType().isBasicLand()) { + if (!c.getRules().getType().isBasicLand()) { this.allButLands.add(c); } } diff --git a/src/main/java/forge/card/CardRuleCharacteristics.java b/src/main/java/forge/card/CardRuleCharacteristics.java index c2b12b1f724..7bc84c19892 100644 --- a/src/main/java/forge/card/CardRuleCharacteristics.java +++ b/src/main/java/forge/card/CardRuleCharacteristics.java @@ -32,7 +32,7 @@ public class CardRuleCharacteristics { private SpellManaCost manaCost = SpellManaCost.NO_COST; private ColorSet color = null; private String ptLine = null; - private String[] cardRules = null; + private String oracleText = null; private Map setsData = new TreeMap(); private String dlUrl; private DeckHints deckHints; @@ -140,8 +140,8 @@ public class CardRuleCharacteristics { * * @return the cardRules */ - public final String[] getCardRules() { - return this.cardRules; + public final String getOracleText() { + return this.oracleText; } /** @@ -150,8 +150,8 @@ public class CardRuleCharacteristics { * @param cardRules0 * the cardRules to set */ - public final void setCardRules(final String[] cardRules0) { - this.cardRules = cardRules0; + public final void setCardRules(final String cardRules0) { + this.oracleText = cardRules0; } /** diff --git a/src/main/java/forge/card/CardRules.java b/src/main/java/forge/card/CardRules.java index 85e99a26703..c979c612fcc 100644 --- a/src/main/java/forge/card/CardRules.java +++ b/src/main/java/forge/card/CardRules.java @@ -104,8 +104,8 @@ public final class CardRules { * * @return the rules */ - public String[] getRules() { - return this.characteristics.getCardRules(); + public String getOracleText() { + return this.characteristics.getOracleText(); } /** @@ -285,13 +285,12 @@ public final class CardRules { * @return true, if successful */ public boolean rulesContain(final String text) { - if (this.characteristics.getCardRules() == null) { + if (this.characteristics.getOracleText() == null) { return false; } - for (final String r : this.characteristics.getCardRules()) { - if (StringUtils.containsIgnoreCase(r, text)) { - return true; - } + + if (StringUtils.containsIgnoreCase(this.characteristics.getOracleText(), text)) { + return true; } return false; } diff --git a/src/main/java/forge/card/CardRulesReader.java b/src/main/java/forge/card/CardRulesReader.java index ce6c9aa3351..ee74ff5f261 100644 --- a/src/main/java/forge/card/CardRulesReader.java +++ b/src/main/java/forge/card/CardRulesReader.java @@ -152,7 +152,7 @@ public class CardRulesReader { case 'O': if (line.startsWith("Oracle:")) { this.characteristics[this.curCharacteristics].setCardRules(CardRulesReader - .getValueAfterKey(line, "Oracle:").split("\\n")); + .getValueAfterKey(line, "Oracle:")); } break; diff --git a/src/main/java/forge/card/MtgDataParser.java b/src/main/java/forge/card/MtgDataParser.java index 273e90057c4..1f86c168111 100644 --- a/src/main/java/forge/card/MtgDataParser.java +++ b/src/main/java/forge/card/MtgDataParser.java @@ -199,7 +199,7 @@ public final class MtgDataParser implements Iterator { "([A-Z0-9][A-Z0-9][A-Z0-9] [CURM], )*[A-Z0-9][A-Z0-9][A-Z0-9] [CURM]", nextline)) { rules.add(nextline); } - ret.setCardRules(rules.toArray(new String[rules.size()])); + ret.setCardRules(StringUtils.join(rules, '\n')); return nextline; } diff --git a/src/main/java/forge/card/cardfactory/CardFactory.java b/src/main/java/forge/card/cardfactory/CardFactory.java index 9375f8f53c5..121c9d02774 100644 --- a/src/main/java/forge/card/cardfactory/CardFactory.java +++ b/src/main/java/forge/card/cardfactory/CardFactory.java @@ -227,7 +227,7 @@ public class CardFactory { public final Card getCard(final CardPrinted cp, final Player owner) { //System.out.println(cardName); - Card c = this.getCard2(cp.getCard().getCardScript(), owner); + Card c = this.getCard2(cp.getRules().getCardScript(), owner); if (c != null) { c.setCurSetCode(cp.getEdition()); diff --git a/src/main/java/forge/deck/Deck.java b/src/main/java/forge/deck/Deck.java index 78bae7ef9ef..b7bbc1e0d92 100644 --- a/src/main/java/forge/deck/Deck.java +++ b/src/main/java/forge/deck/Deck.java @@ -203,9 +203,9 @@ public class Deck extends DeckBase implements Iterable cp: d) { for(Entry e : cp.getValue()) { - if ( e.getKey().getCard().getRemAIDecks() ) + if ( e.getKey().getRules().getRemAIDecks() ) return false; } } diff --git a/src/main/java/forge/deck/DeckFormat.java b/src/main/java/forge/deck/DeckFormat.java index f570e606020..9d9b564f83a 100644 --- a/src/main/java/forge/deck/DeckFormat.java +++ b/src/main/java/forge/deck/DeckFormat.java @@ -136,7 +136,7 @@ public enum DeckFormat { if (null == cmd || cmd.isEmpty()) { return "is missing a commander"; } - if (!cmd.get(0).getCard().getType().isLegendary()) { + if (!cmd.get(0).getRules().getType().isLegendary()) { return "has a commander that is not a legendary creature"; } @@ -152,7 +152,7 @@ public enum DeckFormat { int phenoms = 0; for (Entry cp : planes) { - if (cp.getKey().getCard().getType().typeContains(CardCoreType.Phenomenon)) { + if (cp.getKey().getRules().getType().typeContains(CardCoreType.Phenomenon)) { phenoms++; } if (cp.getValue() > 1) { @@ -197,7 +197,7 @@ public enum DeckFormat { for (Entry cp : Aggregates.groupSumBy(tmp, CardPrinted.FN_GET_NAME)) { CardPrinted simpleCard = CardDb.instance().getCard(cp.getKey()); - boolean canHaveMultiple = simpleCard.getCard().getType().isBasicLand() || limitExceptions.contains(cp.getKey()); + boolean canHaveMultiple = simpleCard.getRules().getType().isBasicLand() || limitExceptions.contains(cp.getKey()); if (!canHaveMultiple && cp.getValue() > maxCopies) { return String.format("must not contain more than %d of '%s' card", maxCopies, cp.getKey()); diff --git a/src/main/java/forge/deck/DeckgenUtil.java b/src/main/java/forge/deck/DeckgenUtil.java index 8362d339197..c60045c8d9b 100644 --- a/src/main/java/forge/deck/DeckgenUtil.java +++ b/src/main/java/forge/deck/DeckgenUtil.java @@ -315,7 +315,7 @@ public class DeckgenUtil { CardPool schemes = new CardPool(); List allSchemes = new ArrayList(); for (CardPrinted c : CardDb.variants().getAllCards()) { - if (c.getCard().getType().isScheme()) { + if (c.getRules().getType().isScheme()) { allSchemes.add(c); } } @@ -340,7 +340,7 @@ public class DeckgenUtil { CardPool res = new CardPool(); List allPlanars = new ArrayList(); for (CardPrinted c : CardDb.variants().getAllCards()) { - if (c.getCard().getType().isPlane() || c.getCard().getType().isPhenomenon()) { + if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) { allPlanars.add(c); } } @@ -352,12 +352,12 @@ public class DeckgenUtil { CardPrinted rndPlane = Aggregates.random(allPlanars); allPlanars.remove(rndPlane); - if(rndPlane.getCard().getType().isPhenomenon() && phenoms < 2) + if(rndPlane.getRules().getType().isPhenomenon() && phenoms < 2) { res.add(rndPlane); phenoms++; } - else if (rndPlane.getCard().getType().isPlane()) + else if (rndPlane.getRules().getType().isPlane()) { res.add(rndPlane); } diff --git a/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java b/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java index 5105b6179e8..05730c6cbac 100644 --- a/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java +++ b/src/main/java/forge/deck/generate/GenerateColoredDeckBase.java @@ -114,10 +114,10 @@ public abstract class GenerateColoredDeckBase { throw new RuntimeException("Generate2ColorDeck : get2ColorDeck -- looped too much -- Cr12"); } - tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getCard().getSetsPrinted()).getKey())); + tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getRules().getSetsPrinted()).getKey())); final int n = this.cardCounts.get(cp.getName()); this.cardCounts.put(cp.getName(), n + 1); - tmpDeck.append(cp.getName() + " " + cp.getCard().getManaCost() + "\n"); + tmpDeck.append(cp.getName() + " " + cp.getRules().getManaCost() + "\n"); } } @@ -133,7 +133,7 @@ public abstract class GenerateColoredDeckBase { // not an error if looped too much - could play singleton mode, with 6 slots for 3 non-basic lands. CardPrinted cp = CardDb.instance().getCard(s); - tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getCard().getSetsPrinted()).getKey())); + tDeck.add(CardDb.instance().getCard(cp.getName(), Aggregates.random(cp.getRules().getSetsPrinted()).getKey())); final int n = this.cardCounts.get(s); this.cardCounts.put(s, n + 1); @@ -169,7 +169,7 @@ public abstract class GenerateColoredDeckBase { this.cardCounts.put(color, nLand); CardPrinted cp = CardDb.instance().getCard(color); - String basicLandSet = Aggregates.random(cp.getCard().getSetsPrinted()).getKey(); + String basicLandSet = Aggregates.random(cp.getRules().getSetsPrinted()).getKey(); for (int j = 0; j <= nLand; j++) { tDeck.add(CardDb.instance().getCard(cp.getName(), basicLandSet)); } @@ -236,7 +236,7 @@ public abstract class GenerateColoredDeckBase { // TODO: count hybrid mana differently? for (Entry cpe : outList) { - int profile = cpe.getKey().getCard().getManaCost().getColorProfile(); + int profile = cpe.getKey().getRules().getManaCost().getColorProfile(); if ((profile & MagicColor.WHITE) != 0) { increment(res, Constant.Color.BASIC_LANDS.get(0), cpe.getValue()); diff --git a/src/main/java/forge/deck/io/DeckSerializer.java b/src/main/java/forge/deck/io/DeckSerializer.java index ec15af9c818..acee3a48715 100644 --- a/src/main/java/forge/deck/io/DeckSerializer.java +++ b/src/main/java/forge/deck/io/DeckSerializer.java @@ -149,7 +149,7 @@ public class DeckSerializer extends StorageReaderFolder implements IItemSe for (final Entry card : d.getMain()) { // System.out.println(card.getSets().get(card.getSets().size() - 1).URL); for( int i = card.getValue().intValue(); i > 0; --i ) { - list.add(card.getKey().getCard().getEditionInfo(card.getKey().getEdition()).getUrl()); + list.add(card.getKey().getRules().getEditionInfo(card.getKey().getEdition()).getUrl()); } } /* diff --git a/src/main/java/forge/game/GameNew.java b/src/main/java/forge/game/GameNew.java index b11b6632e14..9506614a773 100644 --- a/src/main/java/forge/game/GameNew.java +++ b/src/main/java/forge/game/GameNew.java @@ -60,7 +60,7 @@ public class GameNew { // apply random pictures for cards if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_CARD_ART)) { - final int cntVariants = cardPrinted.getCard().getEditionInfo(cardPrinted.getEdition()).getCopiesCount(); + final int cntVariants = cardPrinted.getRules().getEditionInfo(cardPrinted.getEdition()).getCopiesCount(); if (cntVariants > 1) { card.setRandomPicture(generator.nextInt(cntVariants - 1) + 1); card.setImageFilename(CardUtil.buildFilename(card)); @@ -195,7 +195,7 @@ public class GameNew { for ( Entry ds : toUse ) { for (Entry cp : ds.getValue()) { - if ( cp.getKey().getCard().getRemAIDecks() ) + if ( cp.getKey().getRules().getRemAIDecks() ) result.add(cp.getKey()); } } @@ -207,7 +207,7 @@ public class GameNew { Set myRemovedAnteCards = new HashSet(); for ( Entry ds : toUse ) { for (Entry cp : ds.getValue()) { - if ( cp.getKey().getCard().rulesContain(keywordToRemove) ) + if ( cp.getKey().getRules().rulesContain(keywordToRemove) ) myRemovedAnteCards.add(cp.getKey()); } } diff --git a/src/main/java/forge/game/MatchStartHelper.java b/src/main/java/forge/game/MatchStartHelper.java index c93b8997fc6..0f3a0d3894b 100644 --- a/src/main/java/forge/game/MatchStartHelper.java +++ b/src/main/java/forge/game/MatchStartHelper.java @@ -28,8 +28,8 @@ public class MatchStartHelper { PlayerStartConditions start = new PlayerStartConditions(deck); - start.setStartingLife(start.getStartingLife() + avatar.getCard().getLife()); - start.setStartingHand(start.getStartingHand() + avatar.getCard().getHand()); + start.setStartingLife(start.getStartingLife() + avatar.getRules().getLife()); + start.setStartingHand(start.getStartingHand() + avatar.getRules().getHand()); start.setCardsInCommand(Arrays.asList(avatar)); players.put(player, start); diff --git a/src/main/java/forge/game/limited/BoosterDraftAI.java b/src/main/java/forge/game/limited/BoosterDraftAI.java index 8bbcedb4d3b..837e426c399 100644 --- a/src/main/java/forge/game/limited/BoosterDraftAI.java +++ b/src/main/java/forge/game/limited/BoosterDraftAI.java @@ -79,11 +79,11 @@ public class BoosterDraftAI { for(Pair p : rankedCards) { // If a card is not ai playable, somewhat decrease its rating - if( p.getKey().getCard().getRemAIDecks() ) + if( p.getKey().getRules().getRemAIDecks() ) p.setValue(p.getValue() + TAKE_BEST_THRESHOLD); // if I cannot choose more colors, and the card cannot be played with chosen colors, decrease its rating. - if( !canAddMoreColors && !p.getKey().getCard().getManaCost().canBePaidWithAvaliable(currentChoice)) + if( !canAddMoreColors && !p.getKey().getRules().getManaCost().canBePaidWithAvaliable(currentChoice)) p.setValue(p.getValue() + 10); } diff --git a/src/main/java/forge/game/limited/DeckColors.java b/src/main/java/forge/game/limited/DeckColors.java index e624a6c118f..70ae0688169 100644 --- a/src/main/java/forge/game/limited/DeckColors.java +++ b/src/main/java/forge/game/limited/DeckColors.java @@ -45,7 +45,7 @@ class DeckColors { */ public void addColorsOf(CardPrinted pickedCard) { - SpellManaCost colorsInCard = pickedCard.getCard().getManaCost(); + SpellManaCost colorsInCard = pickedCard.getRules().getManaCost(); int colorsCanAdd = MagicColor.ALL_COLORS & ~getChosenColors().getColor(); int colorsWantAdd = colorsInCard.getColorProfile() & colorsCanAdd; diff --git a/src/main/java/forge/game/limited/LimitedDeck.java b/src/main/java/forge/game/limited/LimitedDeck.java index e9d17122d7c..cbb1f331906 100644 --- a/src/main/java/forge/game/limited/LimitedDeck.java +++ b/src/main/java/forge/game/limited/LimitedDeck.java @@ -201,19 +201,19 @@ public class LimitedDeck { System.out.println("DECK"); for (CardPrinted c : deckList) { i++; - System.out.println(i + ". " + c.toString() + ": " + c.getCard().getManaCost().toString()); + System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString()); } i = 0; System.out.println("NOT PLAYABLE"); for (CardPrinted c : availableList) { i++; - System.out.println(i + ". " + c.toString() + ": " + c.getCard().getManaCost().toString()); + System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString()); } i = 0; System.out.println("NOT PICKED"); for (CardPrinted c : getAiPlayables()) { i++; - System.out.println(i + ". " + c.toString() + ": " + c.getCard().getManaCost().toString()); + System.out.println(i + ". " + c.toString() + ": " + c.getRules().getManaCost().toString()); } } @@ -363,7 +363,7 @@ public class LimitedDeck { // count each card color using mana costs for (int i = 0; i < deckList.size(); i++) { - final SpellManaCost mc = deckList.get(i).getCard().getManaCost(); + final SpellManaCost mc = deckList.get(i).getRules().getManaCost(); // count each mana symbol in the mana cost for (ManaCostShard shard : mc.getShards()) { @@ -428,7 +428,7 @@ public class LimitedDeck { List> ranked = rankCards(others); for (Pair bean : ranked) { // Want a card that has just one "off" color. - ColorSet off = colors.getOffColors(bean.getValue().getCard().getColor()); + ColorSet off = colors.getOffColors(bean.getValue().getRules().getColor()); if (off.isWhite() || off.isBlue() || off.isBlack() || off.isRed() || off.isGreen()) { colors = ColorSet.fromMask(colors.getColor() | off.getColor()); break; @@ -447,7 +447,7 @@ public class LimitedDeck { nCards--; if (Preferences.DEV_MODE) { System.out.println("Third Color[" + nCards + "]:" + bean.getValue().getName() + "(" - + bean.getValue().getCard().getManaCost() + ")"); + + bean.getValue().getRules().getManaCost() + ")"); } } else { break; @@ -472,7 +472,7 @@ public class LimitedDeck { nCards--; if (Preferences.DEV_MODE) { System.out.println("Random[" + nCards + "]:" + bean.getValue().getName() + "(" - + bean.getValue().getCard().getManaCost() + ")"); + + bean.getValue().getRules().getManaCost() + ")"); } } else { break; @@ -496,7 +496,7 @@ public class LimitedDeck { getAiPlayables().remove(cardToAdd); if (Preferences.DEV_MODE) { System.out.println("Others[" + num + "]:" + cardToAdd.getName() + " (" - + cardToAdd.getCard().getManaCost() + ")"); + + cardToAdd.getRules().getManaCost() + ")"); } num = addDeckHintsCards(cardToAdd, num); } else { @@ -516,9 +516,9 @@ public class LimitedDeck { */ private int addDeckHintsCards(CardPrinted cardToAdd, int num) { // cards with DeckHints will try to grab additional cards from the pool - if (cardToAdd.getCard().getDeckHints() != null - && cardToAdd.getCard().getDeckHints().getType() != DeckHints.Type.NONE) { - DeckHints hints = cardToAdd.getCard().getDeckHints(); + if (cardToAdd.getRules().getDeckHints() != null + && cardToAdd.getRules().getDeckHints().getType() != DeckHints.Type.NONE) { + DeckHints hints = cardToAdd.getRules().getDeckHints(); Iterable onColor = Iterables.filter(aiPlayables, Predicates.compose(hasColor, CardPrinted.FN_GET_RULES)); List comboCards = hints.filter(onColor); @@ -557,16 +557,16 @@ public class LimitedDeck { int numOthers = 0; for (ListIterator it = deckList.listIterator(); it.hasNext();) { CardPrinted card = it.next(); - if (card.getCard().getRemRandomDecks()) { + if (card.getRules().getRemRandomDecks()) { List comboCards = new ArrayList(); - if (card.getCard().getDeckNeeds() != null - && card.getCard().getDeckNeeds().getType() != DeckHints.Type.NONE) { - DeckHints needs = card.getCard().getDeckNeeds(); + if (card.getRules().getDeckNeeds() != null + && card.getRules().getDeckNeeds().getType() != DeckHints.Type.NONE) { + DeckHints needs = card.getRules().getDeckNeeds(); comboCards.addAll(needs.filter(deckList)); } - if (card.getCard().getDeckHints() != null - && card.getCard().getDeckHints().getType() != DeckHints.Type.NONE) { - DeckHints hints = card.getCard().getDeckHints(); + if (card.getRules().getDeckHints() != null + && card.getRules().getDeckHints().getType() != DeckHints.Type.NONE) { + DeckHints hints = card.getRules().getDeckHints(); comboCards.addAll(hints.filter(deckList)); } if (comboCards.isEmpty()) { @@ -575,7 +575,7 @@ public class LimitedDeck { } it.remove(); availableList.add(card); - if (card.getCard().getType().isCreature()) { + if (card.getRules().getType().isCreature()) { numCreatures++; } else { numOthers++; @@ -616,7 +616,7 @@ public class LimitedDeck { num--; getAiPlayables().remove(c); if (Preferences.DEV_MODE) { - System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getCard().getManaCost() + ")"); + System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getRules().getManaCost() + ")"); } num = addDeckHintsCards(c, num); } else { @@ -642,7 +642,7 @@ public class LimitedDeck { Predicate filter = Predicates.compose(CardRulesPredicates.Presets.IS_CREATURE, CardPrinted.FN_GET_RULES); for (CardPrinted creature : Iterables.filter(deckList, filter)) { - int cmc = creature.getCard().getManaCost().getCMC(); + int cmc = creature.getRules().getManaCost().getCMC(); if (cmc < 1) { cmc = 1; } else if (cmc > 6) { @@ -653,7 +653,7 @@ public class LimitedDeck { for (Pair bean : creatures) { CardPrinted c = bean.getValue(); - int cmc = c.getCard().getManaCost().getCMC(); + int cmc = c.getRules().getManaCost().getCMC(); if (cmc < 1) { cmc = 1; } else if (cmc > 6) { @@ -681,12 +681,12 @@ public class LimitedDeck { getAiPlayables().remove(c); creatureCosts.put(cmc, creatureCosts.get(cmc) + 1); if (Preferences.DEV_MODE) { - System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getCard().getManaCost() + ")"); + System.out.println("Creature[" + num + "]:" + c.getName() + " (" + c.getRules().getManaCost() + ")"); } num = addDeckHintsCards(c, num); } else { if (Preferences.DEV_MODE) { - System.out.println(c.getName() + " not added because CMC " + c.getCard().getManaCost().getCMC() + System.out.println(c.getName() + " not added because CMC " + c.getRules().getManaCost().getCMC() + " has " + currentAtCmc + " already."); } } @@ -727,7 +727,7 @@ public class LimitedDeck { private double getAverageCMC(List cards) { double sum = 0.0; for (CardPrinted cardPrinted : cards) { - sum += cardPrinted.getCard().getManaCost().getCMC(); + sum += cardPrinted.getRules().getManaCost().getCMC(); } return sum / cards.size(); } diff --git a/src/main/java/forge/game/limited/SealedDeck.java b/src/main/java/forge/game/limited/SealedDeck.java index ead9dc0cd58..fe71c48252b 100644 --- a/src/main/java/forge/game/limited/SealedDeck.java +++ b/src/main/java/forge/game/limited/SealedDeck.java @@ -48,7 +48,7 @@ public class SealedDeck extends LimitedDeck { for (int i = 0; i < limit; i++) { CardPrinted cp = rankedCards.get(i).getValue(); colorChooserList.add(cp); - System.out.println(cp.getName() + " " + cp.getCard().getManaCost().toString()); + System.out.println(cp.getName() + " " + cp.getRules().getManaCost().toString()); } Iterable rules = Iterables.transform(colorChooserList, CardPrinted.FN_GET_RULES); diff --git a/src/main/java/forge/gui/GuiMigrateLocalMWSSetPicturesHQ.java b/src/main/java/forge/gui/GuiMigrateLocalMWSSetPicturesHQ.java index 92c96f00afd..a036c9424e8 100644 --- a/src/main/java/forge/gui/GuiMigrateLocalMWSSetPicturesHQ.java +++ b/src/main/java/forge/gui/GuiMigrateLocalMWSSetPicturesHQ.java @@ -501,7 +501,7 @@ public final class GuiMigrateLocalMWSSetPicturesHQ extends DefaultBoundedRangeMo if (imgFN.equals("none") || (!imgFN.contains(edCode) && !imgFN.contains(setCode2))) { imgFN = GuiDisplayUtil.cleanStringMWS(cp.getName()); - final int maxIndex = cp.getCard().getEditionInfo(cp.getEdition()).getCopiesCount(); + final int maxIndex = cp.getRules().getEditionInfo(cp.getEdition()).getCopiesCount(); String k = maxIndex > 1 ? Integer.valueOf(cp.getArtIndex() + 1).toString() : ""; final String fn = GuiDisplayUtil.cleanStringMWS(cp.getName()) + k + ".full.jpg"; final String destFn = imgBase + File.pathSeparator + edCode + File.pathSeparator + imgFN + k + ".jpg"; diff --git a/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java b/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java index 2d905c112e6..cb451b2bd69 100644 --- a/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java +++ b/src/main/java/forge/gui/deckeditor/controllers/CEditorQuestCardShop.java @@ -460,7 +460,7 @@ public final class CEditorQuestCardShop extends ACEditorBase> cardsToRemove = new LinkedList>(); for (Map.Entry item : getTableDeck().getCards()) { CardPrinted card = (CardPrinted)item.getKey(); - int numToKeep = card.getCard().getType().isBasic() ? 50 : 4; + int numToKeep = card.getRules().getType().isBasic() ? 50 : 4; if ("Relentless Rats".equals(card.getName())) { numToKeep = Integer.MAX_VALUE; } diff --git a/src/main/java/forge/gui/deckeditor/controllers/CStatistics.java b/src/main/java/forge/gui/deckeditor/controllers/CStatistics.java index 56afa281b7c..24971e0bacf 100644 --- a/src/main/java/forge/gui/deckeditor/controllers/CStatistics.java +++ b/src/main/java/forge/gui/deckeditor/controllers/CStatistics.java @@ -101,7 +101,7 @@ public enum CStatistics implements ICDoc { int tmc = 0; for (final Entry e : deck) { - final CardRules cardRules = e.getKey().getCard(); + final CardRules cardRules = e.getKey().getRules(); final int count = e.getValue(); final int cmc = cardRules.getManaCost().getCMC(); diff --git a/src/main/java/forge/gui/deckeditor/tables/SColumnUtil.java b/src/main/java/forge/gui/deckeditor/tables/SColumnUtil.java index 174c5800215..96003a16286 100644 --- a/src/main/java/forge/gui/deckeditor/tables/SColumnUtil.java +++ b/src/main/java/forge/gui/deckeditor/tables/SColumnUtil.java @@ -307,19 +307,19 @@ public final class SColumnUtil { private static final Pattern AE_FINDER = Pattern.compile("AE", Pattern.LITERAL); private static SpellManaCost toManaCost(final InventoryItem i) { - return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : SpellManaCost.NO_COST; + return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getManaCost() : SpellManaCost.NO_COST; } private static ColorSet toColor(final InventoryItem i) { - return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getColor() : ColorSet.getNullColor(); + return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getColor() : ColorSet.getNullColor(); } private static Integer toPower(final InventoryItem i) { Integer result = -1; if (i instanceof CardPrinted) { - result = ((CardPrinted) i).getCard().getIntPower(); + result = ((CardPrinted) i).getRules().getIntPower(); if (result == null) { - result = Integer.valueOf(((CardPrinted) i).getCard().getLoyalty()); + result = Integer.valueOf(((CardPrinted) i).getRules().getLoyalty()); if (result == null) { result = -1; } } } @@ -327,11 +327,11 @@ public final class SColumnUtil { } private static Integer toToughness(final InventoryItem i) { - return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getIntToughness() : -1; + return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getIntToughness() : -1; } private static Integer toCMC(final InventoryItem i) { - return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost().getCMC() : -1; + return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getManaCost().getCMC() : -1; } private static CardRarity toRarity(final InventoryItem i) { @@ -348,11 +348,11 @@ public final class SColumnUtil { } private static Integer toAiCmp(final InventoryItem i) { - return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatusComparable() : Integer.valueOf(-1); + return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getAiStatusComparable() : Integer.valueOf(-1); } private static String toAiStr(final InventoryItem i) { - return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatus() : "n/a"; + return i instanceof CardPrinted ? ((CardPrinted) i).getRules().getAiStatus() : "n/a"; } //========== @@ -427,7 +427,7 @@ public final class SColumnUtil { @Override public Comparable apply(final Entry from) { InventoryItem i = from.getKey(); - return i instanceof CardPrinted ? ((CardPrinted)i).getCard().getType().toString() : i.getItemType(); + return i instanceof CardPrinted ? ((CardPrinted)i).getRules().getType().toString() : i.getItemType(); } }; @@ -436,7 +436,7 @@ public final class SColumnUtil { @Override public Object apply(final Entry from) { InventoryItem i = from.getKey(); - return i instanceof CardPrinted ? ((CardPrinted)i).getCard().getType().toString() : i.getItemType(); + return i instanceof CardPrinted ? ((CardPrinted)i).getRules().getType().toString() : i.getItemType(); } }; diff --git a/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java b/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java index 3390e89e5a6..ec1c1e87669 100644 --- a/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java +++ b/src/main/java/forge/gui/download/GuiDownloadPicturesLQ.java @@ -64,7 +64,7 @@ public class GuiDownloadPicturesLQ extends GuiDownloader { for (final CardPrinted c : CardDb.instance().getUniqueCards()) { //System.out.println(c.getName()); - CardRules firstSide = c.getCard(); + CardRules firstSide = c.getRules(); this.createDLObjects(firstSide); CardRules secondSide = firstSide.getSlavePart(); diff --git a/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java b/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java index 1fa7f7350cc..4a45eeb298f 100644 --- a/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java +++ b/src/main/java/forge/gui/download/GuiDownloadSetPicturesLQ.java @@ -68,7 +68,7 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader { final boolean foundSetImage = imgFN.contains(setCode3) || imgFN.contains(setCode2); if (!foundSetImage) { - final int artsCnt = c.getCard().getEditionInfo(setCode3).getCopiesCount(); + final int artsCnt = c.getRules().getEditionInfo(setCode3).getCopiesCount(); final String filename = CardUtil.buildIdealFilename(cardName, c.getArtIndex(), artsCnt); String url = urlBase + setCode2 + "/" + Base64Coder.encodeString(filename, true); cList.add(new DownloadObject(url, new File(this.picturesPath + File.separator + setCode3, filename))); @@ -100,9 +100,9 @@ public class GuiDownloadSetPicturesLQ extends GuiDownloader { continue; // we don't want cards from unknown sets } - this.addCardToList(cList, c, c.getCard().getName()); - if (c.getCard().isDoubleFaced()) { - this.addCardToList(cList, c, c.getCard().getSlavePart().getName()); + this.addCardToList(cList, c, c.getRules().getName()); + if (c.getRules().isDoubleFaced()) { + this.addCardToList(cList, c, c.getRules().getSlavePart().getName()); } } diff --git a/src/main/java/forge/gui/home/variant/CSubmenuArchenemy.java b/src/main/java/forge/gui/home/variant/CSubmenuArchenemy.java index 7a731c1e01c..0ed049becc0 100644 --- a/src/main/java/forge/gui/home/variant/CSubmenuArchenemy.java +++ b/src/main/java/forge/gui/home/variant/CSubmenuArchenemy.java @@ -69,7 +69,7 @@ public enum CSubmenuArchenemy implements ICDoc { @Override public boolean apply(CardPrinted arg0) { - if(arg0.getCard().getType().isScheme()) + if(arg0.getRules().getType().isScheme()) { return true; } diff --git a/src/main/java/forge/gui/home/variant/CSubmenuPlanechase.java b/src/main/java/forge/gui/home/variant/CSubmenuPlanechase.java index 238cbe07f73..d0f64d7e8cb 100644 --- a/src/main/java/forge/gui/home/variant/CSubmenuPlanechase.java +++ b/src/main/java/forge/gui/home/variant/CSubmenuPlanechase.java @@ -68,7 +68,7 @@ public enum CSubmenuPlanechase implements ICDoc { @Override public boolean apply(CardPrinted arg0) { - if(arg0.getCard().getType().isPlane() || arg0.getCard().getType().isPhenomenon()) + if(arg0.getRules().getType().isPlane() || arg0.getRules().getType().isPhenomenon()) { return true; } diff --git a/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java b/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java index c9873ec4378..186753c1d3c 100644 --- a/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java +++ b/src/main/java/forge/gui/home/variant/VSubmenuVanguard.java @@ -95,13 +95,13 @@ public enum VSubmenuVanguard implements IVSubmenu { aiListData.add("Random"); for (CardPrinted cp : getAllAvatars()) { humanListData.add(cp); - if (!cp.getCard().getRemRandomDecks()) { + if (!cp.getRules().getRemRandomDecks()) { nonRandomHumanAvatars.add(cp); } - if (!cp.getCard().getRemAIDecks()) { + if (!cp.getRules().getRemAIDecks()) { aiListData.add(cp); allAiAvatars.add(cp); - if (!cp.getCard().getRemRandomDecks()) { + if (!cp.getRules().getRemRandomDecks()) { nonRandomAiAvatars.add(cp); } } @@ -359,7 +359,7 @@ public enum VSubmenuVanguard implements IVSubmenu { public Iterable getAllAvatars() { if ( allAvatars.isEmpty() ) { for(CardPrinted c : CardDb.variants().getAllCards()) { - if( c.getCard().getType().isVanguard()) + if( c.getRules().getType().isVanguard()) allAvatars.add(c); } } diff --git a/src/main/java/forge/item/CardDb.java b/src/main/java/forge/item/CardDb.java index f120e94b7cb..342f9d230bc 100644 --- a/src/main/java/forge/item/CardDb.java +++ b/src/main/java/forge/item/CardDb.java @@ -416,7 +416,7 @@ public final class CardDb { for (final Entry s : card.getSetsPrinted()) { lastAdded = this.addToLists(card, cardName, s); } - if ( lastAdded.getCard().isTraditional() ) + if ( lastAdded.getRules().isTraditional() ) uniqueCommonCards.put(cardName, lastAdded); else uniqueSpecialCards.put(cardName, lastAdded); diff --git a/src/main/java/forge/item/CardPrinted.java b/src/main/java/forge/item/CardPrinted.java index 5c4606969f2..18337408976 100644 --- a/src/main/java/forge/item/CardPrinted.java +++ b/src/main/java/forge/item/CardPrinted.java @@ -120,7 +120,7 @@ public final class CardPrinted implements Comparable, InventoryItem * * @return the card */ - public CardRules getCard() { + public CardRules getRules() { return this.card; } diff --git a/src/main/java/forge/item/ItemPoolView.java b/src/main/java/forge/item/ItemPoolView.java index 226d7e80a78..81eefc6d75a 100644 --- a/src/main/java/forge/item/ItemPoolView.java +++ b/src/main/java/forge/item/ItemPoolView.java @@ -47,7 +47,7 @@ public class ItemPoolView implements Iterable from) { final T item = from.getKey(); - return item instanceof CardPrinted ? ((CardPrinted) item).getCard() : null; + return item instanceof CardPrinted ? ((CardPrinted) item).getRules() : null; } }; diff --git a/src/test/java/forge/item/DeckHintsTest.java b/src/test/java/forge/item/DeckHintsTest.java index b04c93157a2..b4292c517de 100644 --- a/src/test/java/forge/item/DeckHintsTest.java +++ b/src/test/java/forge/item/DeckHintsTest.java @@ -29,7 +29,7 @@ public class DeckHintsTest { void test() { CardPrinted cp = readCard("griffin_rider.txt"); Assert.assertEquals("Griffin Rider", cp.getName()); - DeckHints hints = cp.getCard().getDeckHints(); + DeckHints hints = cp.getRules().getDeckHints(); Assert.assertNotNull(hints); Assert.assertEquals(DeckHints.Type.TYPE, hints.getType()); @@ -50,7 +50,7 @@ public class DeckHintsTest { void testCards() { CardPrinted cp = readCard("throne_of_empires.txt"); Assert.assertEquals("Throne of Empires", cp.getName()); - DeckHints hints = cp.getCard().getDeckHints(); + DeckHints hints = cp.getRules().getDeckHints(); Assert.assertNotNull(hints); Assert.assertEquals(DeckHints.Type.NAME, hints.getType()); @@ -71,7 +71,7 @@ public class DeckHintsTest { @Test(timeOut = 1000, enabled = true) void testKeywords() { CardPrinted cp = readCard("mwonvuli_beast_tracker.txt"); - DeckHints hints = cp.getCard().getDeckHints(); + DeckHints hints = cp.getRules().getDeckHints(); Assert.assertNotNull(hints); Assert.assertEquals(DeckHints.Type.KEYWORD, hints.getType()); @@ -90,7 +90,7 @@ public class DeckHintsTest { @Test(timeOut = 1000, enabled = true) void testColor() { CardPrinted cp = readCard("wurms_tooth.txt"); - DeckHints hints = cp.getCard().getDeckNeeds(); + DeckHints hints = cp.getRules().getDeckNeeds(); Assert.assertNotNull(hints); Assert.assertEquals(DeckHints.Type.COLOR, hints.getType()); @@ -110,7 +110,7 @@ public class DeckHintsTest { @Test(timeOut = 1000, enabled = false) void testNoFilter() { CardPrinted cp = readCard("assault_griffin.txt"); - DeckHints hints = cp.getCard().getDeckHints(); + DeckHints hints = cp.getRules().getDeckHints(); Assert.assertEquals("Assault Griffin", cp.getName()); Assert.assertNotNull(hints); Assert.assertEquals(DeckHints.Type.NONE, hints.getType());