make Morph cost reduction a separate class (and fix to work with new system)

This commit is contained in:
Steven Knipe 2023-09-18 03:33:20 -07:00
parent 3f82c36813
commit e7927cb50f
8 changed files with 49 additions and 67 deletions

View file

@ -0,0 +1,33 @@
package mage.abilities.effects.common.cost;
import mage.abilities.Ability;
import mage.abilities.keyword.MorphAbility;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
public class MorphSpellsCostReductionControllerEffect extends SpellsCostReductionControllerEffect{
private static final FilterCreatureCard standardFilter = new FilterCreatureCard("Face-down creature spells");
public MorphSpellsCostReductionControllerEffect(int amount) {
super(standardFilter, amount);
}
public MorphSpellsCostReductionControllerEffect(FilterCard filter, int amount) {
super(filter, amount);
}
protected MorphSpellsCostReductionControllerEffect(final MorphSpellsCostReductionControllerEffect effect) {
super(effect);
}
@Override
public MorphSpellsCostReductionControllerEffect copy() {
return new MorphSpellsCostReductionControllerEffect(this);
}
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof MorphAbility) {
return super.applies(abilityToModify, source, game);
}
return false;
}
}

View file

@ -46,11 +46,12 @@ public enum SpellAbilityCastMode {
if (this.equals(BESTOW)) {
BestowAbility.becomeAura(cardCopy);
}
if (this.isTransformed){
if (this.isTransformed) {
Card tmp = card.getSecondCardFace();
if (tmp != null) {
cardCopy = tmp.copy();
}
}
if (this.equals(MORPH)) {
MorphAbility.setObjectToFaceDownCreature(cardCopy, game);
}

View file

@ -1,24 +0,0 @@
package mage.filter.predicate.card;
import mage.abilities.keyword.MorphAbility;
import mage.cards.Card;
import mage.filter.predicate.Predicate;
import mage.game.Game;
/**
* @author JayDi85
*/
public enum FaceDownCastablePredicate implements Predicate<Card> {
instance;
@Override
public boolean apply(Card input, Game game) {
// is card able to cast as face down
return input.getAbilities(game).containsClass(MorphAbility.class);
}
@Override
public String toString() {
return "Face-down";
}
}

View file

@ -79,9 +79,6 @@ public class Spell extends StackObjectImpl implements Card {
// simulate another side as new card (another code part in continues effect from disturb ability)
affectedCard = TransformAbility.transformCardSpellStatic(card, card.getSecondCardFace(), game);
}
if (ability.getSpellAbilityCastMode() == SpellAbilityCastMode.MORPH){
this.faceDown = true;
}
this.card = affectedCard;
this.color = affectedCard.getColor(null).copy();
@ -93,6 +90,12 @@ public class Spell extends StackObjectImpl implements Card {
this.zoneChangeCounter = affectedCard.getZoneChangeCounter(game); // sync card's ZCC with spell (copy spell settings)
this.ability = ability;
this.ability.setControllerId(controllerId);
if (ability.getSpellAbilityCastMode() == SpellAbilityCastMode.MORPH){
this.faceDown = true;
this.getColor(game).setColor(null);
game.getState().getCreateMageObjectAttribute(this.getCard(), game).getSubtype().clear();
}
if (ability.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
// if this spell is going to be a copy, these abilities will be copied in copySpell
if (!isCopy) {