forked from External/mage
Update cast spell name check to use characteristics
This commit is contained in:
parent
9b05f824e0
commit
de8c7ea235
12 changed files with 75 additions and 48 deletions
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.EntersBattlefieldEffect;
|
||||
|
|
@ -15,13 +15,14 @@ import mage.constants.*;
|
|||
import mage.filter.common.FilterNonlandCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.util.CardUtil;
|
||||
import mage.util.GameLog;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -153,10 +154,11 @@ class AlhammarretHighArbiterCantCastEffect extends ContinuousRuleModifyingEffect
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
if (object != null && object.getName().equals(cardName)) {
|
||||
return true;
|
||||
}
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (card == null) { return false;}
|
||||
return CardUtil.haveSameNames(card, cardName, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.cards.a;
|
|||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -116,7 +117,9 @@ class AshioksErasureReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
|||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (sourcePermanent == null
|
||||
|| card == null) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -19,6 +19,8 @@ import mage.game.permanent.Permanent;
|
|||
import mage.game.stack.Spell;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
|
|
@ -70,7 +72,9 @@ class CorneredMarketReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (card != null) {
|
||||
Spell spell = game.getState().getStack().getSpell(event.getSourceId());
|
||||
// Face Down cast spell (Morph creature) has no name
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.e;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
|
|
@ -100,13 +101,14 @@ class ExclusionRitualReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
if (sourcePermanent != null && card != null) {
|
||||
if (!sourcePermanent.getImprinted().isEmpty()) {
|
||||
Card imprintedCard = game.getCard(sourcePermanent.getImprinted().get(0));
|
||||
if (imprintedCard != null) {
|
||||
return CardUtil.haveSameNames(card, imprintedCard);
|
||||
}
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (card == null) { return false;}
|
||||
if (sourcePermanent != null && !sourcePermanent.getImprinted().isEmpty()) {
|
||||
Card imprintedCard = game.getCard(sourcePermanent.getImprinted().get(0));
|
||||
if (imprintedCard != null) {
|
||||
return CardUtil.haveSameNames(spellAbility.getCharacteristics(game), imprintedCard);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2,12 +2,14 @@ package mage.cards.g;
|
|||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.PreventionEffectImpl;
|
||||
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -90,8 +92,10 @@ class GideonsInterventionCantCastEffect extends ContinuousRuleModifyingEffectImp
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
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 && object.getName().equals(cardName);
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
return card != null && CardUtil.haveSameNames(card, cardName, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
|
|
@ -8,7 +9,10 @@ import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
|
|
@ -68,7 +72,9 @@ class IxalansBindingReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
|||
if (event.getPlayerId().equals(source.getControllerId())) {
|
||||
return false;
|
||||
}
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (sourcePermanent != null && card != null) {
|
||||
UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
|
||||
if (exileZone != null) {
|
||||
|
|
|
|||
|
|
@ -1,25 +1,22 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
|
|
@ -61,7 +58,9 @@ class ManaMazeEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (card != null) {
|
||||
LastSpellCastWatcher watcher = game.getState().getWatcher(LastSpellCastWatcher.class);
|
||||
if (watcher != null && watcher.getLastSpellCast() != null) {
|
||||
|
|
|
|||
|
|
@ -3,16 +3,17 @@ package mage.cards.m;
|
|||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.common.ChooseACardNameEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -84,9 +85,11 @@ class MeddlingMageReplacementEffect extends ContinuousRuleModifyingEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
MageObject object = game.getObject(event.getSourceId());
|
||||
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);
|
||||
return object != null
|
||||
&& CardUtil.haveSameNames(object, cardName, game);
|
||||
return CardUtil.haveSameNames(card, cardName, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.cards.r;
|
|||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -13,7 +14,6 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -113,15 +113,11 @@ class ExclusionRitualReplacementEffect extends ContinuousRuleModifyingEffectImpl
|
|||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
if (card != null) {
|
||||
Spell spell = game.getState().getStack().getSpell(event.getSourceId());
|
||||
if (spell != null && spell.isFaceDown(game)) {
|
||||
return false; // Face Down cast spell (Morph creature) has no name
|
||||
}
|
||||
return CardUtil.haveSameNames(card, creatureName, game) && Objects.equals(ownerId, card.getOwnerId());
|
||||
}
|
||||
return false;
|
||||
SpellAbility spellAbility = SpellAbility.getSpellAbilityFromEvent(event, game);
|
||||
if (spellAbility == null) { return false;}
|
||||
Card card = spellAbility.getCharacteristics(game);
|
||||
if (card == null) { return false;}
|
||||
return CardUtil.haveSameNames(card, creatureName, game) && Objects.equals(ownerId, card.getOwnerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue