* 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:
Oleg Agafonov 2023-03-09 21:36:39 +04:00
parent 6102ccee53
commit 743143acde
29 changed files with 180 additions and 42 deletions

View file

@ -47,6 +47,8 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
protected Rarity rarity;
protected Class<? extends Card> secondSideCardClazz;
protected Class<? extends Card> meldsWithClazz;
protected Class<? extends Card> meldsToClazz;
protected Card meldsToCard;
protected Card secondSideCard;
protected boolean nightCard;
protected SpellAbility spellAbility;
@ -127,6 +129,8 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
secondSideCard = null; // will be set on first getSecondCardFace call if card has one
nightCard = card.nightCard;
meldsWithClazz = card.meldsWithClazz;
meldsToClazz = card.meldsToClazz;
meldsToCard = null; // will be set on first getMeldsToCard call if card has one
spellAbility = null; // will be set on first getSpellAbility call if card has one
flipCard = card.flipCard;
@ -614,29 +618,36 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override
public boolean isTransformable() {
// warning, not all multifaces cards can be transformable (meld, mdfc)
// mtg rules method: here
// GUI related method: search "transformable = true" in CardView
// TODO: check and fix method usage in game engine, it's must be mtg rules logic, not GUI
return this.secondSideCardClazz != null || this.nightCard;
}
@Override
public final Card getSecondCardFace() {
// init second side card on first call
// init card side on first call
if (secondSideCardClazz == null && secondSideCard == null) {
return null;
}
if (secondSideCard != null) {
return secondSideCard;
if (secondSideCard == null) {
secondSideCard = initSecondSideCard(secondSideCardClazz);
}
return secondSideCard;
}
private Card initSecondSideCard(Class<? extends Card> cardClazz) {
// must be non strict search in any sets, not one set
// example: if set contains only one card side
// method used in cards database creating, so can't use repository here
ExpansionSet.SetCardInfo info = Sets.findCardByClass(secondSideCardClazz, expansionSetCode);
ExpansionSet.SetCardInfo info = Sets.findCardByClass(cardClazz, expansionSetCode);
if (info == null) {
return null;
}
secondSideCard = createCard(secondSideCardClazz, new CardSetInfo(info.getName(), expansionSetCode, info.getCardNumber(), info.getRarity(), info.getGraphicInfo()));
return secondSideCard;
return createCard(cardClazz, new CardSetInfo(info.getName(), expansionSetCode, info.getCardNumber(), info.getRarity(), info.getGraphicInfo()));
}
@Override
@ -653,6 +664,25 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
return this.meldsWithClazz != null && this.meldsWithClazz.isInstance(card.getMainCard());
}
@Override
public Class<? extends Card> getMeldsToClazz() {
return this.meldsToClazz;
}
@Override
public Card getMeldsToCard() {
// init card on first call
if (meldsToClazz == null && meldsToCard == null) {
return null;
}
if (meldsToCard == null) {
meldsToCard = initSecondSideCard(meldsToClazz);
}
return meldsToCard;
}
@Override
public boolean isNightCard() {
return this.nightCard;