remove helper functions from cardUtil

This commit is contained in:
ingmargoudt 2017-04-07 16:40:38 +02:00
parent 314316f42f
commit 1649530e7b
6 changed files with 16 additions and 27 deletions

View file

@ -42,7 +42,6 @@ import mage.client.util.GUISizeHelper;
import mage.client.util.audio.AudioManager; import mage.client.util.audio.AudioManager;
import mage.client.util.layout.CardLayoutStrategy; import mage.client.util.layout.CardLayoutStrategy;
import mage.client.util.layout.impl.OldCardLayoutStrategy; import mage.client.util.layout.impl.OldCardLayoutStrategy;
import mage.utils.CardUtil;
import mage.view.CounterView; import mage.view.CounterView;
import mage.view.PermanentView; import mage.view.PermanentView;
@ -155,7 +154,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
changed = true; changed = true;
} else { } else {
if (!changed) { if (!changed) {
changed = CardUtil.isCreature(oldMagePermanent.getOriginalPermanent()) != CardUtil.isCreature(permanent); changed = oldMagePermanent.getOriginalPermanent().isCreature() != permanent.isCreature();
if (!changed) { if (!changed) {
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size(); int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
int s2 = oldMagePermanent.getLinks().size(); int s2 = oldMagePermanent.getLinks().size();

View file

@ -3,7 +3,6 @@ package mage.client.util.gui;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.constants.*; import mage.constants.*;
import mage.utils.CardUtil;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CounterView; import mage.view.CounterView;
import mage.view.PermanentView; import mage.view.PermanentView;
@ -269,9 +268,9 @@ public final class GuiDisplayUtil {
buffer.append("</td></tr></table>"); buffer.append("</td></tr></table>");
String pt = ""; String pt = "";
if (CardUtil.isCreature(card)) { if (card.isCreature()) {
pt = card.getPower() + '/' + card.getToughness(); pt = card.getPower() + '/' + card.getToughness();
} else if (CardUtil.isPlaneswalker(card)) { } else if (card.isPlanesWalker()) {
pt = card.getLoyalty(); pt = card.getLoyalty();
} }

View file

@ -9,7 +9,6 @@ import mage.client.util.ImageHelper;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.components.ImagePanelStyle; import mage.components.ImagePanelStyle;
import mage.constants.AbilityType; import mage.constants.AbilityType;
import mage.utils.CardUtil;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CounterView; import mage.view.CounterView;
import mage.view.PermanentView; import mage.view.PermanentView;
@ -232,9 +231,9 @@ public class CardPanelComponentImpl extends CardPanel {
// PT Text // PT Text
ptText = new GlowText(); ptText = new GlowText();
if (CardUtil.isCreature(gameCard)) { if (gameCard.isCreature()) {
ptText.setText(gameCard.getPower() + '/' + gameCard.getToughness()); ptText.setText(gameCard.getPower() + '/' + gameCard.getToughness());
} else if (CardUtil.isPlaneswalker(gameCard)) { } else if (gameCard.isPlanesWalker()) {
ptText.setText(gameCard.getLoyalty()); ptText.setText(gameCard.getLoyalty());
} }
// ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize)); // ptText.setFont(getFont().deriveFont(Font.BOLD, fontSize));
@ -424,7 +423,7 @@ public class CardPanelComponentImpl extends CardPanel {
imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize); imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2); imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
if (hasSickness() && CardUtil.isCreature(gameCard) && isPermanent()) { if (hasSickness() && gameCard.isCreature() && isPermanent()) {
overlayPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize); overlayPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
overlayPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2); overlayPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
} else { } else {
@ -571,11 +570,11 @@ public class CardPanelComponentImpl extends CardPanel {
super.update(card); super.update(card);
// Update card text // Update card text
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) { if (card.isCreature() && card.isPlanesWalker()) {
ptText.setText(card.getPower() + '/' + card.getToughness() + " (" + card.getLoyalty() + ')'); ptText.setText(card.getPower() + '/' + card.getToughness() + " (" + card.getLoyalty() + ')');
} else if (CardUtil.isCreature(card)) { } else if (card.isCreature()) {
ptText.setText(card.getPower() + '/' + card.getToughness()); ptText.setText(card.getPower() + '/' + card.getToughness());
} else if (CardUtil.isPlaneswalker(card)) { } else if (card.isPlanesWalker()) {
ptText.setText(card.getLoyalty()); ptText.setText(card.getLoyalty());
} else { } else {
ptText.setText(""); ptText.setText("");
@ -583,7 +582,7 @@ public class CardPanelComponentImpl extends CardPanel {
setText(card); setText(card);
// Summoning Sickness overlay // Summoning Sickness overlay
if (hasSickness() && CardUtil.isCreature(gameCard) && isPermanent()) { if (hasSickness() && card.isCreature() && isPermanent()) {
overlayPanel.setVisible(true); overlayPanel.setVisible(true);
} else { } else {
overlayPanel.setVisible(false); overlayPanel.setVisible(false);

View file

@ -10,7 +10,6 @@ import mage.client.dialog.PreferencesDialog;
import mage.constants.AbilityType; import mage.constants.AbilityType;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.utils.CardUtil;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CounterView; import mage.view.CounterView;
import mage.view.PermanentView; import mage.view.PermanentView;
@ -236,7 +235,7 @@ public abstract class CardRenderer {
// Draw summoning sickness overlay, and possibly other overlays // Draw summoning sickness overlay, and possibly other overlays
protected void drawOverlays(Graphics2D g) { protected void drawOverlays(Graphics2D g) {
if (CardUtil.isCreature(cardView) && cardView instanceof PermanentView) { if (cardView.isCreature() && cardView instanceof PermanentView) {
if (((PermanentView) cardView).hasSummoningSickness()) { if (((PermanentView) cardView).hasSummoningSickness()) {
int x1 = (int) (0.2 * cardWidth); int x1 = (int) (0.2 * cardWidth);
int x2 = (int) (0.8 * cardWidth); int x2 = (int) (0.8 * cardWidth);

View file

@ -1,11 +1,13 @@
package mage.cards; package mage.cards;
import java.util.List;
import mage.view.PermanentView; import mage.view.PermanentView;
import java.util.List;
public abstract class MagePermanent extends MageCard { public abstract class MagePermanent extends MageCard {
private static final long serialVersionUID = -3469258620601702171L; private static final long serialVersionUID = -3469258620601702171L;
public abstract List<MagePermanent> getLinks(); public abstract List<MagePermanent> getLinks();
public abstract void update(PermanentView card); public abstract void update(PermanentView card);
public abstract PermanentView getOriginalPermanent(); public abstract PermanentView getOriginalPermanent();
} }

View file

@ -1,12 +1,12 @@
package mage.utils; package mage.utils;
import java.util.List;
import mage.ObjectColor; import mage.ObjectColor;
import mage.cards.Card;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.constants.CardType; import mage.constants.CardType;
import mage.view.CardView; import mage.view.CardView;
import java.util.List;
/** /**
* Utility class for {@link CardView} * Utility class for {@link CardView}
* *
@ -21,17 +21,8 @@ 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(CardView card) {
return is(card, CardType.CREATURE);
}
public static boolean isPlaneswalker(CardView card) {
return is(card, CardType.PLANESWALKER);
}
public static boolean isLand(CardView card) {
return is(card, CardType.LAND);
}
public static boolean isCreature(MagePermanent card) { public static boolean isCreature(MagePermanent card) {
return is(card.getOriginal(), CardType.CREATURE); return is(card.getOriginal(), CardType.CREATURE);