Fixed cards granting indestructibility.

This commit is contained in:
North 2012-09-05 16:26:54 +03:00
parent 2a50ace7b5
commit e9b441ed9e
12 changed files with 252 additions and 85 deletions

View file

@ -27,14 +27,13 @@
*/
package mage.sets.avacynrestored;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledPermanent;
@ -60,7 +59,8 @@ public class AvacynAngelOfHope extends CardImpl<AvacynAngelOfHope> {
this.addAbility(VigilanceAbility.getInstance());
// Avacyn, Angel of Hope and other permanents you control are indestructible.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAllEffect(new IndestructibleAbility(), Constants.Duration.WhileInGraveyard, new FilterControlledPermanent())));
FilterControlledPermanent filter = new FilterControlledPermanent("Avacyn, Angel of Hope and other permanents you control");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAllEffect(filter)));
}
public AvacynAngelOfHope(final AvacynAngelOfHope card) {

View file

@ -28,15 +28,13 @@
package mage.sets.darkascension;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.abilities.condition.common.FatefulHourCondition;
import mage.abilities.decorator.ConditionalContinousEffect;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
@ -54,10 +52,12 @@ public class BreakOfDay extends CardImpl<BreakOfDay> {
this.color.setWhite(true);
// Creatures you control get +1/+1 until end of turn.
this.getSpellAbility().addEffect(new BoostControlledEffect(1, 1, Constants.Duration.EndOfTurn));
this.getSpellAbility().addEffect(new BoostControlledEffect(1, 1, Duration.EndOfTurn));
// Fateful hour - If you have 5 or less life, those creatures also are indestructible this turn.
this.getSpellAbility().addEffect(new ConditionalContinousEffect(new GainAbilityControlledEffect(new IndestructibleAbility(), Constants.Duration.EndOfTurn, new FilterCreaturePermanent()),
FatefulHourCondition.getInstance(), "If you have 5 or less life, those creatures also are indestructible this turn."));
this.getSpellAbility().addEffect(new ConditionalContinousEffect(
new IndestructibleAllEffect(new FilterCreaturePermanent("creatures you control"), Duration.EndOfTurn),
FatefulHourCondition.getInstance(),
"If you have 5 or less life, those creatures also are indestructible this turn."));
}
public BreakOfDay(final BreakOfDay card) {

View file

@ -30,12 +30,11 @@ package mage.sets.darksteel;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -45,7 +44,7 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
*/
public class DarksteelForge extends CardImpl<DarksteelForge> {
private final static FilterControlledPermanent filter = new FilterControlledPermanent("Artifacts");
private final static FilterControlledPermanent filter = new FilterControlledPermanent("Artifacts you control");
static {
filter.add(new CardTypePredicate(CardType.ARTIFACT));
@ -54,7 +53,9 @@ public class DarksteelForge extends CardImpl<DarksteelForge> {
public DarksteelForge(UUID ownerId) {
super(ownerId, 110, "Darksteel Forge", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{9}");
this.expansionSetCode = "DST";
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityControlledEffect(new IndestructibleAbility(), Constants.Duration.WhileOnBattlefield, filter, false)));
// Artifacts you control are indestructible.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAllEffect(filter)));
}

View file

@ -27,35 +27,37 @@
*/
package mage.sets.lorwyn;
import mage.Constants;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import java.util.UUID;
import mage.filter.predicate.permanent.AnotherPredicate;
/**
*
* @author anonymous
* @author Loki
*/
public class TimberProtector extends CardImpl<TimberProtector> {
private final static FilterCreaturePermanent filterTreefolk = new FilterCreaturePermanent("Treefolk creatures");
private final static FilterControlledPermanent filterBoth = new FilterControlledPermanent("Treefolk and Forests");
private final static FilterControlledPermanent filterBoth = new FilterControlledPermanent("Other Treefolk and Forests you control");
static {
filterTreefolk.add(new SubtypePredicate("Treefolk"));
filterBoth.add(Predicates.or(new SubtypePredicate("Treefolk"),new SubtypePredicate("Forest")));
filterBoth.add(Predicates.or(
new SubtypePredicate("Treefolk"),
new SubtypePredicate("Forest")));
filterBoth.add(new AnotherPredicate());
}
public TimberProtector(UUID ownerId) {
@ -66,10 +68,11 @@ public class TimberProtector extends CardImpl<TimberProtector> {
this.color.setGreen(true);
this.power = new MageInt(4);
this.toughness = new MageInt(6);
// Other Treefolk creatures you control get +1/+1.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Constants.Duration.WhileOnBattlefield, filterTreefolk, true)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filterTreefolk, true)));
// Other Treefolk and Forests you control are indestructible.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityControlledEffect(new IndestructibleAbility(), Constants.Duration.WhileOnBattlefield, filterBoth, true)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAllEffect(filterBoth)));
}
public TimberProtector(final TimberProtector card) {

View file

@ -33,12 +33,10 @@ import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.effects.common.IndestructibleAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.target.TargetPermanent;
@ -59,10 +57,9 @@ public class Indestructibility extends CardImpl<Indestructibility> {
TargetPermanent auraTarget = new TargetPermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Enchanted permanent is indestructible.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new IndestructibleAbility(), AttachmentType.AURA)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAttachedEffect(AttachmentType.AURA)));
}
public Indestructibility(final Indestructibility card) {

View file

@ -35,13 +35,13 @@ import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
/**
*
@ -53,6 +53,7 @@ public class KnightExemplar extends CardImpl<KnightExemplar> {
static {
filter.add(new SubtypePredicate("Knight"));
filter.add(new AnotherPredicate());
}
public KnightExemplar(UUID ownerId) {
@ -64,9 +65,13 @@ public class KnightExemplar extends CardImpl<KnightExemplar> {
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// First strike
this.addAbility(FirstStrikeAbility.getInstance());
// Other Knight creatures you control get +1/+1 and are indestructible.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(new IndestructibleAbility(), Duration.WhileOnBattlefield, filter, true)));
FilterCreaturePermanent indestructibleFilter = filter.copy();
indestructibleFilter.setMessage("Other Knight creatures you control");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAllEffect(indestructibleFilter)));
}
public KnightExemplar(final KnightExemplar card) {

View file

@ -30,12 +30,14 @@ package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants;
import mage.Constants.AttachmentType;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.effects.common.IndestructibleAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
@ -50,9 +52,13 @@ public class DarksteelPlate extends CardImpl<DarksteelPlate> {
super(ownerId, 104, "Darksteel Plate", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}");
this.expansionSetCode = "MBS";
this.subtype.add("Equipment");
this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(2)));
// Darksteel Plate is indestructible.
this.addAbility(new IndestructibleAbility());
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new IndestructibleAbility(), Constants.AttachmentType.EQUIPMENT)));
// Equipped creature is indestructible.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAttachedEffect(AttachmentType.EQUIPMENT)));
// Equip {2}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(2)));
}
public DarksteelPlate (final DarksteelPlate card) {

View file

@ -31,28 +31,25 @@ package mage.sets.shardsofalara;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Layer;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.SubLayer;
import mage.abilities.Ability;
import mage.Constants.Zone;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effects;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.GetEmblemEffect;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.command.Emblem;
import mage.game.permanent.token.SoldierToken;
import mage.target.common.TargetCreaturePermanent;
@ -62,17 +59,18 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class ElspethKnightErrant extends CardImpl<ElspethKnightErrant> {
private static SoldierToken soldierToken = new SoldierToken();
public ElspethKnightErrant(UUID ownerId) {
super(ownerId, 9, "Elspeth, Knight-Errant", Rarity.MYTHIC, new CardType[]{CardType.PLANESWALKER}, "{2}{W}{W}");
this.expansionSetCode = "ALA";
this.subtype.add("Elspeth");
this.color.setWhite(true);
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), ""));
this.addAbility(new LoyaltyAbility(new CreateTokenEffect(soldierToken), 1));
// +1: Put a 1/1 white Soldier creature token onto the battlefield.
this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new SoldierToken()), 1));
// +1: Target creature gets +3/+3 and gains flying until end of turn.
Effects effects1 = new Effects();
effects1.add(new BoostTargetEffect(3, 3, Duration.EndOfTurn));
effects1.add(new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn));
@ -80,8 +78,8 @@ public class ElspethKnightErrant extends CardImpl<ElspethKnightErrant> {
ability1.addTarget(new TargetCreaturePermanent());
this.addAbility(ability1);
this.addAbility(new LoyaltyAbility(new ElspethKnightErrantEffect(), -8));
// -8: You get an emblem with "Artifacts, creatures, enchantments, and lands you control are indestructible."
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new ElspethKnightErrantEmblem()), -8));
}
public ElspethKnightErrant(final ElspethKnightErrant card) {
@ -95,38 +93,15 @@ public class ElspethKnightErrant extends CardImpl<ElspethKnightErrant> {
}
class ElspethKnightErrantEffect extends ContinuousEffectImpl<ElspethKnightErrantEffect> {
class ElspethKnightErrantEmblem extends Emblem {
private static final FilterPermanent filter = new FilterPermanent("artifacts, creatures, enchantments and lands");
static {
public ElspethKnightErrantEmblem() {
FilterControlledPermanent filter = new FilterControlledPermanent("Artifacts, creatures, enchantments, and lands you control");
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE),
new CardTypePredicate(CardType.ENCHANTMENT),
new CardTypePredicate(CardType.LAND)));
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new IndestructibleAllEffect(filter)));
}
public ElspethKnightErrantEffect() {
super(Duration.EndOfGame, Layer.RulesEffects, SubLayer.NA, Outcome.AddAbility);
staticText = "For the rest of the game artifacts, creature, enchantments and lands you control are indestructible";
}
public ElspethKnightErrantEffect(final ElspethKnightErrantEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
perm.addAbility(new IndestructibleAbility(), game);
}
return true;
}
@Override
public ElspethKnightErrantEffect copy() {
return new ElspethKnightErrantEffect(this);
}
}
}

View file

@ -38,11 +38,12 @@ import mage.abilities.Ability;
import mage.abilities.common.OnEventTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.IndestructibleAllEffect;
import mage.abilities.effects.common.continious.BoostControlledEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent.EventType;
@ -60,9 +61,12 @@ public class EldraziMonument extends CardImpl<EldraziMonument> {
public EldraziMonument(UUID ownerId) {
super(ownerId, 199, "Eldrazi Monument", Rarity.MYTHIC, new CardType[]{CardType.ARTIFACT}, "{5}");
this.expansionSetCode = "ZEN";
// Creatures you control get +1/+1, have flying, and are indestructible.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, new FilterCreaturePermanent(), false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(FlyingAbility.getInstance(), Duration.WhileOnBattlefield, new FilterCreaturePermanent())));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(new IndestructibleAbility(), Duration.WhileOnBattlefield, new FilterCreaturePermanent())));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IndestructibleAllEffect(new FilterControlledCreaturePermanent("Creatures you control"))));
// At the beginning of your upkeep, sacrifice a creature. If you can't, sacrifice Eldrazi Monument.
this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new EldraziMonumentEffect()));
}

View file

@ -0,0 +1,94 @@
/*
* 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.effects.ReplacementEffectImpl;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class IndestructibleAllEffect extends ReplacementEffectImpl<IndestructibleAllEffect> {
private FilterPermanent filter;
/**
* duration = WhileOnBattlefield
*
* @param filter
*/
public IndestructibleAllEffect(FilterPermanent filter) {
this(filter, Duration.WhileOnBattlefield);
}
public IndestructibleAllEffect(FilterPermanent filter, Duration duration) {
super(duration, Outcome.Benefit);
this.filter = filter;
this.staticText = filter.getMessage() + " are indestructible";
if (duration.equals(Duration.EndOfTurn)) {
this.staticText += " this turn";
}
}
public IndestructibleAllEffect(IndestructibleAllEffect effect) {
super(effect);
this.filter = effect.filter;
}
@Override
public IndestructibleAllEffect copy() {
return new IndestructibleAllEffect(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) {
if (event.getType().equals(GameEvent.EventType.DESTROY_PERMANENT)) {
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
}
return false;
}
}

View file

@ -0,0 +1,82 @@
/*
* 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.AttachmentType;
import mage.Constants.Duration;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/**
*
* @author North
*/
public class IndestructibleAttachedEffect extends ReplacementEffectImpl<IndestructibleAttachedEffect> {
public IndestructibleAttachedEffect(AttachmentType attachmentType) {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
if (attachmentType.equals(AttachmentType.AURA)) {
this.staticText = "Enchanted permanent is indestructible";
} else {
this.staticText = "Equiped creature is indestructible";
}
}
public IndestructibleAttachedEffect(IndestructibleAttachedEffect effect) {
super(effect);
}
@Override
public IndestructibleAttachedEffect copy() {
return new IndestructibleAttachedEffect(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) {
if (event.getType().equals(GameEvent.EventType.DESTROY_PERMANENT)) {
Permanent attachment = game.getPermanent(source.getSourceId());
return attachment != null && attachment.getAttachedTo() != null
&& attachment.getAttachedTo().equals(event.getTargetId());
}
return false;
}
}

View file

@ -45,7 +45,7 @@ public class IndestructibleSourceEffect extends ReplacementEffectImpl<Indestruct
this.staticText = "{this} is indestructible";
}
public IndestructibleSourceEffect(ReplacementEffectImpl effect) {
public IndestructibleSourceEffect(IndestructibleSourceEffect effect) {
super(effect);
}