diff --git a/Mage.Sets/src/mage/cards/b/BurnFromWithin.java b/Mage.Sets/src/mage/cards/b/BurnFromWithin.java index e27a27c3b97..0ae16c1ed75 100644 --- a/Mage.Sets/src/mage/cards/b/BurnFromWithin.java +++ b/Mage.Sets/src/mage/cards/b/BurnFromWithin.java @@ -29,10 +29,8 @@ package mage.cards.b; import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.LoseAbilityTargetEffect; -import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -44,9 +42,10 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCreatureOrPlayer; import mage.target.targetpointer.FixedTarget; -import mage.watchers.common.DamagedByWatcher; import java.util.UUID; +import mage.MageObjectReference; +import mage.abilities.effects.common.replacement.DiesReplacementEffect; /** * @@ -55,18 +54,13 @@ import java.util.UUID; public class BurnFromWithin extends CardImpl { public BurnFromWithin(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}"); // Burn from Within deals X damage to target creature or player. If a creature is dealt damage this way, it loses indestructible until end of turn. + // If that creature would die this turn, exile it instead. this.getSpellAbility().addEffect(new BurnFromWithinEffect()); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); - // If that creature would die this turn, exile it instead. - Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn); - effect.setText("If that creature would die this turn, exile it instead"); - this.getSpellAbility().addEffect(effect); - this.getSpellAbility().addWatcher(new DamagedByWatcher()); - } public BurnFromWithin(final BurnFromWithin card) { @@ -83,7 +77,7 @@ class BurnFromWithinEffect extends OneShotEffect { public BurnFromWithinEffect() { super(Outcome.Benefit); - this.staticText = "{this} deals X damage to target creature or player. If a creature is dealt damage this way, it loses indestructible until end of turn"; + this.staticText = "{this} deals X damage to target creature or player. If a creature is dealt damage this way, it loses indestructible until end of turn. If that creature would die this turn, exile it instead"; } public BurnFromWithinEffect(final BurnFromWithinEffect effect) { @@ -102,6 +96,7 @@ class BurnFromWithinEffect extends OneShotEffect { Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source)); int amount = source.getManaCostsToPay().getX(); if (creature != null) { + game.addEffect(new DiesReplacementEffect(new MageObjectReference(creature, game), Duration.EndOfTurn), source); int damageDealt = creature.damage(amount, source.getSourceId(), game, false, true); if (damageDealt > 0) { ContinuousEffect effect = new LoseAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn); @@ -118,4 +113,4 @@ class BurnFromWithinEffect extends OneShotEffect { } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/c/Carbonize.java b/Mage.Sets/src/mage/cards/c/Carbonize.java index 70293d63147..531412d713f 100644 --- a/Mage.Sets/src/mage/cards/c/Carbonize.java +++ b/Mage.Sets/src/mage/cards/c/Carbonize.java @@ -27,9 +27,7 @@ */ package mage.cards.c; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; import mage.abilities.effects.common.ruleModifying.CantRegenerateTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -39,6 +37,7 @@ import mage.target.common.TargetCreatureOrPlayer; import mage.watchers.common.DamagedByWatcher; import java.util.UUID; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; /** * @@ -47,17 +46,15 @@ import java.util.UUID; public class Carbonize extends CardImpl { public Carbonize(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{R}"); // Carbonize deals 3 damage to target creature or player. That creature can't be regenerated this turn. If the creature would die this turn, exile it instead. this.getSpellAbility().addEffect(new DamageTargetEffect(3)); this.getSpellAbility().addEffect(new CantRegenerateTargetEffect(Duration.EndOfTurn, "That creature")); - Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn); - effect.setText("If the creature would die this turn, exile it instead"); - this.getSpellAbility().addEffect(effect); + this.getSpellAbility().addEffect(new ExileTargetIfDiesEffect().setText("If the creature would die this turn, exile it instead")); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); this.getSpellAbility().addWatcher(new DamagedByWatcher()); - + } public Carbonize(final Carbonize card) { diff --git a/Mage.Sets/src/mage/cards/d/Disintegrate.java b/Mage.Sets/src/mage/cards/d/Disintegrate.java index 6454a2cfd48..4ca3790fe1b 100644 --- a/Mage.Sets/src/mage/cards/d/Disintegrate.java +++ b/Mage.Sets/src/mage/cards/d/Disintegrate.java @@ -30,16 +30,15 @@ package mage.cards.d; import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; import mage.abilities.effects.common.ruleModifying.CantRegenerateTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.target.common.TargetCreatureOrPlayer; -import mage.watchers.common.DamagedByWatcher; import java.util.UUID; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; /** * @@ -48,17 +47,15 @@ import java.util.UUID; public class Disintegrate extends CardImpl { public Disintegrate(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{R}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}"); // Disintegrate deals X damage to target creature or player. That creature can't be regenerated this turn. If the creature would die this turn, exile it instead. this.getSpellAbility().addEffect(new DamageTargetEffect(new ManacostVariableValue())); this.getSpellAbility().addEffect(new CantRegenerateTargetEffect(Duration.EndOfTurn, "That creature")); - Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn); + Effect effect = new ExileTargetIfDiesEffect(); effect.setText("If the creature would die this turn, exile it instead"); this.getSpellAbility().addEffect(effect); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); - this.getSpellAbility().addWatcher(new DamagedByWatcher()); } public Disintegrate(final Disintegrate card) { diff --git a/Mage.Sets/src/mage/cards/m/MagmaSpray.java b/Mage.Sets/src/mage/cards/m/MagmaSpray.java index a568e5d6344..3fc5af518e7 100644 --- a/Mage.Sets/src/mage/cards/m/MagmaSpray.java +++ b/Mage.Sets/src/mage/cards/m/MagmaSpray.java @@ -28,18 +28,11 @@ package mage.cards.m; import java.util.UUID; -import mage.MageObjectReference; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.common.replacement.DiesReplacementEffect; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetCreaturePermanent; /** @@ -52,7 +45,8 @@ public class MagmaSpray extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{R}"); // Magma Spray deals 2 damage to target creature. If that creature would die this turn, exile it instead. - this.getSpellAbility().addEffect(new MagmaSprayEffect()); + this.getSpellAbility().addEffect(new DamageTargetEffect(2)); + this.getSpellAbility().addEffect(new ExileTargetIfDiesEffect()); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } @@ -65,34 +59,3 @@ public class MagmaSpray extends CardImpl { return new MagmaSpray(this); } } - -class MagmaSprayEffect extends OneShotEffect { - - public MagmaSprayEffect() { - super(Outcome.Damage); - this.staticText = "{this} deals 2 damage to target creature. If that creature would die this turn, exile it instead"; - } - - public MagmaSprayEffect(final MagmaSprayEffect effect) { - super(effect); - } - - @Override - public MagmaSprayEffect copy() { - return new MagmaSprayEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (targetCreature != null) { - game.addEffect(new DiesReplacementEffect(new MageObjectReference(targetCreature, game), Duration.EndOfTurn), source); - targetCreature.damage(2, source.getSourceId(), game, false, true); - } - return true; - } - return false; - } -} diff --git a/Mage.Sets/src/mage/cards/n/NineRingedBo.java b/Mage.Sets/src/mage/cards/n/NineRingedBo.java index 0fb11cf4432..996b9ded347 100644 --- a/Mage.Sets/src/mage/cards/n/NineRingedBo.java +++ b/Mage.Sets/src/mage/cards/n/NineRingedBo.java @@ -31,18 +31,15 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.ActivateAsSorceryActivatedAbility; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.target.common.TargetCreaturePermanent; -import mage.watchers.common.DamagedByWatcher; /** * @@ -57,15 +54,13 @@ public class NineRingedBo extends CardImpl { } public NineRingedBo(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); // {T}: Nine-Ringed Bo deals 1 damage to target Spirit creature. If that creature would die this turn, exile it instead. Ability ability = new ActivateAsSorceryActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); + ability.addEffect(new ExileTargetIfDiesEffect()); ability.addTarget(new TargetCreaturePermanent(filter)); - Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn); - effect.setText("If that creature would die this turn, exile it instead"); - ability.addEffect(effect); - this.addAbility(ability, new DamagedByWatcher()); + this.addAbility(ability); } public NineRingedBo(final NineRingedBo card) { diff --git a/Mage.Sets/src/mage/cards/r/ReduceToAshes.java b/Mage.Sets/src/mage/cards/r/ReduceToAshes.java index 59f2f871188..663a87f487b 100644 --- a/Mage.Sets/src/mage/cards/r/ReduceToAshes.java +++ b/Mage.Sets/src/mage/cards/r/ReduceToAshes.java @@ -28,15 +28,12 @@ package mage.cards.r; import java.util.UUID; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; import mage.target.common.TargetCreaturePermanent; -import mage.watchers.common.DamagedByWatcher; /** * @@ -45,16 +42,14 @@ import mage.watchers.common.DamagedByWatcher; public class ReduceToAshes extends CardImpl { public ReduceToAshes(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{R}"); // Reduce to Ashes deals 5 damage to target creature. If that creature would die this turn, exile it instead. this.getSpellAbility().addEffect(new DamageTargetEffect(5)); - this.getSpellAbility().addTarget(new TargetCreaturePermanent()); // If that creature would die this turn, exile it instead. - Effect effect = new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn); - effect.setText("If that creature would die this turn, exile it instead"); - this.getSpellAbility().addEffect(effect); - this.getSpellAbility().addWatcher(new DamagedByWatcher()); + this.getSpellAbility().addEffect(new ExileTargetIfDiesEffect()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + } public ReduceToAshes(final ReduceToAshes card) { diff --git a/Mage.Sets/src/mage/cards/s/ScorchingLava.java b/Mage.Sets/src/mage/cards/s/ScorchingLava.java index 03dc90be8be..51bb207a58f 100644 --- a/Mage.Sets/src/mage/cards/s/ScorchingLava.java +++ b/Mage.Sets/src/mage/cards/s/ScorchingLava.java @@ -28,21 +28,26 @@ package mage.cards.s; import java.util.UUID; +import mage.MageObjectReference; +import mage.abilities.Ability; import mage.abilities.condition.LockedInCondition; import mage.abilities.condition.common.KickedCondition; import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect; -import mage.abilities.decorator.ConditionalReplacementEffect; -import mage.abilities.effects.Effect; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageTargetEffect; -import mage.abilities.effects.common.replacement.DealtDamageToCreatureBySourceDies; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; +import mage.abilities.effects.common.replacement.DiesReplacementEffect; import mage.abilities.effects.common.ruleModifying.CantRegenerateTargetEffect; import mage.abilities.keyword.KickerAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; import mage.target.common.TargetCreatureOrPlayer; -import mage.watchers.common.DamagedByWatcher; /** * @@ -51,20 +56,18 @@ import mage.watchers.common.DamagedByWatcher; public class ScorchingLava extends CardImpl { public ScorchingLava(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}"); // Kicker {R} this.addAbility(new KickerAbility("{R}")); // Scorching Lava deals 2 damage to target creature or player. If Scorching Lava was kicked, that creature can't be regenerated this turn and if it would die this turn, exile it instead. this.getSpellAbility().addEffect(new DamageTargetEffect(2)); this.getSpellAbility().addEffect(new ConditionalContinuousRuleModifyingEffect( - new CantRegenerateTargetEffect(Duration.EndOfTurn, "That creature"), new LockedInCondition(KickedCondition.instance))); - Effect effect = new ConditionalReplacementEffect(new DealtDamageToCreatureBySourceDies(this, Duration.EndOfTurn), - new LockedInCondition(KickedCondition.instance)); - effect.setText("and if it would die this turn, exile it instead"); - this.getSpellAbility().addEffect(effect); + new CantRegenerateTargetEffect(Duration.EndOfTurn, "that creature"), new LockedInCondition(KickedCondition.instance))); + this.getSpellAbility().addEffect(new ConditionalOneShotEffect( + (OneShotEffect) new ExileTargetIfDiesEffect().setText("and if it would die this turn, exile it instead"), + new LockedInCondition(KickedCondition.instance))); this.getSpellAbility().addTarget(new TargetCreatureOrPlayer()); - this.getSpellAbility().addWatcher(new DamagedByWatcher()); } public ScorchingLava(final ScorchingLava card) { @@ -76,3 +79,29 @@ public class ScorchingLava extends CardImpl { return new ScorchingLava(this); } } + +class ScorchingLavaEffect extends OneShotEffect { + + public ScorchingLavaEffect() { + super(Outcome.Exile); + this.staticText = "and if it would die this turn, exile it instead"; + } + + public ScorchingLavaEffect(final ScorchingLavaEffect effect) { + super(effect); + } + + @Override + public ScorchingLavaEffect copy() { + return new ScorchingLavaEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (targetCreature != null) { + game.addEffect(new DiesReplacementEffect(new MageObjectReference(targetCreature, game), Duration.EndOfTurn), source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/u/UnnaturalAggression.java b/Mage.Sets/src/mage/cards/u/UnnaturalAggression.java index 3e626588c6d..ae1db4572ea 100644 --- a/Mage.Sets/src/mage/cards/u/UnnaturalAggression.java +++ b/Mage.Sets/src/mage/cards/u/UnnaturalAggression.java @@ -29,27 +29,19 @@ package mage.cards.u; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.ExileTargetIfDiesEffect; import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.keyword.DevoidAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.TargetController; -import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.ControllerPredicate; -import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.events.ZoneChangeEvent; -import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; -import mage.target.targetpointer.FixedTarget; +import mage.target.targetpointer.SecondTargetPointer; /** * @@ -64,7 +56,7 @@ public class UnnaturalAggression extends CardImpl { } public UnnaturalAggression(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}"); // Devoid Ability ability = new DevoidAbility(this.color); @@ -75,7 +67,10 @@ public class UnnaturalAggression extends CardImpl { this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); // If the creature an opponent controls would die this turn, exile it instead. - this.getSpellAbility().addEffect(new DealtDamageToOpponentsCreatureDiesEffect(Duration.EndOfTurn)); + Effect effect = new ExileTargetIfDiesEffect(); + effect.setText("If the creature an opponent controls would die this turn, exile it instead"); + effect.setTargetPointer(new SecondTargetPointer()); + this.getSpellAbility().addEffect(effect); } public UnnaturalAggression(final UnnaturalAggression card) { @@ -87,58 +82,3 @@ public class UnnaturalAggression extends CardImpl { return new UnnaturalAggression(this); } } - -class DealtDamageToOpponentsCreatureDiesEffect extends ReplacementEffectImpl { - - public DealtDamageToOpponentsCreatureDiesEffect(Duration duration) { - super(Duration.EndOfTurn, Outcome.Exile); - staticText = "If the creature an opponent controls would die this turn, exile it instead"; - } - - public DealtDamageToOpponentsCreatureDiesEffect(final DealtDamageToOpponentsCreatureDiesEffect effect) { - super(effect); - } - - @Override - public DealtDamageToOpponentsCreatureDiesEffect copy() { - return new DealtDamageToOpponentsCreatureDiesEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public void init(Ability source, Game game) { - super.init(source, game); - Permanent opponentCreature = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (opponentCreature != null) { - this.setTargetPointer(new FixedTarget(opponentCreature, game)); - } else { - discard(); - } - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - Permanent permanent = ((ZoneChangeEvent) event).getTarget(); - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null && permanent != null) { - return controller.moveCards(permanent, Zone.EXILED, source, game); - } - return false; - } - - @Override - public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == EventType.ZONE_CHANGE; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - ZoneChangeEvent zce = (ZoneChangeEvent) event; - return zce.isDiesEvent() && zce.getTargetId().equals(getTargetPointer().getFirst(game, source)); - } - -} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/KickerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/KickerTest.java index 0c5107783f2..878f6a4c3a0 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/KickerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/KickerTest.java @@ -82,7 +82,7 @@ public class KickerTest extends CardTestPlayerBase { addCard(Zone.HAND, playerA, "Aether Figment"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Aether Figment"); - setChoice(playerA, "Yes"); + setChoice(playerA, "Yes"); // with Kicker setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ScorchingLavaTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ScorchingLavaTest.java new file mode 100644 index 00000000000..b4322443fa5 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/replacement/ScorchingLavaTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package org.mage.test.cards.replacement; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class ScorchingLavaTest extends CardTestPlayerBase { + + /** + * Tests that spells don't work for opponents but still work for controller + */ + @Test + public void testTargetGetExiled() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + // Kicker {R} + // Scorching Lava deals 2 damage to target creature or player. If Scorching Lava was kicked, that creature can't be regenerated this turn and if it would die this turn, exile it instead. + addCard(Zone.HAND, playerA, "Scorching Lava"); // Instant {1}{R} + + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Scorching Lava", "Silvercoat Lion"); + setChoice(playerA, "Yes"); // with Kicker + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Scorching Lava", 1); + assertExileCount(playerB, "Silvercoat Lion", 1); + } + +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileTargetIfDiesEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileTargetIfDiesEffect.java new file mode 100644 index 00000000000..ca3a35a5243 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileTargetIfDiesEffect.java @@ -0,0 +1,67 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.effects.common; + +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.replacement.DiesReplacementEffect; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class ExileTargetIfDiesEffect extends OneShotEffect { + + public ExileTargetIfDiesEffect() { + super(Outcome.Damage); + this.staticText = "If that creature would die this turn, exile it instead"; + } + + public ExileTargetIfDiesEffect(final ExileTargetIfDiesEffect effect) { + super(effect); + } + + @Override + public ExileTargetIfDiesEffect copy() { + return new ExileTargetIfDiesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (targetCreature != null) { + game.addEffect(new DiesReplacementEffect(new MageObjectReference(targetCreature, game), Duration.EndOfTurn), source); + } + return true; + } +}