Merge pull request #3071 from ingmargoudt/cleanups

Cleanups
This commit is contained in:
LevelX2 2017-04-07 19:41:15 +02:00 committed by GitHub
commit fee7e4a4e6
15 changed files with 129 additions and 173 deletions

View file

@ -159,9 +159,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName()+"TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
gImage.drawString(card.getPower() + '/' + card.getToughness(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
}
@ -173,9 +173,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.nameFontSize));
gSmall.drawString(card.getName()+"TEST2", Config.dimensions.contentXOffset, Config.dimensions.nameYOffset);
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
}
@ -207,9 +207,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
if (card.getColor().hasColor()) {
sb.append('\n').append(card.getColor().toString());
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
sb.append('\n').append(card.getPower()).append('/').append(card.getToughness());
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
sb.append('\n').append(card.getLoyalty());
}
for (String rule : getRules()) {
@ -230,9 +230,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
return "effect";
}
StringBuilder sb = new StringBuilder();
if (card.getCardTypes().contains(CardType.LAND)) {
if (card.isLand()) {
sb.append("land").append(card.getSuperTypes()).append(card.getSubTypes());
} else if (card.getCardTypes() != null && (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER))) {
} else if (card.getCardTypes() != null && (card.isCreature() || card.isPlanesWalker())) {
sb.append("creature");
}
sb.append(card.getColor()).append(card.getRarity()).append(card.getExpansionSetCode());

View file

