From ed8e53dabaacedfa305776f253fdd3caa7e5989c Mon Sep 17 00:00:00 2001 From: North Date: Wed, 5 Sep 2012 23:06:20 +0300 Subject: [PATCH] Added IndestructibleTargetEffect and fixed cards that should use it --- .../sets/darksteel/SlobadGoblinTinkerer.java | 12 ++- .../src/mage/sets/magic2012/AegisAngel.java | 10 +- .../sets/riseoftheeldrazi/DeathlessAngel.java | 13 ++- .../sets/scarsofmirrodin/WithstandDeath.java | 7 +- .../shardsofalara/SpearbreakerBehemoth.java | 6 +- .../common/IndestructibleTargetEffect.java | 100 ++++++++++++++++++ 6 files changed, 131 insertions(+), 17 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/IndestructibleTargetEffect.java diff --git a/Mage.Sets/src/mage/sets/darksteel/SlobadGoblinTinkerer.java b/Mage.Sets/src/mage/sets/darksteel/SlobadGoblinTinkerer.java index 0655aaddde..bf23940fce 100644 --- a/Mage.Sets/src/mage/sets/darksteel/SlobadGoblinTinkerer.java +++ b/Mage.Sets/src/mage/sets/darksteel/SlobadGoblinTinkerer.java @@ -30,15 +30,15 @@ package mage.sets.darksteel; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeTargetCost; -import mage.abilities.effects.common.continious.GainAbilityTargetEffect; -import mage.abilities.keyword.IndestructibleAbility; +import mage.abilities.effects.common.IndestructibleTargetEffect; import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledPermanent; @@ -68,7 +68,11 @@ public class SlobadGoblinTinkerer extends CardImpl { this.color.setRed(true); this.power = new MageInt(1); this.toughness = new MageInt(2); - Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new GainAbilityTargetEffect(new IndestructibleAbility(), Constants.Duration.EndOfTurn), new SacrificeTargetCost(new TargetControlledPermanent(filterControlled))); + + // Sacrifice an artifact: Target artifact is indestructible this turn. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new IndestructibleTargetEffect(Duration.EndOfTurn), + new SacrificeTargetCost(new TargetControlledPermanent(filterControlled))); ability.addTarget(new TargetPermanent(filter)); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java b/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java index dd91a80990..7c27e337a1 100644 --- a/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java +++ b/Mage.Sets/src/mage/sets/magic2012/AegisAngel.java @@ -30,15 +30,14 @@ package mage.sets.magic2012; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; -import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.effects.common.IndestructibleTargetEffect; import mage.abilities.keyword.FlyingAbility; -import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.filter.FilterPermanent; import mage.filter.predicate.permanent.AnotherPredicate; @@ -57,10 +56,13 @@ public class AegisAngel extends CardImpl { this.color.setWhite(true); this.power = new MageInt(5); this.toughness = new MageInt(5); + + // Flying this.addAbility(FlyingAbility.getInstance()); + // When Aegis Angel enters the battlefield, another target permanent is indestructible for as long as you control Aegis Angel. FilterPermanent filter = new FilterPermanent("another target permanent"); filter.add(new AnotherPredicate()); - Ability ability = new EntersBattlefieldTriggeredAbility(new GainAbilityTargetEffect(new IndestructibleAbility(), Constants.Duration.WhileOnBattlefield), false); + Ability ability = new EntersBattlefieldTriggeredAbility(new IndestructibleTargetEffect(Duration.WhileOnBattlefield), false); Target target = new TargetPermanent(filter); target.setRequired(true); ability.addTarget(target); diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/DeathlessAngel.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/DeathlessAngel.java index 120cb0f95f..ad2dcf3ddb 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/DeathlessAngel.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/DeathlessAngel.java @@ -30,16 +30,16 @@ package mage.sets.riseoftheeldrazi; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; +import mage.Constants.Zone; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.effects.common.IndestructibleTargetEffect; import mage.abilities.keyword.FlyingAbility; -import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.target.common.TargetCreaturePermanent; @@ -56,8 +56,13 @@ public class DeathlessAngel extends CardImpl { this.color.setWhite(true); this.power = new MageInt(5); this.toughness = new MageInt(7); + + // Flying this.addAbility(FlyingAbility.getInstance()); - Ability ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new GainAbilityTargetEffect(new IndestructibleAbility(), Constants.Duration.EndOfTurn), new ManaCostsImpl("{W}{W}")); + // {W}{W}: Target creature is indestructible this turn. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, + new IndestructibleTargetEffect(Duration.EndOfTurn), + new ManaCostsImpl("{W}{W}")); ability.addTarget(new TargetCreaturePermanent()); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/WithstandDeath.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/WithstandDeath.java index a9388c1e78..8cba52b4e2 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/WithstandDeath.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/WithstandDeath.java @@ -32,8 +32,7 @@ import java.util.UUID; import mage.Constants.CardType; import mage.Constants.Duration; import mage.Constants.Rarity; -import mage.abilities.effects.common.continious.GainAbilityTargetEffect; -import mage.abilities.keyword.IndestructibleAbility; +import mage.abilities.effects.common.IndestructibleTargetEffect; import mage.cards.CardImpl; import mage.target.common.TargetCreaturePermanent; @@ -47,7 +46,9 @@ public class WithstandDeath extends CardImpl { super(ownerId, 134, "Withstand Death", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{G}"); this.expansionSetCode = "SOM"; this.color.setGreen(true); - this.getSpellAbility().addEffect(new GainAbilityTargetEffect(new IndestructibleAbility(), Duration.EndOfTurn)); + + // Target creature is indestructible this turn. + this.getSpellAbility().addEffect(new IndestructibleTargetEffect(Duration.EndOfTurn)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } diff --git a/Mage.Sets/src/mage/sets/shardsofalara/SpearbreakerBehemoth.java b/Mage.Sets/src/mage/sets/shardsofalara/SpearbreakerBehemoth.java index 601c9c64b1..d0e9ff68dd 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/SpearbreakerBehemoth.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/SpearbreakerBehemoth.java @@ -35,7 +35,7 @@ import mage.Constants.Zone; import mage.MageInt; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.common.continious.GainAbilityTargetEffect; +import mage.abilities.effects.common.IndestructibleTargetEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.filter.Filter.ComparisonType; @@ -64,9 +64,11 @@ public class SpearbreakerBehemoth extends CardImpl { this.power = new MageInt(5); this.toughness = new MageInt(5); + // Spearbreaker Behemoth is indestructible. this.addAbility(new IndestructibleAbility()); + // {1}: Target creature with power 5 or greater is indestructible this turn. SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new GainAbilityTargetEffect(new IndestructibleAbility(), Duration.EndOfTurn), + new IndestructibleTargetEffect(Duration.EndOfTurn), new ManaCostsImpl("{1}")); ability.addTarget(new TargetCreaturePermanent(filter)); this.addAbility(ability); diff --git a/Mage/src/mage/abilities/effects/common/IndestructibleTargetEffect.java b/Mage/src/mage/abilities/effects/common/IndestructibleTargetEffect.java new file mode 100644 index 0000000000..8ac9f6ef85 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/IndestructibleTargetEffect.java @@ -0,0 +1,100 @@ +/* + * 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.Constants.Duration; +import mage.Constants.Outcome; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.Target; + +/** + * + * @author North + */ +public class IndestructibleTargetEffect extends ReplacementEffectImpl { + + public IndestructibleTargetEffect(Duration duration) { + super(duration, Outcome.Benefit); + } + + public IndestructibleTargetEffect(IndestructibleTargetEffect effect) { + super(effect); + } + + @Override + public IndestructibleTargetEffect copy() { + return new IndestructibleTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return event.getType().equals(GameEvent.EventType.DESTROY_PERMANENT) + && this.targetPointer.getTargets(game, source).contains(event.getTargetId()); + } + + @Override + public String getText(Mode mode) { + if (mode.getTargets().isEmpty()) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + Target target = mode.getTargets().get(0); + if (target.getMaxNumberOfTargets() > 1) { + if (target.getMaxNumberOfTargets() != target.getNumberOfTargets()) { + sb.append("up to "); + } + sb.append(target.getMaxNumberOfTargets()).append(" "); + } + sb.append("target ").append(mode.getTargets().get(0).getTargetName()); + if (target.getMaxNumberOfTargets() > 1) { + sb.append("s"); + } + + sb.append(" is indestructible"); + if (Duration.EndOfTurn.equals(this.duration)) { + sb.append(" this turn"); + } + + return sb.toString(); + } +}