* 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,10 +227,12 @@ 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()) {
if (targetUUID.equals(source.getSourceId())) { for (UUID targetUUID : target.getTargets()) {
return true; if (targetUUID.equals(source.getSourceId())) {
return true;
}
} }
} }
} }

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,14 +109,16 @@ 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 (UUID targetUUID : target.getTargets()) { for (Target target : mode.getTargets()) {
if (targetUUID.equals(source.getControllerId())) { for (UUID targetUUID : target.getTargets()) {
return true; if (targetUUID.equals(source.getControllerId())) {
} return true;
Permanent permanent = game.getPermanent(targetUUID); }
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())) { Permanent permanent = game.getPermanent(targetUUID);
return true; if (permanent != null && permanent.getControllerId().equals(source.getControllerId())) {
return true;
}
} }
} }
} }

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,10 +106,12 @@ 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()) {
if (targetUUID.equals(source.getSourceId())) { for (UUID targetUUID : target.getTargets()) {
return true; if (targetUUID.equals(source.getSourceId())) {
return true;
}
} }
} }
} }
@ -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,12 +139,14 @@ 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 (UUID targetUUID : target.getTargets()) { for (Target target : mode.getTargets()) {
Permanent permanent = game.getPermanent(targetUUID); for (UUID targetUUID : target.getTargets()) {
if(permanent != null && permanent.getId().equals(source.getSourceId())) { Permanent permanent = game.getPermanent(targetUUID);
return true; if (permanent != null && permanent.getId().equals(source.getSourceId())) {
return true;
}
} }
} }
} }
@ -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,12 +155,14 @@ 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 (UUID targetUUID : target.getTargets()) { for (Target target : mode.getTargets()) {
Permanent enchantment = game.getPermanent(source.getSourceId()); for (UUID targetUUID : target.getTargets()) {
UUID attachedTo = enchantment.getAttachedTo(); Permanent enchantment = game.getPermanent(source.getSourceId());
if (targetUUID.equals(attachedTo)) { UUID attachedTo = enchantment.getAttachedTo();
return true; if (targetUUID.equals(attachedTo)) {
return true;
}
} }
} }
} }