GUI: fixed wrong card sides, data and errors for transform and double side cards;

This commit is contained in:
Oleg Agafonov 2021-11-09 10:16:39 +04:00
parent 3515647c7b
commit 3284cb5b24
10 changed files with 72 additions and 69 deletions

View file

@ -6,6 +6,7 @@ import mage.abilities.icon.CardIconImpl;
import mage.abilities.icon.CardIconOrder;
import mage.abilities.icon.CardIconPosition;
import mage.abilities.icon.CardIconType;
import mage.abilities.keyword.TransformAbility;
import mage.cards.*;
import mage.cards.decks.Deck;
import mage.cards.repository.CardInfo;
@ -109,7 +110,7 @@ public class TestCardRenderDialog extends MageDialog {
this.removeDialog();
}
private PermanentView createPermanentCard(Game game, UUID controllerId, String code, String cardNumber, int power, int toughness, int damage, boolean tapped, List<Ability> extraAbilities) {
private PermanentView createPermanentCard(Game game, UUID controllerId, String code, String cardNumber, int power, int toughness, int damage, boolean tapped, boolean transform, List<Ability> extraAbilities) {
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
@ -121,20 +122,21 @@ public class TestCardRenderDialog extends MageDialog {
game.loadCards(cardsList, controllerId);
Card permCard = CardUtil.getDefaultCardSideForBattlefield(newCard);
if (extraAbilities != null) {
extraAbilities.forEach(ability -> permCard.addAbility(ability));
}
PermanentCard perm = new PermanentCard(permCard, controllerId, game);
if (transform) {
// need direct transform call to keep other side info (original)
TransformAbility.transformPermanent(perm, permCard.getSecondCardFace(), game, null);
}
if (damage > 0) perm.damage(damage, controllerId, null, game);
if (power > 0) perm.getPower().setValue(power);
if (toughness > 0) perm.getToughness().setValue(toughness);
perm.removeSummoningSickness();
perm.setTapped(tapped);
if (perm.isTransformable()) {
perm.setTransformed(true);
}
PermanentView cardView = new PermanentView(perm, permCard, controllerId, game);
return cardView;
@ -290,16 +292,16 @@ public class TestCardRenderDialog extends MageDialog {
//*/
/* //test emblems
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "78", 125, 89, 0, false, null)); // Noxious Groodion
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "14", 3, 5, 2, false, null)); // Knight of Sorrows
cardViews.add(createPermanentCard(game, playerYou.getId(), "DKA", "140", 5, 2, 2, false, null)); // Huntmaster of the Fells, transforms
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "221", 0, 0, 0, false, null)); // Bedeck // Bedazzle
cardViews.add(createPermanentCard(game, playerYou.getId(), "XLN", "234", 0, 0, 0, false, null)); // Conqueror's Galleon
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "78", 125, 89, 0, false, false, null)); // Noxious Groodion
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "14", 3, 5, 2, false, false, null)); // Knight of Sorrows
cardViews.add(createPermanentCard(game, playerYou.getId(), "DKA", "140", 5, 2, 2, false, false, null)); // Huntmaster of the Fells, transforms
cardViews.add(createPermanentCard(game, playerYou.getId(), "RNA", "221", 0, 0, 0, false, false, null)); // Bedeck // Bedazzle
cardViews.add(createPermanentCard(game, playerYou.getId(), "XLN", "234", 0, 0, 0, false, false, null)); // Conqueror's Galleon
cardViews.add(createEmblem(new AjaniAdversaryOfTyrantsEmblem())); // Emblem Ajani
cardViews.add(createPlane(new AkoumPlane())); // Plane - Akoum
//*/
/* //test split, transform and mdf in hands
//test split, transform and mdf in hands
cardViews.add(createHandCard(game, playerYou.getId(), "SOI", "97")); // Accursed Witch
cardViews.add(createHandCard(game, playerYou.getId(), "UMA", "225")); // Fire // Ice
cardViews.add(createHandCard(game, playerYou.getId(), "ELD", "14")); // Giant Killer
@ -309,11 +311,10 @@ public class TestCardRenderDialog extends MageDialog {
//* //test card icons
cardViews.add(createHandCard(game, playerYou.getId(), "POR", "169")); // Grizzly Bears
cardViews.add(createHandCard(game, playerYou.getId(), "DKA", "140")); // Huntmaster of the Fells, transforms
cardViews.add(createPermanentCard(game, playerYou.getId(), "DKA", "140", 3, 3, 1, false, additionalIcons)); // Huntmaster of the Fells, transforms
cardViews.add(createPermanentCard(game, playerYou.getId(), "MB1", "401", 1, 1, 0, false, additionalIcons)); // Hinterland Drake
cardViews.add(createPermanentCard(game, playerYou.getId(), "MB1", "1441", 1, 1, 0, true, additionalIcons)); // Kathari Remnant
cardViews.add(createPermanentCard(game, playerYou.getId(), "KHM", "50", 1, 1, 0, true, additionalIcons)); // Cosima, God of the Voyage
cardViews.add(createPermanentCard(game, playerYou.getId(), "DKA", "140", 3, 3, 1, false, true, additionalIcons)); // Huntmaster of the Fells, transforms
cardViews.add(createPermanentCard(game, playerYou.getId(), "MB1", "401", 1, 1, 0, false, false, additionalIcons)); // Hinterland Drake
//cardViews.add(createPermanentCard(game, playerYou.getId(), "MB1", "1441", 1, 1, 0, true, false, additionalIcons)); // Kathari Remnant
//cardViews.add(createPermanentCard(game, playerYou.getId(), "KHM", "50", 1, 1, 0, true, false, additionalIcons)); // Cosima, God of the Voyage
//*/

View file

@ -96,7 +96,7 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
public double transformAngle = 1;
private boolean guiTransformed;
private boolean guiTransformed; // current main or other side in gui (use isTransformed() to find a real transform state)
private boolean animationInProgress = false;
private Container cardContainer;
@ -236,7 +236,7 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
public final void initialDraw() {
// Kick off
if (getGameCard().isTransformed()) {
if (getGameCard().isTransformed() && !this.isTransformed()) {
// this calls updateImage
toggleTransformed();
} else {
@ -494,7 +494,11 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
@Override
public final boolean isTransformed() {
return this.guiTransformed;
if (this.cardSideMain.isTransformed()) {
return !this.guiTransformed;
} else {
return this.guiTransformed;
}
}
@Override
@ -572,17 +576,15 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
}
// Update transform circle
if (card.canTransform()) {
if (card.canTransform() && dayNightButton != null) {
BufferedImage transformIcon;
if (isTransformed() || card.isTransformed()) { // wtf
if (this.isTransformed()) {
transformIcon = ImageManagerImpl.instance.getNightImage();
} else {
transformIcon = ImageManagerImpl.instance.getDayImage();
}
if (dayNightButton != null) {
dayNightButton.setVisible(true); // show T button for any cards and permanents
dayNightButton.setIcon(new ImageIcon(transformIcon));
}
dayNightButton.setVisible(true); // show T button for any cards and permanents
dayNightButton.setIcon(new ImageIcon(transformIcon));
}
}
@ -846,7 +848,7 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
this.guiTransformed = !this.guiTransformed;
if (dayNightButton != null) { // if transformbable card is copied, button can be null
BufferedImage image = this.guiTransformed ? ImageManagerImpl.instance.getNightImage() : ImageManagerImpl.instance.getDayImage();
BufferedImage image = this.isTransformed() ? ImageManagerImpl.instance.getNightImage() : ImageManagerImpl.instance.getDayImage();
dayNightButton.setIcon(new ImageIcon(image));
}
@ -864,7 +866,7 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
// alternative side -> main side
copySelections(this.cardSideOther, this.cardSideMain);
update(this.cardSideMain);
this.getGameCard().setAlternateName(this.cardSideOther.getName());
this.getGameCard().setAlternateName(this.cardSideOther.getName()); // wtf null protect
}
updateArtImage();
@ -939,14 +941,15 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
} else {
// from other side
this.cardSideOther = gameCard;
return;
}
}
// fix other side: if it's a night side permanent then the main side info must be extracted
if (this.cardSideOther != null
&& this.cardSideOther.getName().equals(this.cardSideMain.getName())
&& this.cardSideMain instanceof PermanentView) {
this.cardSideOther = ((PermanentView) this.cardSideMain).getOriginal();
if (this.cardSideOther == null || this.cardSideOther.getName().equals(this.cardSideMain.getName())) {
if (this.cardSideMain instanceof PermanentView) {
this.cardSideOther = ((PermanentView) this.cardSideMain).getOriginal();
}
}
}