* Icefall Regent, Monastery Siege, Elderwood Scion, Accursed Witch, Infectious Curse - Fixed target check not working for multi modal spells (fixed #2114).

This commit is contained in:
LevelX2 2016-07-31 10:41:23 +02:00
parent e9c994d8e5
commit 94e59e5ee7
5 changed files with 65 additions and 53 deletions

View file

@ -30,6 +30,7 @@ package mage.sets.dragonsoftarkir;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -125,9 +126,9 @@ class IcefallRegentEffect extends ContinuousRuleModifyingEffectImpl {
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.LOST_CONTROL || return event.getType() == GameEvent.EventType.LOST_CONTROL
event.getType() == GameEvent.EventType.ZONE_CHANGE || || event.getType() == GameEvent.EventType.ZONE_CHANGE
event.getType() == GameEvent.EventType.UNTAP; || event.getType() == GameEvent.EventType.UNTAP;
} }
@Override @Override
@ -147,7 +148,7 @@ class IcefallRegentEffect extends ContinuousRuleModifyingEffectImpl {
} }
} }
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) { if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
discard(); discard();
return false; return false;
@ -167,7 +168,7 @@ class IcefallRegentEffect extends ContinuousRuleModifyingEffectImpl {
class IcefallRegentWatcher extends Watcher { class IcefallRegentWatcher extends Watcher {
IcefallRegentWatcher () { IcefallRegentWatcher() {
super("ControlLost", WatcherScope.CARD); super("ControlLost", WatcherScope.CARD);
} }
@ -183,7 +184,7 @@ class IcefallRegentWatcher extends Watcher {
return; return;
} }
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) { if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
condition = true; condition = true;
game.replaceEvent(event); game.replaceEvent(event);
@ -226,8 +227,9 @@ class IcefallRegentCostIncreaseEffect extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) { if (abilityToModify instanceof SpellAbility) {
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
for (Target target :abilityToModify.getTargets()) { for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
for (UUID targetUUID :target.getTargets()) { for (Target target : mode.getTargets()) {
for (UUID targetUUID : target.getTargets()) {
if (targetUUID.equals(source.getSourceId())) { if (targetUUID.equals(source.getSourceId())) {
return true; return true;
} }
@ -235,6 +237,7 @@ class IcefallRegentCostIncreaseEffect extends CostModificationEffectImpl {
} }
} }
} }
}
return false; return false;
} }

View file

@ -29,6 +29,7 @@ package mage.sets.fatereforged;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.BeginningOfDrawTriggeredAbility; import mage.abilities.common.BeginningOfDrawTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility; import mage.abilities.common.EntersBattlefieldAbility;
@ -108,7 +109,8 @@ class MonasterySiegeCostIncreaseEffect extends CostModificationEffectImpl {
if (new ModeChoiceSourceCondition("Dragons").apply(game, source)) { if (new ModeChoiceSourceCondition("Dragons").apply(game, source)) {
if (abilityToModify instanceof SpellAbility) { if (abilityToModify instanceof SpellAbility) {
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
for (Target target : abilityToModify.getTargets()) { for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
for (UUID targetUUID : target.getTargets()) { for (UUID targetUUID : target.getTargets()) {
if (targetUUID.equals(source.getControllerId())) { if (targetUUID.equals(source.getControllerId())) {
return true; return true;
@ -122,6 +124,7 @@ class MonasterySiegeCostIncreaseEffect extends CostModificationEffectImpl {
} }
} }
} }
}
return false; return false;
} }

View file

@ -27,11 +27,10 @@
*/ */
package mage.sets.planechase2012; package mage.sets.planechase2012;
import mage.constants.CardType; import java.util.UUID;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl; import mage.abilities.effects.common.cost.CostModificationEffectImpl;
@ -39,15 +38,16 @@ import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.LifelinkAbility; import mage.abilities.keyword.LifelinkAbility;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.CostModificationType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.target.Target; import mage.target.Target;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.UUID;
import mage.constants.CostModificationType;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -106,8 +106,9 @@ class ElderwoodScionCostReductionEffect extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) { if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility) {
if (abilityToModify.getControllerId().equals(source.getControllerId())) { if (abilityToModify.getControllerId().equals(source.getControllerId())) {
for (Target target :abilityToModify.getTargets()) { for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
for (UUID targetUUID :target.getTargets()) { for (Target target : mode.getTargets()) {
for (UUID targetUUID : target.getTargets()) {
if (targetUUID.equals(source.getSourceId())) { if (targetUUID.equals(source.getSourceId())) {
return true; return true;
} }
@ -115,6 +116,7 @@ class ElderwoodScionCostReductionEffect extends CostModificationEffectImpl {
} }
} }
} }
}
return false; return false;
} }
@ -149,8 +151,8 @@ class ElderwoodScionCostReductionEffect2 extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) { if (abilityToModify instanceof SpellAbility) {
if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
for (Target target :abilityToModify.getTargets()) { for (Target target : abilityToModify.getTargets()) {
for (UUID targetUUID :target.getTargets()) { for (UUID targetUUID : target.getTargets()) {
if (targetUUID.equals(source.getSourceId())) { if (targetUUID.equals(source.getSourceId())) {
return true; return true;
} }

View file

@ -30,6 +30,7 @@ package mage.sets.shadowsoverinnistrad;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -138,17 +139,19 @@ class AccursedWitchSpellsCostReductionEffect extends CostModificationEffectImpl
@Override @Override
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) { if (abilityToModify instanceof SpellAbility) {
if(game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) { if (game.getOpponents(source.getControllerId()).contains(abilityToModify.getControllerId())) {
for (Target target : abilityToModify.getTargets()) { for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
for (UUID targetUUID : target.getTargets()) { for (UUID targetUUID : target.getTargets()) {
Permanent permanent = game.getPermanent(targetUUID); Permanent permanent = game.getPermanent(targetUUID);
if(permanent != null && permanent.getId().equals(source.getSourceId())) { if (permanent != null && permanent.getId().equals(source.getSourceId())) {
return true; return true;
} }
} }
} }
} }
} }
}
return false; return false;
} }
@ -157,5 +160,3 @@ class AccursedWitchSpellsCostReductionEffect extends CostModificationEffectImpl
return new AccursedWitchSpellsCostReductionEffect(this); return new AccursedWitchSpellsCostReductionEffect(this);
} }
} }

View file

@ -29,6 +29,7 @@ package mage.sets.shadowsoverinnistrad;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -154,7 +155,8 @@ class InfectiousCurseCostReductionEffect extends CostModificationEffectImpl {
public boolean applies(Ability abilityToModify, Ability source, Game game) { public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) { if (abilityToModify instanceof SpellAbility) {
if (source.getControllerId().equals(abilityToModify.getControllerId())) { if (source.getControllerId().equals(abilityToModify.getControllerId())) {
for (Target target : abilityToModify.getTargets()) { for (Mode mode : abilityToModify.getModes().getSelectedModes()) {
for (Target target : mode.getTargets()) {
for (UUID targetUUID : target.getTargets()) { for (UUID targetUUID : target.getTargets()) {
Permanent enchantment = game.getPermanent(source.getSourceId()); Permanent enchantment = game.getPermanent(source.getSourceId());
UUID attachedTo = enchantment.getAttachedTo(); UUID attachedTo = enchantment.getAttachedTo();
@ -165,6 +167,7 @@ class InfectiousCurseCostReductionEffect extends CostModificationEffectImpl {
} }
} }
} }
}
return false; return false;
} }