* Improved handling of enlarged images. Added mode to show other side of flip and transform cards. Added icon for copied cards and possibility to show enlarged original or copied card.

This commit is contained in:
LevelX2 2014-03-06 21:51:51 +01:00
parent 0babf49392
commit 59d907c981
24 changed files with 490 additions and 233 deletions

View file

@ -47,6 +47,7 @@ import java.util.List;
import java.util.UUID;
import static mage.constants.Constants.*;
import mage.constants.EnlargeMode;
/**
* Class for displaying big image of the card
@ -65,6 +66,7 @@ public class BigCard extends JComponent {
protected Thread foilThread;
protected float hue = 0.005f;
protected float dh = 0.005f;
protected EnlargeMode enlargeMode;
public BigCard() {
initComponents();
@ -87,19 +89,20 @@ public class BigCard extends JComponent {
}
public void setCard(UUID cardId, Image image, List<String> strings, boolean foil) {
if (this.cardId == null || !this.cardId.equals(cardId)) {
public void setCard(UUID cardId, EnlargeMode enlargeMode, Image image, List<String> strings) {
if (this.cardId == null || !enlargeMode.equals(this.enlargeMode) || !this.cardId.equals(cardId)) {
if (this.panel != null) {
remove(this.panel);
}
this.cardId = cardId;
this.enlargeMode = enlargeMode;
bigImage = image;
synchronized (this) {
source = null;
hue = 0.000f;
}
drawText(strings);
setFoil(foil);
repaint();
}
}
@ -143,10 +146,6 @@ public class BigCard extends JComponent {
this.scrollPane.setVisible(true);
}
public void setFoil(boolean foil) {
repaint();
}
public void addJXPanel(UUID cardId, JXPanel jxPanel) {
bigImage = null;
synchronized (this) {

View file

@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>

View file

@ -34,36 +34,64 @@
package mage.client.cards;
import mage.constants.CardType;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.JScrollPane;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.text.BadLocationException;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.cards.Sets;
import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
import mage.client.MageFrame;
import static mage.client.constants.Constants.CONTENT_MAX_XOFFSET;
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
import static mage.client.constants.Constants.NAME_FONT_MAX_SIZE;
import static mage.client.constants.Constants.NAME_MAX_YOFFSET;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_LEFT;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
import static mage.client.constants.Constants.SYMBOL_MAX_XOFFSET;
import static mage.client.constants.Constants.SYMBOL_MAX_YOFFSET;
import static mage.client.constants.Constants.TYPE_MAX_YOFFSET;
import mage.client.game.PlayAreaPanel;
import mage.client.util.Config;
import mage.client.util.DefaultActionCallback;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.remote.Session;
import mage.cards.Sets;
import mage.view.AbilityView;
import mage.view.CardView;
import mage.view.CounterView;
import mage.view.PermanentView;
import mage.view.StackAbilityView;
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import static mage.constants.Constants.*;
import mage.view.CounterView;
/**
*
* @author BetaSteward_at_googlemail.com
@ -89,7 +117,14 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
protected BufferedImage small;
protected String backgroundName;
/** Creates new form Card */
/**
* Creates new form Card
*
* @param card
* @param bigCard
* @param dimension
* @param gameId
*/
public Card(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId) {
this.dimension = dimension;
initComponents();
@ -120,10 +155,12 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
return card.getId();
}
@Override
public void update(PermanentView permanent) {
this.update((CardView)permanent);
}
@Override
public void update(CardView card) {
this.card = card;
Graphics2D gImage = image.createGraphics();
@ -141,8 +178,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.setColor(Color.BLACK);
gImage.drawImage(background, 0, 0, this);
if (card.getManaCost().size() > 0)
if (card.getManaCost().size() > 0) {
ImageHelper.drawCosts(card.getManaCost(), gImage, FRAME_MAX_WIDTH - SYMBOL_MAX_XOFFSET, SYMBOL_MAX_YOFFSET, this);
}
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gSmall.setColor(Color.BLACK);
@ -157,8 +195,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.drawString(card.getLoyalty(), POWBOX_TEXT_MAX_LEFT, POWBOX_TEXT_MAX_TOP);
}
if (card.getCardTypes().size() > 0)
if (card.getCardTypes().size() > 0) {
gImage.drawString(cardType, CONTENT_MAX_XOFFSET, TYPE_MAX_YOFFSET);
}
gImage.dispose();
@ -171,8 +210,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.drawString(card.getLoyalty(), Config.dimensions.powBoxTextLeft, Config.dimensions.powBoxTextTop);
}
if (card.getCardTypes().size() > 0)
if (card.getCardTypes().size() > 0) {
gSmall.drawString(cardType, Config.dimensions.contentXOffset, Config.dimensions.typeYOffset);
}
drawText();
gSmall.dispose();
@ -217,7 +257,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
return sb.toString();
}
protected String getBackgroundName() {
private String getBackgroundName() {
if (card instanceof StackAbilityView || card instanceof AbilityView) {
return "effect";
}
@ -237,8 +277,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
StyledDocument doc = text.getStyledDocument();
try {
for (String rule: getRules())
for (String rule: getRules()) {
doc.insertString(doc.getLength(), rule + "\n", doc.getStyle("small"));
}
} catch (BadLocationException e) {}
text.setCaretPosition(0);
@ -246,7 +287,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
protected List<String> getRules() {
if (card.getCounters() != null) {
List<String> rules = new ArrayList<String>(card.getRules());
List<String> rules = new ArrayList<>(card.getRules());
for (CounterView counter: card.getCounters()) {
rules.add(counter.getCount() + " x " + counter.getName());
}
@ -333,7 +374,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void mouseMoved(MouseEvent arg0) {
this.bigCard.showTextComponent();
this.bigCard.setCard(card.getId(), image, getRules(), false);
this.bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, getRules());
}
@Override
@ -353,8 +394,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void mouseEntered(MouseEvent arg0) {
if (!popupShowing) {
if (popup != null)
if (popup != null) {
popup.hide();
}
PopupFactory factory = PopupFactory.getSharedInstance();
popup = factory.getPopup(this, popupText, (int) this.getLocationOnScreen().getX() + Config.dimensions.frameWidth, (int) this.getLocationOnScreen().getY() + 40);
popup.show();
@ -368,9 +410,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
List<UUID> targets = card.getTargets();
if (targets != null) {
for (UUID uuid : targets) {
PlayAreaPanel p = MageFrame.getGame(gameId).getPlayers().get(uuid);
if (p != null) {
Point target = p.getLocationOnScreen();
PlayAreaPanel playAreaPanel = MageFrame.getGame(gameId).getPlayers().get(uuid);
if (playAreaPanel != null) {
Point target = playAreaPanel.getLocationOnScreen();
Point me = this.getLocationOnScreen();
ArrowBuilder.getBuilder().addArrow(gameId, (int)me.getX() + 35, (int)me.getY(), (int)target.getX() + 40, (int)target.getY() - 40, Color.red, ArrowBuilder.Type.TARGET);
} else {
@ -390,7 +432,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void mouseExited(MouseEvent arg0) {
if(getMousePosition(true) != null) return;
if(getMousePosition(true) != null) {
return;
}
if (popup != null) {
popup.hide();
popupShowing = false;
@ -408,8 +452,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void focusLost(FocusEvent arg0) {
if (popup != null)
if (popup != null) {
popup.hide();
}
this.repaint();
}
@ -433,9 +478,10 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override
public void componentHidden(ComponentEvent e) {
if (popup != null)
if (popup != null) {
popup.hide();
}
}
@Override
public List<MagePermanent> getLinks() {return null;}
@ -491,7 +537,9 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
}
@Override
public float getAlpha() {return 0;}
public float getAlpha() {
return 0;
}
@Override
public void toggleTransformed() {

View file

@ -59,6 +59,7 @@ import mage.client.util.ImageHelper;
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;
import org.apache.log4j.Logger;
@ -380,7 +381,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
if (image != null && image instanceof BufferedImage) {
// XXX: scaled to fit width
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
bigCard.setCard(card.getId(), image, new ArrayList<String>(), false);
bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, new ArrayList<String>());
} else {
drawCardText(card);
}

View file

@ -92,6 +92,7 @@ import mage.client.util.Config;
import mage.client.util.GameManager;
import mage.client.util.PhaseManager;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.EnlargeMode;
import mage.constants.PhaseStep;
import static mage.constants.PhaseStep.BEGIN_COMBAT;
import static mage.constants.PhaseStep.COMBAT_DAMAGE;
@ -952,7 +953,17 @@ public final class GamePanel extends javax.swing.JPanel {
@Override
public void actionPerformed(ActionEvent actionEvent) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
((MageActionCallback)callback).enlargeCard();
((MageActionCallback)callback).enlargeCard(EnlargeMode.NORMAL);
}
});
KeyStroke ksAltS = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK);
this.getInputMap(c).put(ksAltS, "ENLARGE_SOURCE");
this.getActionMap().put("ENLARGE_SOURCE", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
((MageActionCallback)callback).enlargeCard(EnlargeMode.ALTERNATE);
}
});
@ -989,16 +1000,19 @@ public final class GamePanel extends javax.swing.JPanel {
}
});
KeyStroke ksAltShiftReleased = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK, true);
this.getInputMap(c).put(ksAltShiftReleased, "ENLARGE_RELEASE");
KeyStroke ksAltEReleased = KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.ALT_MASK, true);
this.getInputMap(c).put(ksAltEReleased, "ENLARGE_RELEASE");
KeyStroke ksAltSReleased = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.ALT_MASK, true);
this.getInputMap(c).put(ksAltSReleased, "ENLARGE_RELEASE");
this.getActionMap().put("ENLARGE_RELEASE", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
((MageActionCallback)callback).hideCard();
((MageActionCallback)callback).hideEnlargedCard();
}
});
btnSwitchHands.setText("Switch Hands");
btnSwitchHands.addMouseListener(new MouseAdapter() {
@Override

View file

@ -34,13 +34,16 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.GuiDisplayUtil;
import mage.components.CardInfoPane;
import mage.constants.EnlargeMode;
import mage.remote.Session;
import mage.utils.ThreadUtils;
import mage.view.CardView;
import mage.view.PermanentView;
import mage.view.PlayerView;
import mage.view.SimpleCardsView;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.JXPanel;
import org.mage.plugins.card.images.ImageCache;
public class MageActionCallback implements ActionCallback {
@ -54,13 +57,16 @@ public class MageActionCallback implements ActionCallback {
private CardView popupCard;
private TransferData popupData;
private JComponent cardInfoPane;
private volatile boolean state = false;
private boolean enlarged = false;
private volatile boolean popupTextWindowOpen = false;
private volatile boolean enlargedImageWindowOpen = false;
// shows the alternative card the normal card or the alternative card (copy source, other flip side, other transformed side)
private volatile EnlargeMode enlargeMode;
private static final ScheduledExecutorService timeoutExecutor = Executors.newScheduledThreadPool(1);
private ScheduledFuture<?> hideTimeout;
public MageActionCallback() {
enlargeMode = EnlargeMode.NORMAL;
}
public void setCardPreviewComponent(BigCard bigCard) {
@ -227,7 +233,7 @@ public class MageActionCallback implements ActionCallback {
public void run() {
ThreadUtils.sleep(300);
if (popupCard == null || !popupCard.equals(data.card) || session == null || !state || enlarged) {
if (popupCard == null || !popupCard.equals(data.card) || session == null || !popupTextWindowOpen || enlargedImageWindowOpen) {
return;
}
@ -248,7 +254,7 @@ public class MageActionCallback implements ActionCallback {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (!state || enlarged) {
if (!popupTextWindowOpen || enlargedImageWindowOpen) {
return;
}
popupContainer.setVisible(true);
@ -265,7 +271,7 @@ public class MageActionCallback implements ActionCallback {
}
@Override
public void mouseMoved(MouseEvent e, TransferData data) {
public void mouseMoved(MouseEvent e, TransferData transferData) {
if (!Plugins.getInstance().isCardPluginLoaded()) {
return;
}
@ -273,26 +279,32 @@ public class MageActionCallback implements ActionCallback {
return;
}
MageCard card = (MageCard) data.component;
if (!state || card.getOriginal().getId() != bigCard.getCardId()) {
MageCard mageCard = (MageCard) transferData.component;
if (!popupTextWindowOpen || mageCard.getOriginal().getId() != bigCard.getCardId()) {
if (bigCard.getWidth() > 0) {
synchronized (MageActionCallback.class) {
if (!state || card.getOriginal().getId() != bigCard.getCardId()) {
if (!state) {
if (!popupTextWindowOpen || mageCard.getOriginal().getId() != bigCard.getCardId()) {
if (!popupTextWindowOpen) {
bigCard.resetCardId();
}
state = true;
Image image = card.getImage();
displayCardInfo(card, image, bigCard);
popupTextWindowOpen = true;
Image image = mageCard.getImage();
displayCardInfo(mageCard, image, bigCard);
}
}
} else {
state = true;
popupTextWindowOpen = true;
}
if (enlargedImageWindowOpen) {
displayEnlargedCard(mageCard.getOriginal(), transferData);
}
displayCard(card.getOriginal(), data);
}
}
/**
* Hides the text popup window
*
*/
@Override
public void hidePopup() {
this.popupCard = null;
@ -306,6 +318,7 @@ public class MageActionCallback implements ActionCallback {
if (session == null) {
return;
}
// set enlarged card display to visible = false
Component popupContainer = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
popupContainer.setVisible(false);
} catch (Exception e2) {
@ -325,7 +338,7 @@ public class MageActionCallback implements ActionCallback {
public void hideAll(UUID gameId) {
hidePopup();
startHideTimeout();
this.state = false;
this.popupTextWindowOpen = false;
if (gameId != null) {
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.TARGET);
ArrowBuilder.getBuilder().removeArrowsByType(gameId, ArrowBuilder.Type.PAIRED);
@ -334,26 +347,49 @@ public class MageActionCallback implements ActionCallback {
}
}
public void enlargeCard() {
if (!enlarged) {
enlarged = true;
CardView card = null;
if (popupData != null) {
card = popupData.card;
@Override
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
if (enlargedImageWindowOpen) {
hideEnlargedCard();
return;
}
if (this.state) {
int notches = e.getWheelRotation();
if (notches < 0) {
// move up - show normal image
enlargeCard(EnlargeMode.NORMAL);
} else {
// move down - show alternate image
enlargeCard(EnlargeMode.ALTERNATE);
}
}
/**
* Show the big card image on mouse position while hoovering over a card
*
* @param showAlternative defines if the original image (if it's a copied card) or the opposite side of a transformable card will be shown
*/
public void enlargeCard(EnlargeMode showAlternative) {
if (!enlargedImageWindowOpen) {
this.enlargeMode = showAlternative;
CardView cardView = null;
if (popupData != null) {
cardView = popupData.card;
}
if (this.popupTextWindowOpen) {
hidePopup();
}
if (card != null) {
displayCard(card, popupData);
if (cardView != null) {
enlargedImageWindowOpen = true;
displayEnlargedCard(cardView, popupData);
}
}
}
public void hideCard() {
if (enlarged) {
enlarged = false;
public void hideEnlargedCard() {
if (enlargedImageWindowOpen) {
enlargedImageWindowOpen = false;
try {
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
cardPreviewContainer.setVisible(false);
@ -363,52 +399,59 @@ public class MageActionCallback implements ActionCallback {
}
}
@Override
public void mouseWheelMoved(MouseWheelEvent e, TransferData data) {
int notches = e.getWheelRotation();
if (notches < 0) {
enlargeCard();
} else {
hideCard();
}
}
private void displayCard(final CardView card, final TransferData data) {
if (!enlarged) {
return;
}
private void displayEnlargedCard(final CardView cardView, final TransferData transferData) {
ThreadUtils.threadPool2.submit(new Runnable() {
@Override
public void run() {
if (card == null) {
if (cardView == null) {
return;
}
try {
if (!enlarged) {
if (!enlargedImageWindowOpen) {
return;
}
Component parentComponent = SwingUtilities.getRoot(data.component);
Component parentComponent = SwingUtilities.getRoot(transferData.component);
Point parentPoint = parentComponent.getLocationOnScreen();
final Component popupContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
Component cardPreview = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_PANE);
if (cardPreview != null) {
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreview, parentComponent);
Component cardPreviewPane = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_PANE);
if (cardPreviewPane != null) {
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
location.translate(-parentPoint.x, -parentPoint.y);
popupContainer.setLocation(location);
popupContainer.setVisible(true);
MageCard card = (MageCard) data.component;
Image image = card.getImage();
BigCard bigCard = (BigCard)cardPreview;
displayCardInfo(card, image, bigCard);
MageCard mageCard = (MageCard) transferData.component;
Image image = null;
switch (enlargeMode) {
case COPY:
if (cardView instanceof PermanentView) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
}
break;
case ALTERNATE:
if (cardView.getAlternateName() != null) {
if (cardView instanceof PermanentView && !cardView.isFlipCard() && !cardView.canTransform() && ((PermanentView) cardView).isCopy()) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
} else {
Logger.getLogger(MageActionCallback.class).warn("No Card preview Pane in Mage Frame defined. Card: " + card.getName());
image = ImageCache.getImageOriginalAlternateName(cardView);
}
}
break;
}
if (image == null) {
image = mageCard.getImage();
}
// shows the card in the popup Container
BigCard bigCard = (BigCard)cardPreviewPane;
displayCardInfo(mageCard, image, bigCard);
} else {
logger.warn("No Card preview Pane in Mage Frame defined. Card: " + cardView.getName());
}
} catch (Exception e) {
@ -418,21 +461,22 @@ public class MageActionCallback implements ActionCallback {
});
}
private void displayCardInfo(MageCard card, Image image, BigCard bigCard) {
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) {
if (image != null && image instanceof BufferedImage) {
// XXX: scaled to fit width
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules(), false);
if (card.getOriginal().isAbility()) {
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules());
// if it's an ability, show only the ability text as overlay
if (mageCard.getOriginal().isAbility()) {
bigCard.showTextComponent();
} else {
bigCard.hideTextComponent();
}
} else {
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
JXPanel panel = GuiDisplayUtil.getDescription(mageCard.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
panel.setVisible(true);
bigCard.hideTextComponent();
bigCard.addJXPanel(card.getOriginal().getId(), panel);
bigCard.addJXPanel(mageCard.getOriginal().getId(), panel);
}
}
@ -441,7 +485,7 @@ public class MageActionCallback implements ActionCallback {
hideTimeout = timeoutExecutor.schedule(new Runnable() {
@Override
public void run() {
hideCard();
hideEnlargedCard();
}
}, 700, TimeUnit.MILLISECONDS);
}

View file

@ -379,7 +379,8 @@ public class CallbackClientImpl implements CallbackClient {
switch (usedPanel.getChatType()) {
case GAME:
usedPanel.receiveMessage("", new StringBuilder("You may use hot keys to play faster:")
.append("\nTurn Mousewheel - Show big image of card your mousepointer hovers over")
.append("\nTurn mousewheel up (ALT-e) - enlarge image of card the mousepointer hovers over")
.append("\nTurn mousewheel down (ALT-s) - enlarge original/alternate image of card the mousepointer hovers over")
.append("\nF2 - Confirm \"Ok\", \"Yes\" or \"Done\" button")
.append("\nF4 - Skip current turn but stop on declare attackers/blockers and something on the stack")
.append("\nF9 - Skip everything until your next turn")

View file

@ -24,15 +24,17 @@ import java.util.UUID;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import mage.cards.MagePermanent;
import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins;
import mage.client.util.audio.AudioManager;
import mage.components.ImagePanel;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
import mage.utils.CardUtil;
import mage.view.AbilityView;
import mage.view.CardView;
@ -76,7 +78,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
// for two faced cards
public CardView temporary;
private List<MagePermanent> links = new ArrayList<MagePermanent>();
private List<MagePermanent> links = new ArrayList<>();
public double tappedAngle = 0;
public double flippedAngle = 0;
@ -84,6 +86,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
public ImagePanel overlayPanel;
public JPanel buttonPanel;
public JPanel iconPanel;
public JPanel copyIconPanel;
private GlowText titleText;
private GlowText ptText;
@ -111,8 +114,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private boolean transformed;
private boolean animationInProgress = false;
private JButton dayNightButton;
private JButton tokenButton;
private JButton showCopySourceButton;
private boolean displayTitleAnyway;
@ -140,7 +145,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
dayNightButton.setLocation(2, 2);
dayNightButton.setSize(25, 25);
buttonPanel.setVisible(this.gameCard.canTransform());
buttonPanel.setVisible(true);
BufferedImage day = ImageManagerImpl.getInstance().getDayImage();
dayNightButton.setIcon(new ImageIcon(day));
@ -154,9 +159,6 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
// if card is tapped, no visual transforming is possible (implementation limitation)
// if card is permanent, it will be rotated by Mage, so manual rotate should be possible
if (animationInProgress || isTapped() || isPermanent) {
if (isPermanent) {
JOptionPane.showMessageDialog(null, "You can't transform cards on battlefield.");
}
return;
}
Animation.transformCard(CardPanel.this, CardPanel.this, true);
@ -183,6 +185,32 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
iconPanel.add(tokenButton);
}
// icon to inform about permanent is copying something
if (this.gameCard instanceof PermanentView) {
copyIconPanel = new JPanel();
copyIconPanel.setLayout(null);
copyIconPanel.setOpaque(false);
add(copyIconPanel);
showCopySourceButton = new JButton("");
showCopySourceButton.setLocation(2, 2);
showCopySourceButton.setSize(25, 25);
showCopySourceButton.setToolTipText("This permanent is copying a target. To see original image, push this button or turn mouse wheel down while hoovering with the mouse pointer over the permanent.");
copyIconPanel.setVisible(((PermanentView) this.gameCard).isCopy());
showCopySourceButton.setIcon(new ImageIcon(ImageManagerImpl.getInstance().getCopyInformIconImage()));
copyIconPanel.add(showCopySourceButton);
showCopySourceButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ActionCallback callback = Plugins.getInstance().getActionCallback();
((MageActionCallback) callback).enlargeCard(EnlargeMode.COPY);
}
});
}
setBackground(Color.black);
setOpaque(false);
@ -462,6 +490,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
iconPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
iconPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
}
if (copyIconPanel != null) {
copyIconPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize);
copyIconPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2);
}
int fontHeight = Math.round(cardHeight * (27f / 680));
boolean showText = (!isAnimationPanel && fontHeight < 12);
titleText.setVisible(showText);
@ -634,7 +666,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void update(CardView card) {
if (isPermanent) {
if (isPermanent && (card instanceof PermanentView)) {
boolean needsTapping = isTapped() != ((PermanentView) card).isTapped();
boolean needsFlipping = isFlipped() != ((PermanentView) card).isFlipped();
if (needsTapping || needsFlipping) {
@ -648,6 +680,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
Animation.transformCard(this, this, card.isTransformed());
}
}
if (card.canTransform()) {
dayNightButton.setVisible(!isPermanent);
}
if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) {
ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")");
} else if (CardUtil.isCreature(card)) {
@ -658,6 +694,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
ptText.setText("");
}
setText(card);
boolean updateImage = !gameCard.getName().equals(card.getName()); // update after e.g. turning a night/day card
this.gameCard = card;
String cardType = getType(card);
@ -668,7 +706,18 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
} else {
overlayPanel.setVisible(false);
}
if (updateImage) {
updateImage();
if (card.canTransform()) {
BufferedImage transformIcon;
if (card.isTransformed()) {
transformIcon = ImageManagerImpl.getInstance().getNightImage();
} else {
transformIcon = ImageManagerImpl.getInstance().getDayImage();
}
dayNightButton.setIcon(new ImageIcon(transformIcon));
}
}
repaint();
}
@ -859,8 +908,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void update(PermanentView card) {
update((CardView) card);
this.hasSickness = card.hasSummoningSickness();
this.copyIconPanel.setVisible(card.isCopy());
update((CardView) card);
}
@Override
@ -883,7 +933,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
this.transformed = !this.transformed;
if (transformed) {
BufferedImage night = ImageManagerImpl.getInstance().getNightImage();
if (dayNightButton != null) { // if transformbable card is copied, button can be null
dayNightButton.setIcon(new ImageIcon(night));
}
if (this.gameCard.getSecondCardFace() == null) {
log.error("no second side for card to transform!");
return;
@ -892,17 +944,21 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
this.temporary = this.gameCard;
update(this.gameCard.getSecondCardFace());
}
updateImage();
} else {
BufferedImage day = ImageManagerImpl.getInstance().getDayImage();
if (dayNightButton != null) { // if transformbable card is copied, button can be null
dayNightButton.setIcon(new ImageIcon(day));
}
if (!isPermanent) { // use only for custom transformation (when pressing day-night button)
this.gameCard = this.temporary;
this.temporary = null;
update(this.gameCard);
}
updateImage();
}
String temp = this.gameCard.getAlternateName();
this.gameCard.setAlternateName(this.gameCard.getOriginalName());
this.gameCard.setOriginalName(temp);
updateImage();
}
@Override

View file

@ -62,7 +62,7 @@ public class CardPluginImpl implements CardPlugin {
private int cardWidth, cardHeight;
private int extraCardSpacingX, cardSpacingX, cardSpacingY;
private int stackSpacingX, stackSpacingY;
private List<Row> rows = new ArrayList<Row>();
private List<Row> rows = new ArrayList<>();
@Init
public void init() {
@ -183,7 +183,7 @@ public class CardPluginImpl implements CardPlugin {
int afterCreaturesIndex = rows.size();
wrap(lands, rows, afterCreaturesIndex);
// Store the current rows and others.
List<Row> storedRows = new ArrayList<Row>(rows.size());
List<Row> storedRows = new ArrayList<>(rows.size());
for (Row row : rows) {
storedRows.add((Row) row.clone());
}

View file

@ -7,21 +7,21 @@ import com.mortennobel.imagescaling.ResampleOp;
import de.schlichtherle.truezip.file.TFile;
import de.schlichtherle.truezip.file.TFileInputStream;
import de.schlichtherle.truezip.file.TFileOutputStream;
import mage.client.dialog.PreferencesDialog;
import mage.view.CardView;
import org.apache.log4j.Logger;
import org.mage.plugins.card.constants.Constants;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.utils.CardImageUtils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import mage.client.dialog.PreferencesDialog;
import mage.view.CardView;
import org.apache.log4j.Logger;
import org.mage.plugins.card.constants.Constants;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.utils.CardImageUtils;
/**
* This class stores ALL card images in a cache with soft values. this means
@ -167,10 +167,20 @@ public class ImageCache {
if (card.getUsesVariousArt()) {
key += "#usesVariousArt";
}
// log.debug("#key: " + key);
// log.warn("#key: " + key);
return getImage(key);
}
public static BufferedImage getImageOriginalAlternateName(CardView card) {
String key = getKeyAlternateName(card, card.getAlternateName());
if (card.getUsesVariousArt()) {
key += "#usesVariousArt";
}
// log.warn("#key: " + key);
return getImage(key);
}
/**
* Returns the Image corresponding to the key
*/
@ -205,6 +215,18 @@ public class ImageCache {
return sb.toString();
}
/**
* Returns the map key for the flip image of a card, without any suffixes for the image size.
*/
private static String getKeyAlternateName(CardView card, String alternateName) {
StringBuilder sb = new StringBuilder(alternateName).append("#");
sb.append(card.getExpansionSetCode()).append("#");
sb.append(card.getType()).append("#");
sb.append(card.getCardNumber()).append("#");
sb.append(card.getTokenSetCode() == null ? "":card.getTokenSetCode());
return sb.toString();
}
/**
* Load image from file
*
@ -251,6 +273,7 @@ public class ImageCache {
/**
* Returns an image scaled to the size given
* @param original
* @return
*/
public static BufferedImage getNormalSizeImage(BufferedImage original) {
@ -289,6 +312,9 @@ public class ImageCache {
/**
* Returns an image scaled to the size appropriate for the card picture
* panel
* @param original
* @param sizeNeed
* @return
*/
public static BufferedImage getResizedImage(BufferedImage original, Rectangle sizeNeed) {
ResampleOp resampleOp = new ResampleOp(sizeNeed.width, sizeNeed.height);
@ -298,6 +324,10 @@ public class ImageCache {
/**
* Returns the image appropriate to display the card in the picture panel
* @param card
* @param width
* @param height
* @return
*/
public static BufferedImage getImage(CardView card, int width, int height) {
if (Constants.THUMBNAIL_SIZE_FULL.width + 10 > width) {

View file

@ -13,6 +13,7 @@ public interface ImageManager {
Image getNightImage();
Image getTokenIconImage();
Image getCopyInformIconImage();
Image getDlgAcceptButtonImage();
Image getDlgActiveAcceptButtonImage();

View file

@ -106,6 +106,15 @@ public class ImageManagerImpl implements ImageManager {
return imageTokenIcon;
}
@Override
public BufferedImage getCopyInformIconImage() {
if (imageCopyIcon == null) {
Image image = getImageFromResourceTransparent("/card/copy.png", Color.WHITE, new Rectangle(20, 20));
imageCopyIcon = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
}
return imageCopyIcon;
}
@Override
public Image getDlgCancelButtonImage() {
if (imageDlgCancelButton == null) {
@ -226,6 +235,7 @@ public class ImageManagerImpl implements ImageManager {
private static BufferedImage imageNight;
private static BufferedImage imageTokenIcon;
private static BufferedImage imageCopyIcon;
private static BufferedImage imageDlgAcceptButton;
private static BufferedImage imageDlgActiveAcceptButton;

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

View file

@ -1,11 +1,10 @@
package mage.cards;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
import java.awt.Image;
import java.util.UUID;
import javax.swing.JPanel;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
public abstract class MageCard extends JPanel {
private static final long serialVersionUID = 6089945326434301879L;

View file

@ -87,6 +87,11 @@ public class CardView extends SimpleCardView {
protected CardView secondCardFace;
protected boolean transformed;
protected boolean flipCard;
protected String alternateName;
protected String originalName;
protected boolean isSplitCard;
protected String leftSplitName;
protected ManaCosts leftSplitCosts;
@ -167,7 +172,7 @@ public class CardView extends SimpleCardView {
this.superTypes = card.getSupertype();
this.color = card.getColor();
this.canTransform = card.canTransform();
this.flipCard = card.isFlipCard();
if (card instanceof PermanentToken) {
this.isToken = true;
@ -190,13 +195,20 @@ public class CardView extends SimpleCardView {
this.isToken = false;
}
if (card.getCounters() != null && !card.getCounters().isEmpty()) {
counters = new ArrayList<CounterView>();
counters = new ArrayList<>();
for (Counter counter: card.getCounters().values()) {
counters.add(new CounterView(counter));
}
}
if (card.getSecondCardFace() != null) {
this.secondCardFace = new CardView(card.getSecondCardFace());
this.alternateName = secondCardFace.getName();
this.originalName = card.getName();
}
this.flipCard = card.isFlipCard();
if (card.isFlipCard() && card.getFlipCardName() != null) {
this.alternateName = card.getFlipCardName();
this.originalName = card.getName();
}
if (card instanceof Spell) {
@ -258,7 +270,7 @@ public class CardView extends SimpleCardView {
if (this.rarity == null && object instanceof StackAbility) {
StackAbility stackAbility = (StackAbility)object;
this.rarity = Rarity.NA;
this.rules = new ArrayList<String>();
this.rules = new ArrayList<>();
this.rules.add(stackAbility.getRule());
if (stackAbility.getZone().equals(Zone.COMMAND)) {
this.expansionSetCode = stackAbility.getExpansionSetCode();
@ -298,15 +310,15 @@ public class CardView extends SimpleCardView {
private void fillEmpty() {
this.name = "Face Down";
this.rules = new ArrayList<String>();
this.rules = new ArrayList<>();
this.power = "";
this.toughness = "";
this.loyalty = "";
this.cardTypes = new ArrayList<CardType>();
this.subTypes = new ArrayList<String>();
this.superTypes = new ArrayList<String>();
this.cardTypes = new ArrayList<>();
this.subTypes = new ArrayList<>();
this.superTypes = new ArrayList<>();
this.color = new ObjectColor();
this.manaCost = new ArrayList<String>();
this.manaCost = new ArrayList<>();
this.convertedManaCost = 0;
this.rarity = Rarity.COMMON;
this.expansionSetCode = "";
@ -338,7 +350,7 @@ public class CardView extends SimpleCardView {
if (target.isChosen()) {
for (UUID targetUUID : target.getTargets()) {
if (this.targets == null) {
this.targets = new ArrayList<UUID>();
this.targets = new ArrayList<>();
}
this.targets.add(targetUUID);
}
@ -483,6 +495,32 @@ public class CardView extends SimpleCardView {
return this.isSplitCard;
}
/**
* Name of the other side (transform), flipped, or copying card name.
*
* @return name
*/
public String getAlternateName() {
return alternateName;
}
/**
* Stores the name of the original name, to provide it for a flipped or transformed or copying card
*
* @return
*/
public String getOriginalName() {
return originalName;
}
public void setAlternateName(String alternateName) {
this.alternateName = alternateName;
}
public void setOriginalName(String originalName) {
this.originalName = originalName;
}
public String getLeftSplitName() {
return leftSplitName;
}
@ -555,4 +593,8 @@ public class CardView extends SimpleCardView {
return controlledByOwner;
}
public boolean isFlipCard() {
return flipCard;
}
}

View file

@ -43,13 +43,14 @@ public class PermanentView extends CardView {
private static final long serialVersionUID = 1L;
private boolean tapped;
private boolean flipped;
private boolean phasedIn;
private boolean faceUp;
private boolean summoningSickness;
private int damage;
private final boolean flipped;
private final boolean phasedIn;
private final boolean faceUp;
private final boolean summoningSickness;
private final int damage;
private List<UUID> attachments;
private CardView original;
private final CardView original;
private final boolean copy;
public PermanentView(Permanent permanent, Card card) {
super(permanent);
@ -61,7 +62,7 @@ public class PermanentView extends CardView {
this.summoningSickness = permanent.hasSummoningSickness();
this.damage = permanent.getDamage();
if (permanent.getAttachments().size() > 0) {
attachments = new ArrayList<UUID>();
attachments = new ArrayList<>();
attachments.addAll(permanent.getAttachments());
}
if (isToken()) {
@ -77,6 +78,19 @@ public class PermanentView extends CardView {
}
}
this.transformed = permanent.isTransformed();
this.copy = permanent.isCopy();
// for fipped, transformed or copied cards, switch the names
if (!original.getName().equals(this.getName())) {
if (permanent.isCopy() && permanent.isFlipCard()) {
this.alternateName = permanent.getFlipCardName();
this.originalName = this.getName();
} else {
this.alternateName = original.getName();
this.originalName = this.getName();
}
}
}
public boolean isTapped() {
@ -91,6 +105,10 @@ public class PermanentView extends CardView {
return flipped;
}
public boolean isCopy() {
return copy;
}
public boolean isPhasedIn() {
return phasedIn;
}

View file

@ -28,7 +28,9 @@
package mage;
import mage.constants.CardType;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl;
import mage.abilities.Ability;
@ -36,12 +38,9 @@ import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.keyword.ChangelingAbility;
import mage.constants.CardType;
import mage.game.Game;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements MageObject {
protected UUID objectId;
@ -49,9 +48,9 @@ public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements Mag
protected String name;
protected ManaCosts<ManaCost> manaCost;
protected ObjectColor color;
protected List<CardType> cardType = new ArrayList<CardType>();
protected List<String> subtype = new ArrayList<String>();
protected List<String> supertype = new ArrayList<String>();
protected List<CardType> cardType = new ArrayList<>();
protected List<String> subtype = new ArrayList<>();
protected List<String> supertype = new ArrayList<>();
protected Abilities<Ability> abilities;
protected String text;
protected MageInt power;
@ -70,8 +69,8 @@ public abstract class MageObjectImpl<T extends MageObjectImpl<T>> implements Mag
power = new MageInt(0);
toughness = new MageInt(0);
color = new ObjectColor();
manaCost = new ManaCostsImpl<ManaCost>("");
abilities = new AbilitiesImpl<Ability>();
manaCost = new ManaCostsImpl<>("");
abilities = new AbilitiesImpl<>();
}
public MageObjectImpl(final MageObjectImpl<T> object) {

View file

@ -36,7 +36,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
import mage.cards.Card;
import mage.game.permanent.PermanentCard;
/**
@ -73,7 +72,6 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
if (permanent == null) {
return false;
}
permanent.setName(target.getName());
permanent.getColor().setColor(target.getColor());
permanent.getManaCost().clear();
@ -97,9 +95,13 @@ public class CopyEffect extends ContinuousEffectImpl<CopyEffect> {
permanent.getPower().setValue(target.getPower().getValue());
permanent.getToughness().setValue(target.getToughness().getValue());
if (target instanceof Permanent) {
permanent.setTransformed(((Permanent)target).isTransformed());
permanent.setSecondCardFace(((Permanent) target).getSecondCardFace());
Permanent targetPermanent = (Permanent) target;
permanent.setTransformed(targetPermanent.isTransformed());
permanent.setSecondCardFace(targetPermanent.getSecondCardFace());
permanent.setFlipCard(targetPermanent.isFlipCard());
permanent.setFlipCardName(targetPermanent.getFlipCardName());
}
// to get the image of the copied permanent copy number und expansionCode
if (target instanceof PermanentCard) {
permanent.setCardNumber(((PermanentCard) target).getCard().getCardNumber());

View file

@ -2,7 +2,11 @@ package mage.abilities.effects.common;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;

View file

@ -64,6 +64,8 @@ public interface Card extends MageObject {
boolean isFaceDown();
boolean isFlipCard();
String getFlipCardName();
void setFlipCard(boolean flipCard);
void setFlipCardName(String flipCardName);
boolean isSplitCard();
boolean canTransform();

View file

@ -55,7 +55,10 @@ import mage.constants.TimingRule;
import static mage.constants.Zone.EXILED;
import mage.game.command.Commander;
/**
*
* @param <T>
*/
public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T> implements Card {
private static final long serialVersionUID = 1L;
@ -63,7 +66,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
protected UUID ownerId;
protected int cardNumber;
protected List<Watcher> watchers = new ArrayList<Watcher>();
protected List<Watcher> watchers = new ArrayList<>();
protected String expansionSetCode;
protected String tokenSetCode;
protected Rarity rarity;
@ -127,7 +130,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
expansionSetCode = card.expansionSetCode;
rarity = card.rarity;
for (Watcher watcher: (List<Watcher>)card.watchers) {
this.watchers.add(watcher.copy());
watchers.add(watcher.copy());
}
faceDown = card.faceDown;
@ -138,14 +141,14 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
}
zoneChangeCounter = card.zoneChangeCounter;
if (card.info != null) {
info = new HashMap<String, String>();
info = new HashMap<>();
info.putAll(card.info);
}
this.flipCard = card.flipCard;
this.flipCardName = card.flipCardName;
this.splitCard = card.splitCard;
this.usesVariousArt = card.usesVariousArt;
this.counters = card.counters.copy();
flipCard = card.flipCard;
flipCardName = card.flipCardName;
splitCard = card.splitCard;
usesVariousArt = card.usesVariousArt;
counters = card.counters.copy();
}
@Override
@ -210,7 +213,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
System.out.println("Exception in rules generation for card: " + this.getName());
e.printStackTrace();
}
ArrayList<String> rules = new ArrayList<String>();
ArrayList<String> rules = new ArrayList<>();
rules.add("Exception occured in rules generation");
return rules;
}
@ -562,15 +565,27 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
return flipCard;
}
@Override
public String getFlipCardName() {
return flipCardName;
}
@Override
public void setFlipCard(boolean flipCard) {
this.flipCard = flipCard;
}
@Override
public void setFlipCardName(String flipCardName) {
this.flipCardName = flipCardName;
}
@Override
public boolean isSplitCard() {
return splitCard;
}
@Override
public String getFlipCardName() {
return flipCardName;
}
@Override
public int getZoneChangeCounter() {

View file

@ -0,0 +1,11 @@
package mage.constants;
/**
* Controlls the display handling of the enlarged image of the card / permanent
*
* @author LevelX2
*/
public enum EnlargeMode {
NORMAL, ALTERNATE, COPY
}

View file

@ -78,11 +78,9 @@ public class PermanentCard extends PermanentImpl<PermanentCard> {
@Override
public void reset(Game game) {
// when the permanent is reset copy all original values from the card
// when the permanent is reset, copy all original values from the card
// must copy card each reset so that the original values don't get modified
// game.getState().getContinuousEffects().removeGainedEffectsForSource(objectId);
// game.getState().resetTriggersForSourceId(this.getId());
copyFromCard(card, game);
copyFromCard(card);
super.reset(game);
}
@ -98,16 +96,6 @@ public class PermanentCard extends PermanentImpl<PermanentCard> {
this.manaCost = card.getManaCost().copy();
this.power = card.getPower().copy();
this.toughness = card.getToughness().copy();
/*if (card instanceof LevelerCard) {
LevelAbility level = ((LevelerCard) card).getLevel(this.getCounters().getCount(CounterType.LEVEL));
if (level != null) {
this.power.setValue(level.getPower());
this.toughness.setValue(level.getToughness());
for (Ability ability : level.getAbilities()) {
this.addAbility(ability);
}
}
}*/
if (card instanceof PermanentCard) {
this.maxLevelCounters = ((PermanentCard) card).maxLevelCounters;
}
@ -125,46 +113,8 @@ public class PermanentCard extends PermanentImpl<PermanentCard> {
secondSideCard = card.getSecondCardFace();
nightCard = card.isNightCard();
}
}
protected void copyFromCard(Card card, Game game) {
this.name = card.getName();
// this.removeAllAbilities(objectId, game);
this.abilities.clear();
this.abilities.addAll(card.getAbilities());
this.abilities.setControllerId(this.controllerId);
this.cardType.clear();
this.cardType.addAll(card.getCardType());
this.color = card.getColor().copy();
this.manaCost = card.getManaCost().copy();
this.power = card.getPower().copy();
this.toughness = card.getToughness().copy();
/*if (card instanceof LevelerCard) {
LevelAbility level = ((LevelerCard) card).getLevel(this.getCounters().getCount(CounterType.LEVEL));
if (level != null) {
this.power.setValue(level.getPower());
this.toughness.setValue(level.getToughness());
for (Ability ability : level.getAbilities()) {
this.addAbility(ability, game);
}
}
}*/
if (card instanceof PermanentCard) {
this.maxLevelCounters = ((PermanentCard) card).maxLevelCounters;
}
this.subtype.clear();
this.subtype.addAll(card.getSubtype());
this.supertype.clear();
this.supertype.addAll(card.getSupertype());
this.expansionSetCode = card.getExpansionSetCode();
this.rarity = card.getRarity();
this.cardNumber = card.getCardNumber();
canTransform = card.canTransform();
if (canTransform) {
secondSideCard = card.getSecondCardFace();
nightCard = card.isNightCard();
}
this.flipCard = card.isFlipCard();
this.flipCardName = card.getFlipCardName();
}
public Card getCard() {

View file

@ -626,6 +626,17 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
return false;
}
@Override
public void setFlipCard(boolean flipCard) {
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void setFlipCardName(String flipCardName) {
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public Spell copy() {
return new Spell(this);