move methods from cardutil to magepermanent, cardview:getColorText now uses ObjectColor.getDescription

This commit is contained in:
igoudt 2017-04-26 09:29:38 +02:00
parent b3110af503
commit 27aea04820
4 changed files with 15 additions and 39 deletions

View file

@ -151,7 +151,7 @@ public class CardPluginImpl implements CardPlugin {
outerLoop: outerLoop:
// //
for (MagePermanent permanent : permanents) { for (MagePermanent permanent : permanents) {
if (!CardUtil.isLand(permanent) || CardUtil.isCreature(permanent)) { if (!permanent.isLand() || permanent.isCreature()) {
continue; continue;
} }
@ -418,11 +418,11 @@ public class CardPluginImpl implements CardPlugin {
public boolean isType(MagePermanent card) { public boolean isType(MagePermanent card) {
switch (this) { switch (this) {
case land: case land:
return CardUtil.isLand(card); return card.isLand();
case creature: case creature:
return CardUtil.isCreature(card); return card.isCreature();
case other: case other:
return !CardUtil.isLand(card) && !CardUtil.isCreature(card); return !card.isLand() && !card.isCreature();
case attached: case attached:
return card.getOriginalPermanent().isAttachedToPermanent(); return card.getOriginalPermanent().isAttachedToPermanent();
default: default:

View file

@ -10,4 +10,12 @@ public abstract class MagePermanent extends MageCard {
public abstract void update(PermanentView card); public abstract void update(PermanentView card);
public abstract PermanentView getOriginalPermanent(); public abstract PermanentView getOriginalPermanent();
public boolean isCreature(){
return getOriginal().isCreature();
}
public boolean isLand(){
return getOriginal().isLand();
}
} }

View file

@ -21,25 +21,6 @@ public final class CardUtil {
private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*"; private static final String regexGreen = ".*\\x7b.{0,2}G.{0,2}\\x7d.*";
private static final String regexWhite = ".*\\x7b.{0,2}W.{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<String> manaCost, ObjectColor originalColor, List<String> rules) { public static int getColorIdentitySortValue(List<String> manaCost, ObjectColor originalColor, List<String> rules) {
ObjectColor color = new ObjectColor(originalColor); ObjectColor color = new ObjectColor(originalColor);
for (String rule : rules) { for (String rule : rules) {

View file

@ -28,6 +28,8 @@
package mage.view; package mage.view;
import java.util.*; import java.util.*;
import com.sun.xml.internal.ws.util.StringUtils;
import mage.MageObject; import mage.MageObject;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Abilities; import mage.abilities.Abilities;
@ -963,22 +965,7 @@ public class CardView extends SimpleCardView {
} }
public String getColorText() { public String getColorText() {
if (getColor().getColorCount() == 0) { return StringUtils.capitalize(getColor().getDescription());
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 "";
} }
public String getTypeText() { public String getTypeText() {