* 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

@ -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;
}
@ -554,5 +592,9 @@ public class CardView extends SimpleCardView {
public boolean isControlledByOwner() {
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;
}