From 27aea04820d2edc39f79ed0e13e8decd5873bacf Mon Sep 17 00:00:00 2001 From: igoudt Date: Wed, 26 Apr 2017 09:29:38 +0200 Subject: [PATCH] move methods from cardutil to magepermanent, cardview:getColorText now uses ObjectColor.getDescription --- .../org/mage/plugins/card/CardPluginImpl.java | 8 ++++---- .../main/java/mage/cards/MagePermanent.java | 8 ++++++++ .../src/main/java/mage/utils/CardUtil.java | 19 ------------------- .../src/main/java/mage/view/CardView.java | 19 +++---------------- 4 files changed, 15 insertions(+), 39 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java index ba7356c073..080772869e 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/CardPluginImpl.java @@ -151,7 +151,7 @@ public class CardPluginImpl implements CardPlugin { outerLoop: // for (MagePermanent permanent : permanents) { - if (!CardUtil.isLand(permanent) || CardUtil.isCreature(permanent)) { + if (!permanent.isLand() || permanent.isCreature()) { continue; } @@ -418,11 +418,11 @@ public class CardPluginImpl implements CardPlugin { public boolean isType(MagePermanent card) { switch (this) { case land: - return CardUtil.isLand(card); + return card.isLand(); case creature: - return CardUtil.isCreature(card); + return card.isCreature(); case other: - return !CardUtil.isLand(card) && !CardUtil.isCreature(card); + return !card.isLand() && !card.isCreature(); case attached: return card.getOriginalPermanent().isAttachedToPermanent(); default: diff --git a/Mage.Common/src/main/java/mage/cards/MagePermanent.java b/Mage.Common/src/main/java/mage/cards/MagePermanent.java index acbcd5de07..a8320821b5 100644 --- a/Mage.Common/src/main/java/mage/cards/MagePermanent.java +++ b/Mage.Common/src/main/java/mage/cards/MagePermanent.java @@ -10,4 +10,12 @@ public abstract class MagePermanent extends MageCard { public abstract void update(PermanentView card); public abstract PermanentView getOriginalPermanent(); + public boolean isCreature(){ + return getOriginal().isCreature(); + } + + public boolean isLand(){ + return getOriginal().isLand(); + } + } diff --git a/Mage.Common/src/main/java/mage/utils/CardUtil.java b/Mage.Common/src/main/java/mage/utils/CardUtil.java index da99b4de7f..ccd928f988 100644 --- a/Mage.Common/src/main/java/mage/utils/CardUtil.java +++ b/Mage.Common/src/main/java/mage/utils/CardUtil.java @@ -21,25 +21,6 @@ public final class CardUtil { private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*"; private static final String regexWhite = ".*\\x7b.{0,2}W.{0,2}\\x7d.*"; - - - - public static boolean isCreature(MagePermanent card) { - return is(card.getOriginal(), CardType.CREATURE); - } - - public static boolean isPlaneswalker(MagePermanent card) { - return is(card.getOriginal(), CardType.PLANESWALKER); - } - - public static boolean isLand(MagePermanent card) { - return is(card.getOriginal(), CardType.LAND); - } - - public static boolean is(CardView card, CardType type) { - return card.getCardTypes().contains(type); - } - public static int getColorIdentitySortValue(List manaCost, ObjectColor originalColor, List rules) { ObjectColor color = new ObjectColor(originalColor); for (String rule : rules) { diff --git a/Mage.Common/src/main/java/mage/view/CardView.java b/Mage.Common/src/main/java/mage/view/CardView.java index 8b567d89da..f2abab2320 100644 --- a/Mage.Common/src/main/java/mage/view/CardView.java +++ b/Mage.Common/src/main/java/mage/view/CardView.java @@ -28,6 +28,8 @@ package mage.view; import java.util.*; + +import com.sun.xml.internal.ws.util.StringUtils; import mage.MageObject; import mage.ObjectColor; import mage.abilities.Abilities; @@ -963,22 +965,7 @@ public class CardView extends SimpleCardView { } public String getColorText() { - if (getColor().getColorCount() == 0) { - return "Colorless"; - } else if (getColor().getColorCount() > 1) { - return "Gold"; - } else if (getColor().isBlack()) { - return "Black"; - } else if (getColor().isBlue()) { - return "Blue"; - } else if (getColor().isWhite()) { - return "White"; - } else if (getColor().isGreen()) { - return "Green"; - } else if (getColor().isRed()) { - return "Red"; - } - return ""; + return StringUtils.capitalize(getColor().getDescription()); } public String getTypeText() {