[ZNR] Improved GUI for modal double faces cards (#7012)

This commit is contained in:
Oleg Agafonov 2020-10-22 09:37:52 +04:00
parent c60bf3ccef
commit 898d271c36
4 changed files with 34 additions and 7 deletions

View file

@ -579,7 +579,10 @@ public class MageActionCallback implements ActionCallback {
break;
case ALTERNATE:
if (cardView.getAlternateName() != null) {
if (cardView instanceof PermanentView && !cardView.isFlipCard() && !cardView.canTransform() && ((PermanentView) cardView).isCopy()) {
if (cardView instanceof PermanentView
&& !cardView.isFlipCard()
&& !cardView.canTransform()
&& ((PermanentView) cardView).isCopy()) {
image = ImageCache.getImageOriginal(((PermanentView) cardView).getOriginal());
} else {
image = ImageCache.getImageOriginalAlternateName(cardView);

View file

@ -819,9 +819,12 @@ public abstract class CardPanel extends MagePermanent implements MouseListener,
this.setTemporary(null);
}
}
// switch card names for render
String temp = this.getGameCard().getAlternateName();
this.getGameCard().setAlternateName(this.getGameCard().getOriginalName());
this.getGameCard().setOriginalName(temp);
updateArtImage();
}

View file

@ -76,7 +76,7 @@ public class CardView extends SimpleCardView {
protected CardView ability;
protected int type;
protected boolean transformable;
protected boolean transformable; // can toggle one card side to another (transformable cards, modal double faces)
protected CardView secondCardFace;
protected boolean transformed;
@ -444,18 +444,29 @@ public class CardView extends SimpleCardView {
this.isToken = false;
}
// transformable, double faces cards
Card secondSideCard = card.getSecondCardFace();
if (secondSideCard != null) {
this.secondCardFace = new CardView(secondSideCard);
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 ModalDoubleFacesCard) {
ModalDoubleFacesCard mdfCard = (ModalDoubleFacesCard) card;
this.secondCardFace = new CardView(mdfCard.getRightHalfCard());
this.alternateName = mdfCard.getRightHalfCard().getName();
this.originalName = card.getName();
}
*/
if (card instanceof Spell) {
this.mageObjectType = MageObjectType.SPELL;
Spell spell = (Spell) card;
@ -887,7 +898,7 @@ public class CardView extends SimpleCardView {
}
/**
* Name of the other side (transform), flipped, or copying card name.
* Name of the other side (transform), flipped, modal double faces card or copying card name.
*
* @return name
*/

View file

@ -6,6 +6,7 @@ import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.cards.CardImpl;
import mage.cards.ModalDoubleFacesCard;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import org.apache.log4j.Logger;
@ -31,7 +32,7 @@ public class MockCard extends CardImpl {
protected ManaCosts<ManaCost> manaCostLeft;
protected ManaCosts<ManaCost> manaCostRight;
protected String adventureSpellName;
protected String modalDoubleFacesSecondSideName;
protected boolean isModalDoubleFacesCard;
public MockCard(CardInfo card) {
super(null, card.getName());
@ -68,7 +69,10 @@ public class MockCard extends CardImpl {
}
if (card.isModalDoubleFacesCard()) {
this.modalDoubleFacesSecondSideName = card.getModalDoubleFacesSecondSideName();
ModalDoubleFacesCard mdfCard = (ModalDoubleFacesCard) card.getCard();
CardInfo mdfSecondSide = new CardInfo(mdfCard.getRightHalfCard());
this.secondSideCard = new MockCard(mdfSecondSide);
this.isModalDoubleFacesCard = true;
}
if (this.isPlaneswalker()) {
@ -128,8 +132,8 @@ public class MockCard extends CardImpl {
if (adventureSpellName != null) {
return getName() + ADVENTURE_NAME_SEPARATOR + adventureSpellName;
} else if (modalDoubleFacesSecondSideName != null) {
return getName() + MODAL_DOUBLE_FACES_NAME_SEPARATOR + modalDoubleFacesSecondSideName;
} else if (isModalDoubleFacesCard) {
return getName() + MODAL_DOUBLE_FACES_NAME_SEPARATOR + this.secondSideCard.getName();
} else {
return getName();
}
@ -156,4 +160,10 @@ public class MockCard extends CardImpl {
private Ability textAbilityFromString(final String text) {
return new MockAbility(text);
}
@Override
public boolean isTransformable() {
// must enable toggle mode in deck editor (switch between card sides);
return super.isTransformable() || this.isModalDoubleFacesCard;
}
}