Update cast spell name check to use characteristics

This commit is contained in:
Steven Knipe 2023-09-18 05:48:36 -07:00
parent 9b05f824e0
commit de8c7ea235
12 changed files with 75 additions and 48 deletions

View file

@ -306,7 +306,7 @@ public class SpellAbility extends ActivatedAbilityImpl {
}
public static SpellAbility getSpellAbilityFromEvent(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.CAST_SPELL) {
if (event.getType() != GameEvent.EventType.CAST_SPELL && event.getType() != GameEvent.EventType.CAST_SPELL_LATE) {
return null;
}

View file

@ -2,7 +2,9 @@ package mage.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.game.Game;
@ -45,11 +47,12 @@ public class OpponentsCantCastChosenUntilNextTurnEffect extends ContinuousRuleMo
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { return false; }
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
if (spellAbility == null) { return false; }
Card card = spellAbility.getCharacteristics(game);
if (card == null) { return false; }
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId());
return object != null && CardUtil.haveSameNames(object, cardName, game);
}
return false;
return CardUtil.haveSameNames(card, cardName, game);
}
}

View file

@ -4,6 +4,7 @@ import mage.abilities.keyword.BestowAbility;
import mage.abilities.keyword.MorphAbility;
import mage.cards.Card;
import mage.game.Game;
import mage.game.stack.Spell;
/**
* @author LevelX2
@ -53,6 +54,10 @@ public enum SpellAbilityCastMode {
}
}
if (this.equals(MORPH)) {
if (cardCopy instanceof Spell) {
//Spell doesn't support setName, so make a copy of the card (we're blowing it away anyway)
cardCopy = ((Spell) cardCopy).getCard().copy();
}
MorphAbility.setCardToFaceDownCreature(cardCopy);
}
return cardCopy;