mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* GUI: meld cards improves:
* added images download for melds cards (#9660); * added switch card side button to view a meld part; * fixed NPE and other errors on card side switching; * added meld cards support in test render dialog;
This commit is contained in:
parent
6102ccee53
commit
743143acde
29 changed files with 180 additions and 42 deletions
|
|
@ -33,6 +33,7 @@ import mage.game.mulligan.Mulligan;
|
|||
import mage.game.mulligan.MulliganType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.permanent.PermanentMeld;
|
||||
import mage.players.Player;
|
||||
import mage.players.StubPlayer;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -111,7 +112,7 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
}
|
||||
|
||||
private PermanentView createPermanentCard(Game game, UUID controllerId, String code, String cardNumber, int powerBoosted, int toughnessBoosted, int damage, boolean tapped, boolean transform, List<Ability> extraAbilities) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber, false);
|
||||
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
|
||||
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
|
||||
new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
|
||||
|
|
@ -126,24 +127,31 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
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);
|
||||
// meld card must be a special class, see CardUtils.putCardOntoBattlefieldWithEffects
|
||||
PermanentCard permanent;
|
||||
if (permCard instanceof MeldCard) {
|
||||
permanent = new PermanentMeld(permCard, controllerId, game);
|
||||
} else {
|
||||
permanent = new PermanentCard(permCard, controllerId, game);
|
||||
}
|
||||
|
||||
if (damage > 0) perm.damage(damage, controllerId, null, game);
|
||||
if (powerBoosted > 0) perm.getPower().setBoostedValue(powerBoosted);
|
||||
if (toughnessBoosted > 0) perm.getToughness().setBoostedValue(toughnessBoosted);
|
||||
perm.removeSummoningSickness();
|
||||
perm.setTapped(tapped);
|
||||
PermanentView cardView = new PermanentView(perm, permCard, controllerId, game);
|
||||
if (transform) {
|
||||
// need direct transform call to keep other side info (original)
|
||||
TransformAbility.transformPermanent(permanent, permCard.getSecondCardFace(), game, null);
|
||||
}
|
||||
|
||||
if (damage > 0) permanent.damage(damage, controllerId, null, game);
|
||||
if (powerBoosted > 0) permanent.getPower().setBoostedValue(powerBoosted);
|
||||
if (toughnessBoosted > 0) permanent.getToughness().setBoostedValue(toughnessBoosted);
|
||||
permanent.removeSummoningSickness();
|
||||
permanent.setTapped(tapped);
|
||||
PermanentView cardView = new PermanentView(permanent, permCard, controllerId, game);
|
||||
|
||||
return cardView;
|
||||
}
|
||||
|
||||
private CardView createFaceDownCard(Game game, UUID controllerId, String code, String cardNumber, boolean isMorphed, boolean isManifested, boolean tapped) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber, false);
|
||||
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
|
||||
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
|
||||
new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
|
||||
|
|
@ -170,7 +178,7 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
}
|
||||
|
||||
private CardView createHandCard(Game game, UUID controllerId, String code, String cardNumber) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber, false);
|
||||
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
|
||||
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
|
||||
new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
|
||||
|
|
@ -303,12 +311,21 @@ public class TestCardRenderDialog extends MageDialog {
|
|||
|
||||
//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
|
||||
cardViews.add(createHandCard(game, playerYou.getId(), "ZNR", "134")); // Akoum Warrior
|
||||
//cardViews.add(createHandCard(game, playerYou.getId(), "UMA", "225")); // Fire // Ice
|
||||
//cardViews.add(createHandCard(game, playerYou.getId(), "ELD", "14")); // Giant Killer
|
||||
//cardViews.add(createHandCard(game, playerYou.getId(), "ZNR", "134")); // Akoum Warrior
|
||||
//*/
|
||||
|
||||
//* //test card icons
|
||||
// test meld cards in hands and battlefield
|
||||
cardViews.add(createHandCard(game, playerYou.getId(), "EMN", "204")); // Hanweir Battlements
|
||||
cardViews.add(createHandCard(game, playerYou.getId(), "EMN", "130a")); // Hanweir Garrison
|
||||
cardViews.add(createHandCard(game, playerYou.getId(), "EMN", "130b")); // Hanweir, the Writhing Township
|
||||
cardViews.add(createPermanentCard(game, playerYou.getId(), "EMN", "204", 1, 1, 0, false, false, null)); // Hanweir Battlements
|
||||
cardViews.add(createPermanentCard(game, playerYou.getId(), "EMN", "130a", 1, 1, 0, false, false, null)); // Hanweir Garrison
|
||||
cardViews.add(createPermanentCard(game, playerYou.getId(), "EMN", "130b", 1, 1, 0, false, false, null)); // Hanweir, the Writhing Township
|
||||
//*/
|
||||
|
||||
/* //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, true, additionalIcons)); // Huntmaster of the Fells, transforms
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
popupContainer.setVisible(true);
|
||||
|
||||
// popup hint mode
|
||||
Image image = null;
|
||||
Image image = cardPanel.getImage();
|
||||
CardView displayCard = cardPanel.getOriginal();
|
||||
switch (enlargeMode) {
|
||||
case COPY:
|
||||
|
|
@ -696,12 +696,9 @@ public class MageActionCallback implements ActionCallback {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (image == null) {
|
||||
image = cardPanel.getImage();
|
||||
}
|
||||
|
||||
// shows the card in the popup Container
|
||||
displayCardInfo(displayCard, image, (BigCard) cardPreviewPane);
|
||||
|
||||
} else {
|
||||
logger.warn("No Card preview Pane in Mage Frame defined. Card: " + cardView.getName());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
|
|||
if (this.guiTransformed) {
|
||||
// main side -> alternative side
|
||||
if (this.cardSideOther == null) {
|
||||
logger.error("no second side for card to transform!");
|
||||
logger.error("can't find second side to toggle transform from main to second: " + this.getCard().getName());
|
||||
return;
|
||||
}
|
||||
copySelections(this.cardSideMain, this.cardSideOther);
|
||||
|
|
@ -864,6 +864,10 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
|
|||
this.getGameCard().setAlternateName(this.cardSideMain.getName());
|
||||
} else {
|
||||
// alternative side -> main side
|
||||
if (this.cardSideOther == null) {
|
||||
logger.error("can't find second side to toggle transform from second side to main: " + this.getCard().getName());
|
||||
return;
|
||||
}
|
||||
copySelections(this.cardSideOther, this.cardSideMain);
|
||||
update(this.cardSideMain);
|
||||
this.getGameCard().setAlternateName(this.cardSideOther.getName());
|
||||
|
|
@ -945,10 +949,16 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen
|
|||
}
|
||||
}
|
||||
|
||||
// fix other side: if it's a night side permanent then the main side info must be extracted
|
||||
// fix other side: if it's a night side permanent then the main side info can be extracted from original
|
||||
if (this.cardSideOther == null || this.cardSideOther.getName().equals(this.cardSideMain.getName())) {
|
||||
if (this.cardSideMain instanceof PermanentView) {
|
||||
this.cardSideOther = ((PermanentView) this.cardSideMain).getOriginal();
|
||||
if ((this.cardSideMain instanceof PermanentView)) {
|
||||
// some "transformed" cards don't have info about main side
|
||||
// (example: melded card have two main sides/cards),
|
||||
// so it must be ignored until multiple hints implement like mtga
|
||||
CardView original = ((PermanentView) this.cardSideMain).getOriginal();
|
||||
if (original != null && !original.getName().equals(this.getName())) {
|
||||
this.cardSideOther = original;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,7 +449,8 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
// main side
|
||||
allCardsUrls.add(url);
|
||||
|
||||
// second side (xmage's set doesn't have info about it, so generate it here)
|
||||
// second side
|
||||
// xmage doesn't search night cards by default, so add it and other types manually
|
||||
if (card.isDoubleFaced()) {
|
||||
if (card.getSecondSideName() == null || card.getSecondSideName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("Second side card can't have empty name.");
|
||||
|
|
@ -460,7 +461,12 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
throw new IllegalStateException("Can''t find second side card in database: " + card.getSecondSideName());
|
||||
}
|
||||
|
||||
url = new CardDownloadData(card.getSecondSideName(), card.getSetCode(), secondSideCard.getCardNumber(), card.usesVariousArt(), 0, "", "", false, card.isDoubleFaced(), true);
|
||||
url = new CardDownloadData(
|
||||
card.getSecondSideName(),
|
||||
card.getSetCode(),
|
||||
secondSideCard.getCardNumber(),
|
||||
card.usesVariousArt(),
|
||||
0, "", "", false, card.isDoubleFaced(), true);
|
||||
url.setType2(isType2);
|
||||
allCardsUrls.add(url);
|
||||
}
|
||||
|
|
@ -479,6 +485,26 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
|||
cardDownloadData.setType2(isType2);
|
||||
allCardsUrls.add(cardDownloadData);
|
||||
}
|
||||
if (card.getMeldsToCardName() != null) {
|
||||
if (card.getMeldsToCardName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("MeldsToCardName can't be empty in " + card.getName());
|
||||
}
|
||||
|
||||
CardInfo meldsToCard = CardRepository.instance.findCardWPreferredSet(card.getMeldsToCardName(), card.getSetCode());
|
||||
if (meldsToCard == null) {
|
||||
throw new IllegalStateException("Can''t find meldsToCard in database: " + card.getMeldsToCardName());
|
||||
}
|
||||
|
||||
// meld cards are normal cards from the set, so no needs to set two faces/sides here
|
||||
url = new CardDownloadData(
|
||||
card.getMeldsToCardName(),
|
||||
card.getSetCode(),
|
||||
meldsToCard.getCardNumber(),
|
||||
card.usesVariousArt(),
|
||||
0, "", "", false, false, false);
|
||||
url.setType2(isType2);
|
||||
allCardsUrls.add(url);
|
||||
}
|
||||
if (card.isModalDoubleFacesCard()) {
|
||||
if (card.getModalDoubleFacesSecondSideName() == null || card.getModalDoubleFacesSecondSideName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("MDF card can't have empty name.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue