diff --git a/Mage.Sets/src/mage/cards/c/ChainerNightmareAdept.java b/Mage.Sets/src/mage/cards/c/ChainerNightmareAdept.java index 08dae62107d..6d0ebc5af3b 100644 --- a/Mage.Sets/src/mage/cards/c/ChainerNightmareAdept.java +++ b/Mage.Sets/src/mage/cards/c/ChainerNightmareAdept.java @@ -3,6 +3,7 @@ package mage.cards.c; import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; import mage.abilities.common.LimitedTimesPerTurnActivatedAbility; import mage.abilities.costs.common.DiscardCardCost; @@ -92,18 +93,21 @@ class ChainerNightmareAdeptContinuousEffect extends AsThoughEffectImpl { } @Override - public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility"); + } + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { ChainerNightmareAdeptWatcher watcher = game.getState().getWatcher(ChainerNightmareAdeptWatcher.class); if (watcher == null || !watcher.checkPermission( - affectedControllerId, source, game - ) || game.getState().getZone(sourceId) != Zone.GRAVEYARD) { + playerId, source, game + ) || game.getState().getZone(objectId) != Zone.GRAVEYARD) { return false; } - Card card = game.getCard(sourceId); - return card != null - && card.getOwnerId().equals(affectedControllerId) - && card.isCreature(game) - && !card.isLand(game); + Card card = game.getCard(objectId); + return card != null && affectedAbility instanceof SpellAbility + && card.getOwnerId().equals(playerId) + && ((SpellAbility) affectedAbility).getCharacteristics(game).isCreature(); } } diff --git a/Mage.Sets/src/mage/cards/c/ChandraDressedToKill.java b/Mage.Sets/src/mage/cards/c/ChandraDressedToKill.java index f87cbc854dd..f168b6b8e42 100644 --- a/Mage.Sets/src/mage/cards/c/ChandraDressedToKill.java +++ b/Mage.Sets/src/mage/cards/c/ChandraDressedToKill.java @@ -7,6 +7,7 @@ import mage.MageObject; import mage.Mana; import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; +import mage.abilities.SpellAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.GetEmblemEffect; @@ -165,10 +166,10 @@ class ChandraDressedToKillPlayEffect extends PlayFromNotOwnHandZoneTargetEffect @Override public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { - if (!super.applies(objectId, affectedAbility, source, game, playerId)) { + if (!(super.applies(objectId, affectedAbility, source, game, playerId) && affectedAbility instanceof SpellAbility)) { return false; } - Card card = game.getCard(objectId); + Card card = ((SpellAbility) affectedAbility).getCharacteristics(game); return card != null && card.getColor(game).isRed(); } } diff --git a/Mage.Sets/src/mage/cards/d/DanithaNewBenaliasLight.java b/Mage.Sets/src/mage/cards/d/DanithaNewBenaliasLight.java index 7794b0e27eb..7d0b3d8402c 100644 --- a/Mage.Sets/src/mage/cards/d/DanithaNewBenaliasLight.java +++ b/Mage.Sets/src/mage/cards/d/DanithaNewBenaliasLight.java @@ -4,6 +4,7 @@ import mage.MageIdentifier; import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.keyword.LifelinkAbility; @@ -82,18 +83,22 @@ class DanithaNewBenaliasLightCastFromGraveyardEffect extends AsThoughEffectImpl } @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - if (!source.isControlledBy(affectedControllerId) || game.getState().getZone(objectId) != Zone.GRAVEYARD) { + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { + if (!source.isControlledBy(playerId) || game.getState().getZone(objectId) != Zone.GRAVEYARD || !(affectedAbility instanceof SpellAbility)) { return false; } - Card objectCard = game.getCard(objectId); + Card objectCard = ((SpellAbility) affectedAbility).getCharacteristics(game); return objectCard != null && objectCard.isOwnedBy(source.getControllerId()) && (objectCard.hasSubtype(SubType.AURA, game) || objectCard.hasSubtype(SubType.EQUIPMENT, game)) && objectCard.getSpellAbility() != null - && objectCard.getSpellAbility().spellCanBeActivatedRegularlyNow(affectedControllerId, game) + && objectCard.getSpellAbility().spellCanBeActivatedRegularlyNow(playerId, game) && !DanithaNewBenaliasLightWatcher.isAbilityUsed(source, game); } + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility"); + } } class DanithaNewBenaliasLightWatcher extends Watcher { diff --git a/Mage/src/main/java/mage/abilities/effects/common/asthought/PlayFromNotOwnHandZoneAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/asthought/PlayFromNotOwnHandZoneAllEffect.java index 265fd5610fb..e29fd3d9824 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/asthought/PlayFromNotOwnHandZoneAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/asthought/PlayFromNotOwnHandZoneAllEffect.java @@ -3,6 +3,7 @@ package mage.abilities.effects.common.asthought; import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.effects.AsThoughEffectImpl; import mage.cards.Card; import mage.constants.AsThoughEffectType; @@ -51,16 +52,23 @@ public class PlayFromNotOwnHandZoneAllEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility"); + } + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { Card card = game.getCard(objectId); if (card != null) { + if (affectedAbility instanceof SpellAbility) { + card = ((SpellAbility) affectedAbility).getCharacteristics(game); + } switch (allowedCaster) { case YOU: - if (affectedControllerId != source.getControllerId()) { + if (playerId != source.getControllerId()) { return false; } break; case OPPONENT: - if (!game.getOpponents(source.getControllerId()).contains(affectedControllerId)) { + if (!game.getOpponents(source.getControllerId()).contains(playerId)) { return false; } break; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java index fd3f9be2d33..79f4f7ce71a 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/PlayTheTopCardEffect.java @@ -1,6 +1,7 @@ package mage.abilities.effects.common.continuous; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.effects.AsThoughEffectImpl; import mage.cards.Card; import mage.constants.AsThoughEffectType; @@ -87,6 +88,10 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility"); + } + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { // main card and all parts are checks in different calls. // two modes: // * can play cards (must check main card and allows any parts) @@ -101,10 +106,15 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl { if (this.canPlayCardOnly) { // check whole card instead part cardToCheck = cardToCheck.getMainCard(); + } else if (affectedAbility instanceof SpellAbility) { + SpellAbility spell = (SpellAbility) affectedAbility; + cardToCheck = spell.getCharacteristics(game); + if (spell.getManaCosts().isEmpty()){ + return false; + } } - // must be you - if (!affectedControllerId.equals(source.getControllerId())) { + if (!playerId.equals(source.getControllerId())) { return false; } @@ -154,12 +164,7 @@ public class PlayTheTopCardEffect extends AsThoughEffectImpl { } } - // can't cast without mana cost - if (!cardToCheck.isLand(game) && cardToCheck.getManaCost().isEmpty()) { - return false; - } - // must be correct card - return filter.match(cardToCheck, affectedControllerId, source, game); + return filter.match(cardToCheck, playerId, source, game); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java index fe1696a3810..096491d8771 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ruleModifying/PlayLandsFromGraveyardControllerEffect.java @@ -1,6 +1,7 @@ package mage.abilities.effects.common.ruleModifying; import mage.abilities.Ability; +import mage.abilities.SpellAbility; import mage.abilities.effects.AsThoughEffectImpl; import mage.cards.Card; import mage.constants.AsThoughEffectType; @@ -48,6 +49,10 @@ public class PlayLandsFromGraveyardControllerEffect extends AsThoughEffectImpl { @Override public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + throw new IllegalArgumentException("ERROR, can't call applies method on empty affectedAbility"); + } + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game, UUID playerId) { // current card's part Card cardToCheck = game.getCard(objectId); if (cardToCheck == null) { @@ -55,13 +60,13 @@ public class PlayLandsFromGraveyardControllerEffect extends AsThoughEffectImpl { } // must be you - if (!affectedControllerId.equals(source.getControllerId())) { + if (!playerId.equals(source.getControllerId())) { return false; } // must be your card Player player = game.getPlayer(cardToCheck.getOwnerId()); - if (player == null || !player.getId().equals(affectedControllerId)) { + if (player == null || !player.getId().equals(playerId)) { return false; } @@ -75,8 +80,10 @@ public class PlayLandsFromGraveyardControllerEffect extends AsThoughEffectImpl { if (!cardToCheck.isLand(game) && cardToCheck.getManaCost().isEmpty()) { return false; } - + if (affectedAbility instanceof SpellAbility){ + cardToCheck = ((SpellAbility) affectedAbility).getCharacteristics(game); + } // must be correct card - return filter.match(cardToCheck, affectedControllerId, source, game); + return filter.match(cardToCheck, playerId, source, game); } }