Some changes to meld implementation (#9620)

* some surface-level tweaks to meld implementation

* add default implementation for meldsWith method

* move nightcard declaration to meldcard constructor

* remove unused variable declaration
This commit is contained in:
Evan Kranzler 2022-10-05 12:00:59 -04:00 committed by GitHub
parent d21f2e43dd
commit 5a4d755dba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 197 additions and 154 deletions

View file

@ -6,7 +6,10 @@ import mage.Mana;
import mage.abilities.*;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continuous.HasSubtypesSourceEffect;
import mage.abilities.keyword.*;
import mage.abilities.keyword.ChangelingAbility;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.ReconfigureAbility;
import mage.abilities.keyword.SunburstAbility;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.repository.PluginClassloaderRegistery;
import mage.constants.*;
@ -42,7 +45,8 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
protected String tokenSetCode;
protected String tokenDescriptor;
protected Rarity rarity;
protected Class<?> secondSideCardClazz;
protected Class<? extends Card> secondSideCardClazz;
protected Class<? extends Card> meldsWithClazz;
protected Card secondSideCard;
protected boolean nightCard;
protected SpellAbility spellAbility;
@ -122,6 +126,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
secondSideCardClazz = card.secondSideCardClazz;
secondSideCard = null; // will be set on first getSecondCardFace call if card has one
nightCard = card.nightCard;
meldsWithClazz = card.meldsWithClazz;
spellAbility = null; // will be set on first getSpellAbility call if card has one
flipCard = card.flipCard;
@ -643,6 +648,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
return secondFace.getSpellAbility();
}
@Override
public boolean meldsWith(Card card) {
return this.meldsWithClazz != null && this.meldsWithClazz.isInstance(card.getMainCard());
}
@Override
public boolean isNightCard() {
return this.nightCard;