From cc1f4b563d7853c66af24f84addf881a5b2f1d82 Mon Sep 17 00:00:00 2001 From: MTGfan Date: Thu, 1 Dec 2016 14:20:40 -0500 Subject: [PATCH] Consecrate Land currently not working --- .../src/mage/cards/c/ConsecrateLand.java | 128 ++++++++++++++++++ .../src/mage/sets/LimitedEditionAlpha.java | 1 + .../src/mage/sets/LimitedEditionBeta.java | 1 + .../src/mage/sets/TimeSpiralTimeshifted.java | 1 + Mage.Sets/src/mage/sets/UnlimitedEdition.java | 1 + .../common/CantBeEnchantedSourceEffect.java | 73 ++++++++++ 6 files changed, 205 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/c/ConsecrateLand.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/CantBeEnchantedSourceEffect.java diff --git a/Mage.Sets/src/mage/cards/c/ConsecrateLand.java b/Mage.Sets/src/mage/cards/c/ConsecrateLand.java new file mode 100644 index 00000000000..3fa41532429 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/ConsecrateLand.java @@ -0,0 +1,128 @@ +/* + * 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.cards.c; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.CantBeEnchantedSourceEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.IndestructibleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.common.FilterEnchantmentPermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetLandPermanent; + +/** + * + * @author MTGfan + */ +public class ConsecrateLand extends CardImpl { + + public ConsecrateLand(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}"); + + this.subtype.add("Aura"); + + // Enchant land + TargetPermanent auraTarget = new TargetLandPermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Enchanted land is indestructible and can't be enchanted by other Auras. + Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(IndestructibleAbility.getInstance(), AttachmentType.AURA, Duration.WhileOnBattlefield, "{this} is indestructible and can't be enchanted by other Auras.")); + ability2.addEffect(new CantBeEnchantedSourceEffect()); + ability2.addEffect(new ConsecrateLandEffect()); + this.addAbility(ability); + } + + public ConsecrateLand(final ConsecrateLand card) { + super(card); + } + + @Override + public ConsecrateLand copy() { + return new ConsecrateLand(this); + } +} + +// 9/25/2006 ruling: If Consecrate Land enters the battlefield attached to a land that’s enchanted by other Auras, those Auras are put into their owners’ graveyards. + +class ConsecrateLandEffect extends OneShotEffect { + + private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent(); + + static { + filter.add(new SubtypePredicate("Aura")); + } + + public ConsecrateLandEffect() { + super(Outcome.Benefit); + } + + public ConsecrateLandEffect(final ConsecrateLandEffect effect) { + super(effect); + } + + @Override + public ConsecrateLandEffect copy() { + return new ConsecrateLandEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); + Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); + if (enchanted != null) { + Cards removeAuras = new CardsImpl(enchanted.getAttachments()); + controller.moveCards(removeAuras, Zone.GRAVEYARD, source, game); + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java b/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java index 35833ec2c25..5a7c5416eb9 100644 --- a/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java +++ b/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java @@ -60,6 +60,7 @@ public class LimitedEditionAlpha extends ExpansionSet { cards.add(new SetCardInfo("Clockwork Beast", 236, Rarity.RARE, mage.cards.c.ClockworkBeast.class)); cards.add(new SetCardInfo("Clone", 52, Rarity.UNCOMMON, mage.cards.c.Clone.class)); cards.add(new SetCardInfo("Cockatrice", 98, Rarity.RARE, mage.cards.c.Cockatrice.class)); + cards.add(new SetCardInfo("Consecrate Land", 198, Rarity.UNCOMMON, mage.cards.c.ConsecrateLand.class)); cards.add(new SetCardInfo("Conservator", 237, Rarity.UNCOMMON, mage.cards.c.Conservator.class)); cards.add(new SetCardInfo("Control Magic", 53, Rarity.UNCOMMON, mage.cards.c.ControlMagic.class)); cards.add(new SetCardInfo("Conversion", 199, Rarity.UNCOMMON, mage.cards.c.Conversion.class)); diff --git a/Mage.Sets/src/mage/sets/LimitedEditionBeta.java b/Mage.Sets/src/mage/sets/LimitedEditionBeta.java index 0c1817bff90..c3cc0997f46 100644 --- a/Mage.Sets/src/mage/sets/LimitedEditionBeta.java +++ b/Mage.Sets/src/mage/sets/LimitedEditionBeta.java @@ -61,6 +61,7 @@ public class LimitedEditionBeta extends ExpansionSet { cards.add(new SetCardInfo("Clockwork Beast", 238, Rarity.RARE, mage.cards.c.ClockworkBeast.class)); cards.add(new SetCardInfo("Clone", 52, Rarity.UNCOMMON, mage.cards.c.Clone.class)); cards.add(new SetCardInfo("Cockatrice", 98, Rarity.RARE, mage.cards.c.Cockatrice.class)); + cards.add(new SetCardInfo("Consecrate Land", 200, Rarity.UNCOMMON, mage.cards.c.ConsecrateLand.class)); cards.add(new SetCardInfo("Conservator", 239, Rarity.UNCOMMON, mage.cards.c.Conservator.class)); cards.add(new SetCardInfo("Control Magic", 53, Rarity.UNCOMMON, mage.cards.c.ControlMagic.class)); cards.add(new SetCardInfo("Conversion", 201, Rarity.UNCOMMON, mage.cards.c.Conversion.class)); diff --git a/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java b/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java index 23aa760839c..17b166f29aa 100644 --- a/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java +++ b/Mage.Sets/src/mage/sets/TimeSpiralTimeshifted.java @@ -63,6 +63,7 @@ public class TimeSpiralTimeshifted extends ExpansionSet { cards.add(new SetCardInfo("Claws of Gix", 107, Rarity.COMMON, mage.cards.c.ClawsOfGix.class)); cards.add(new SetCardInfo("Coalition Victory", 91, Rarity.RARE, mage.cards.c.CoalitionVictory.class)); cards.add(new SetCardInfo("Cockatrice", 75, Rarity.SPECIAL, mage.cards.c.Cockatrice.class)); + cards.add(new SetCardInfo("Consecrate Land", 4, Rarity.SPECIAL, mage.cards.c.ConsecrateLand.class)); cards.add(new SetCardInfo("Conspiracy", 39, Rarity.SPECIAL, mage.cards.c.Conspiracy.class)); cards.add(new SetCardInfo("Craw Giant", 76, Rarity.SPECIAL, mage.cards.c.CrawGiant.class)); cards.add(new SetCardInfo("Dandan", 19, Rarity.SPECIAL, mage.cards.d.Dandan.class)); diff --git a/Mage.Sets/src/mage/sets/UnlimitedEdition.java b/Mage.Sets/src/mage/sets/UnlimitedEdition.java index 20a01a1a788..9e607a279ce 100644 --- a/Mage.Sets/src/mage/sets/UnlimitedEdition.java +++ b/Mage.Sets/src/mage/sets/UnlimitedEdition.java @@ -61,6 +61,7 @@ public class UnlimitedEdition extends ExpansionSet { cards.add(new SetCardInfo("Clockwork Beast", 237, Rarity.RARE, mage.cards.c.ClockworkBeast.class)); cards.add(new SetCardInfo("Clone", 52, Rarity.UNCOMMON, mage.cards.c.Clone.class)); cards.add(new SetCardInfo("Cockatrice", 98, Rarity.RARE, mage.cards.c.Cockatrice.class)); + cards.add(new SetCardInfo("Consecrate Land", 199, Rarity.UNCOMMON, mage.cards.c.ConsecrateLand.class)); cards.add(new SetCardInfo("Conservator", 238, Rarity.UNCOMMON, mage.cards.c.Conservator.class)); cards.add(new SetCardInfo("Control Magic", 53, Rarity.UNCOMMON, mage.cards.c.ControlMagic.class)); cards.add(new SetCardInfo("Conversion", 200, Rarity.UNCOMMON, mage.cards.c.Conversion.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CantBeEnchantedSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CantBeEnchantedSourceEffect.java new file mode 100644 index 00000000000..348a0290fb2 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/CantBeEnchantedSourceEffect.java @@ -0,0 +1,73 @@ +/* + * 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.abilities.Ability; +import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; + +/** + * + * @author MTGfan + */ +public class CantBeEnchantedSourceEffect extends ContinuousRuleModifyingEffectImpl { + + public CantBeEnchantedSourceEffect(CantBeEnchantedSourceEffect effect) { + super(effect); + } + + public CantBeEnchantedSourceEffect() { + super(Duration.WhileOnBattlefield, Outcome.Neutral); + staticText = "{this} can't be enchanted by other Auras."; + } + + @Override + public CantBeEnchantedSourceEffect copy() { + return new CantBeEnchantedSourceEffect(this); + } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ATTACH; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getTargetId().equals(source.getSourceId())) { + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent != null && permanent.getSubtype(game).contains("Aura")) { + return true; + } + } + return false; + } +}