@ -44,7 +44,6 @@ import mage.client.plugins.impl.Plugins;
import mage.client.util.*;
import mage.client.util.Event;
import mage.client.util.gui.TableSpinnerEditor;
import mage.constants.CardType;
import mage.view.CardView;
import mage.view.CardsView;
import mage.view.SimpleCardView;
@ -383,22 +382,22 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
int artifactCount = 0;
for (CardView card : cards.values()) {
if (card.getCardTypes().contains(CardType.LAND)) {
if (card.isLand()) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
creatureCount++;
}
if (card.getCardTypes().contains(CardType.SORCERY)) {
if (card.isSorcery()) {
sorceryCount++;
}
if (card.getCardTypes().contains(CardType.INSTANT)) {
if (card.isInstant()) {
instantCount++;
}
if (card.getCardTypes().contains(CardType.ENCHANTMENT)) {
if (card.isEnchantment()) {
enchantmentCount++;
}
if (card.getCardTypes().contains(CardType.ARTIFACT)) {
if (card.isArtifact()) {
artifactCount++;
}
}

View file

@ -1,53 +1,6 @@
package mage.client.cards;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import mage.cards.Card;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLayout;
@ -58,15 +11,8 @@ import mage.client.MageFrame;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardViewCardTypeComparator;
import mage.client.util.CardViewColorComparator;
import mage.client.util.CardViewColorIdentityComparator;
import mage.client.util.CardViewCostComparator;
import mage.client.util.CardViewNameComparator;
import mage.client.util.CardViewRarityComparator;
import mage.client.util.*;
import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.Listener;
import mage.constants.CardType;
import mage.constants.SuperType;
import mage.util.RandomUtil;
@ -75,6 +21,18 @@ import mage.view.CardsView;
import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRenderer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Created by StravantUser on 2016-09-20.
*/
@ -512,50 +470,50 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
private final CardTypeCounter creatureCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.CREATURE);
return card.isCreature();
}
};
private final CardTypeCounter landCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.LAND);
return card.isLand();
}
};
private final CardTypeCounter artifactCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ARTIFACT);
return card.isArtifact();
}
};
private final CardTypeCounter enchantmentCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ENCHANTMENT);
return card.isEnchantment();
}
};
private final CardTypeCounter instantCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.INSTANT);
return card.isInstant();
}
};
private final CardTypeCounter sorceryCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.SORCERY);
return card.isSorcery();
}
};
private final CardTypeCounter planeswalkerCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.PLANESWALKER);
return card.isPlanesWalker();
}
};
private final CardTypeCounter tribalCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.TRIBAL);
return card.isTribal();
}
};
@ -1897,7 +1855,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// What row to add it to?
ArrayList<ArrayList<CardView>> targetRow;
if (separateCreatures && !newCard.getCardTypes().contains(CardType.CREATURE)) {
if (separateCreatures && !newCard.isCreature()) {
// Ensure row 2 exists
if (cardGrid.size() < 2) {
cardGrid.add(1, new ArrayList<>());

View file

@ -39,7 +39,6 @@ import mage.cards.MagePermanent;
import mage.cards.Sets;
import mage.client.util.Config;
import mage.client.util.TransformedImageCache;
import mage.constants.CardType;
import mage.view.CounterView;
import mage.view.PermanentView;
@ -110,10 +109,10 @@ public class Permanent extends Card {
if (permanent.getOriginal().getColor().hasColor()) {
sb.append('\n').append(permanent.getOriginal().getColor().toString());
}
if (permanent.getOriginal().getCardTypes().contains(CardType.CREATURE)) {
if (permanent.getOriginal().isCreature()) {
sb.append('\n').append(permanent.getOriginal().getPower()).append('/').append(permanent.getOriginal().getToughness());
}
else if (permanent.getOriginal().getCardTypes().contains(CardType.PLANESWALKER)) {
else if (permanent.getOriginal().isPlanesWalker()) {
sb.append('\n').append(permanent.getOriginal().getLoyalty());
}
for (String rule: getRules()) {

View file

@ -37,7 +37,6 @@ import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.client.util.gui.GuiDisplayUtil;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.view.CardView;
import mage.view.CardsView;
@ -125,22 +124,22 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
addCard(card, bigCard, gameId);
}
if (updateCountsCallback != null) {
if (card.getCardTypes().contains(CardType.LAND)) {
if (card.isLand()) {
landCount++;
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
creatureCount++;
}
if (card.getCardTypes().contains(CardType.INSTANT)) {
if (card.isInstant()) {
instantCount++;
}
if (card.getCardTypes().contains(CardType.SORCERY)) {
if (card.isSorcery()) {
sorceryCount++;
}
if (card.getCardTypes().contains(CardType.ENCHANTMENT)) {
if (card.isEnchantment()) {
enchantmentCount++;
}
if (card.getCardTypes().contains(CardType.ARTIFACT)) {
if (card.isArtifact()) {
artifactCount++;
}
}

View file

@ -33,15 +33,6 @@
*/
package mage.client.game;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.cards.MagePermanent;
import mage.client.cards.BigCard;
import mage.client.cards.Permanent;
@ -51,11 +42,19 @@ import mage.client.util.GUISizeHelper;
import mage.client.util.audio.AudioManager;
import mage.client.util.layout.CardLayoutStrategy;
import mage.client.util.layout.impl.OldCardLayoutStrategy;
import mage.constants.CardType;
import mage.utils.CardUtil;
import mage.view.CounterView;
import mage.view.PermanentView;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
/**
*
* @author BetaSteward_at_googlemail.com
@ -155,7 +154,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
changed = true;
} else {
if (!changed) {
changed = CardUtil.isCreature(oldMagePermanent.getOriginalPermanent()) != CardUtil.isCreature(permanent);
changed = oldMagePermanent.getOriginalPermanent().isCreature() != permanent.isCreature();
if (!changed) {
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
int s2 = oldMagePermanent.getLinks().size();
@ -279,9 +278,9 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
}*/
}
if (permanent.getCardTypes().contains(CardType.ARTIFACT)) {
if (permanent.isArtifact()) {
addedArtifact = true;
} else if (permanent.getCardTypes().contains(CardType.CREATURE)) {
} else if (permanent.isCreature()) {
addedCreature = true;
} else {
addedPermanent = true;
@ -305,7 +304,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
});
t.start();
}
if (((MagePermanent) comp).getOriginal().getCardTypes().contains(CardType.CREATURE)) {
if (((MagePermanent) comp).getOriginal().isCreature()) {
removedCreature = true;
}
}

View file

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

View file

@ -700,9 +700,9 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
if (card.getColor().hasColor()) {
sb.append('\n').append(card.getColor().toString());
}
if (card.getCardTypes().contains(CardType.CREATURE)) {
if (card.isCreature()) {
sb.append('\n').append(card.getPower()).append('/').append(card.getToughness());
} else if (card.getCardTypes().contains(CardType.PLANESWALKER)) {
} else if (card.isPlanesWalker()) {
sb.append('\n').append(card.getLoyalty());
}
if (card.getRules() == null) {

View file

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

View file

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

View file

@ -11,7 +11,6 @@ import mage.cards.FrameStyle;
import mage.client.dialog.PreferencesDialog;
import mage.constants.CardType;
import mage.constants.MageObjectType;
import mage.constants.SpellAbilityType;
import mage.view.CardView;
import mage.view.PermanentView;
import org.apache.log4j.Logger;
@ -21,8 +20,8 @@ import java.awt.*;
import java.awt.font.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.RasterFormatException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.text.AttributedCharacterIterator;
import java.text.AttributedString;
@ -76,10 +75,9 @@ public class ModernCardRenderer extends CardRenderer {
}
private static Font loadFont(String name) {
try {
try(InputStream in = ModernCardRenderer.class.getResourceAsStream("/cardrender/" + name + ".ttf")) {
return Font.createFont(
Font.TRUETYPE_FONT,
ModernCardRenderer.class.getResourceAsStream("/cardrender/" + name + ".ttf"));
Font.TRUETYPE_FONT,in);
} catch (IOException e) {
LOGGER.info("Failed to load font `" + name + "`, couldn't find resource.");
} catch (FontFormatException e) {
@ -427,7 +425,7 @@ public class ModernCardRenderer extends CardRenderer {
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
// If it's a planeswalker, extend the textbox left border by some
if (cardView.getCardTypes().contains(CardType.PLANESWALKER)) {
if (cardView.isPlanesWalker()) {
g.setPaint(borderPaint);
g.fillRect(
totalContentInset, typeLineY + boxHeight,
@ -603,7 +601,7 @@ public class ModernCardRenderer extends CardRenderer {
// Is it a creature?
boolean isVehicle = cardView.getSubTypes().contains("Vehicle");
if (cardView.getCardTypes().contains(CardType.CREATURE) || isVehicle) {
if (cardView.isCreature() || isVehicle) {
int x = cardWidth - borderWidth - partWidth;
// Draw PT box
@ -623,7 +621,7 @@ public class ModernCardRenderer extends CardRenderer {
// Draw text
Color textColor;
if (isVehicle) {
boolean isAnimated = !(cardView instanceof PermanentView) || cardView.getCardTypes().contains(CardType.CREATURE);
boolean isAnimated = !(cardView instanceof PermanentView) || cardView.isCreature();
if (isAnimated) {
textColor = Color.white;
} else {
@ -646,7 +644,7 @@ public class ModernCardRenderer extends CardRenderer {
// Is it a walker? (But don't draw the box if it's a non-permanent view
// of a walker without a starting loyalty (EG: Arlin Kord's flipped side).
if (cardView.getCardTypes().contains(CardType.PLANESWALKER)
if (cardView.isPlanesWalker()
&& (cardView instanceof PermanentView || !cardView.getStartingLoyalty().equals("0"))) {
// Draw the PW loyalty box
int w = partWidth;
@ -772,7 +770,7 @@ public class ModernCardRenderer extends CardRenderer {
}
// Basic mana draw mana symbol in textbox (for basic lands)
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.getCardTypes().contains(CardType.LAND)) {
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.isLand()) {
drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
return;
}

View file

@ -1,21 +1,5 @@
package org.mage.plugins.card;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLayeredPane;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
@ -31,11 +15,7 @@ import net.xeoh.plugins.base.annotations.events.Init;
import net.xeoh.plugins.base.annotations.events.PluginLoaded;
import net.xeoh.plugins.base.annotations.meta.Author;
import org.apache.log4j.Logger;
import org.mage.card.arcane.Animation;
import org.mage.card.arcane.CardPanel;
import org.mage.card.arcane.CardPanelComponentImpl;
import org.mage.card.arcane.CardPanelRenderImpl;
import org.mage.card.arcane.ManaSymbols;
import org.mage.card.arcane.*;
import org.mage.plugins.card.dl.DownloadGui;
import org.mage.plugins.card.dl.DownloadJob;
import org.mage.plugins.card.dl.Downloader;
@ -46,6 +26,15 @@ import org.mage.plugins.card.dl.sources.GathererSymbols;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.info.CardInfoPaneImpl;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.util.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* {@link CardPlugin} implementation.
*

View file

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

View file

@ -1,12 +1,12 @@
package mage.utils;
import java.util.List;
import mage.ObjectColor;
import mage.cards.Card;
import mage.cards.MagePermanent;
import mage.constants.CardType;
import mage.view.CardView;
import java.util.List;
/**
* 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 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) {
return is(card.getOriginal(), CardType.CREATURE);

View file

@ -216,7 +216,6 @@ public class CardView extends SimpleCardView {
}
/**
*
* @param card
* @param game
* @param controlled is the card view created for the card controller - used
@ -245,7 +244,6 @@ public class CardView extends SimpleCardView {
}
/**
*
* @param card
* @param game
* @param controlled is the card view created for the card controller - used
@ -434,7 +432,7 @@ public class CardView extends SimpleCardView {
artRect = ArtRect.SPLIT_FUSED;
} else {
if (spell.getCard() != null) {
SplitCard wholeCard = ((SplitCardHalf)spell.getCard()).getParentCard();
SplitCard wholeCard = ((SplitCardHalf) spell.getCard()).getParentCard();
Abilities<Ability> aftermathHalfAbilities = wholeCard.getRightHalfCard().getAbilities();
if (aftermathHalfAbilities.stream().anyMatch(ability -> ability instanceof AftermathAbility)) {
if (ty == SpellAbilityType.SPLIT_RIGHT) {
@ -957,10 +955,14 @@ public class CardView extends SimpleCardView {
this.canAttack = canAttack;
}
public boolean isCreature(){
public boolean isCreature() {
return cardTypes.contains(CardType.CREATURE);
}
public boolean isPlanesWalker() {
return cardTypes.contains(CardType.PLANESWALKER);
}
public String getColorText() {
if (getColor().getColorCount() == 0) return "Colorless";
else if (getColor().getColorCount() > 1) return "Gold";
@ -996,4 +998,27 @@ public class CardView extends SimpleCardView {
return type.toString();
}
public boolean isLand() {
return cardTypes.contains(CardType.LAND);
}
public boolean isInstant() {
return cardTypes.contains(CardType.INSTANT);
}
public boolean isSorcery() {
return cardTypes.contains(CardType.SORCERY);
}
public boolean isEnchantment() {
return cardTypes.contains(CardType.ENCHANTMENT);
}
public boolean isArtifact() {
return cardTypes.contains(CardType.ARTIFACT);
}
public boolean isTribal() {
return cardTypes.contains(CardType.TRIBAL);
}
}