From cc1f4b563d7853c66af24f84addf881a5b2f1d82 Mon Sep 17 00:00:00 2001 From: MTGfan Date: Thu, 1 Dec 2016 14:20:40 -0500 Subject: [PATCH 1/5] 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 0000000000..3fa4153242 --- /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 35833ec2c2..5a7c5416eb 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 0c1817bff9..c3cc0997f4 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 23aa760839..17b166f29a 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 20a01a1a78..9e607a279c 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 0000000000..348a0290fb --- /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; + } +} From 0f90531b33a168c52271d54baf512490b9a10592 Mon Sep 17 00:00:00 2001 From: MTGfan Date: Thu, 1 Dec 2016 23:33:10 -0500 Subject: [PATCH 2/5] Animate Artifact please test this --- .../src/mage/cards/a/AnimateArtifact.java | 120 ++++++++++++++++++ Mage.Sets/src/mage/sets/FourthEdition.java | 1 + .../src/mage/sets/LimitedEditionAlpha.java | 1 + .../src/mage/sets/LimitedEditionBeta.java | 1 + Mage.Sets/src/mage/sets/MastersEditionIV.java | 1 + Mage.Sets/src/mage/sets/RevisedEdition.java | 1 + Mage.Sets/src/mage/sets/UnlimitedEdition.java | 1 + .../EquippedMatchesFilterCondition.java | 6 +- 8 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/a/AnimateArtifact.java diff --git a/Mage.Sets/src/mage/cards/a/AnimateArtifact.java b/Mage.Sets/src/mage/cards/a/AnimateArtifact.java new file mode 100644 index 0000000000..c788c76b9f --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AnimateArtifact.java @@ -0,0 +1,120 @@ +/* + * 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.a; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.common.EquippedMatchesFilterCondition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.BecomesCreatureAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterArtifactPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.Token; +import mage.target.TargetPermanent; +import mage.target.common.TargetArtifactPermanent; + +/** + * + * @author MTGfan + */ +public class AnimateArtifact extends CardImpl { + + private static final FilterPermanent filter = new FilterArtifactPermanent("noncreature artifact"); + + static { + filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); + } + + public AnimateArtifact(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}"); + + this.subtype.add("Aura"); + + // Enchant artifact + TargetPermanent auraTarget = new TargetArtifactPermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Benefit)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // As long as enchanted artifact isn't a creature, it's an artifact creature with power and toughness each equal to its converted mana cost. + ConvertedManaCost cost = new ConvertedManaCost(); + int amount = cost.getConvertedManaCost(); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new BecomesCreatureAttachedEffect(new AnimateArtifactToken(amount, amount), "it's an artifact creature with power and toughness each equal to its converted mana cost.", Duration.WhileOnBattlefield), new EquippedMatchesFilterCondition(filter), "As long as enchanted artifact isn't a creature"))); + } + + public AnimateArtifact(final AnimateArtifact card) { + super(card); + } + + @Override + public AnimateArtifact copy() { + return new AnimateArtifact(this); + } +} + +class AnimateArtifactToken extends Token { + + AnimateArtifactToken(int power, int toughness) { + super("", ""); + cardType.add(CardType.CREATURE); + this.power = new MageInt(power); + this.toughness = new MageInt(toughness); + } +} + +class ConvertedManaCost {//need to figure out how this can be used to return CMC to variable amount in animate artifact token + + int cmc; + + int calculate(Game game, Ability source, Effect effect) { + Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); + Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); + cmc = enchanted.getConvertedManaCost(); + return cmc; + } + + int getConvertedManaCost () { + return cmc; + } +} diff --git a/Mage.Sets/src/mage/sets/FourthEdition.java b/Mage.Sets/src/mage/sets/FourthEdition.java index aff0ffeedb..1d254e51db 100644 --- a/Mage.Sets/src/mage/sets/FourthEdition.java +++ b/Mage.Sets/src/mage/sets/FourthEdition.java @@ -62,6 +62,7 @@ public class FourthEdition extends ExpansionSet { cards.add(new SetCardInfo("Amrou Kithkin", 252, Rarity.COMMON, mage.cards.a.AmrouKithkin.class)); cards.add(new SetCardInfo("Amulet of Kroog", 311, Rarity.COMMON, mage.cards.a.AmuletOfKroog.class)); cards.add(new SetCardInfo("Angry Mob", 253, Rarity.UNCOMMON, mage.cards.a.AngryMob.class)); + cards.add(new SetCardInfo("Animate Artifact", 60, Rarity.UNCOMMON, mage.cards.a.AnimateArtifact.class)); cards.add(new SetCardInfo("Animate Dead", 2, Rarity.UNCOMMON, mage.cards.a.AnimateDead.class)); cards.add(new SetCardInfo("Animate Wall", 254, Rarity.RARE, mage.cards.a.AnimateWall.class)); cards.add(new SetCardInfo("Ankh of Mishra", 312, Rarity.RARE, mage.cards.a.AnkhOfMishra.class)); diff --git a/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java b/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java index 5a7c5416eb..08d5f7b536 100644 --- a/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java +++ b/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java @@ -27,6 +27,7 @@ public class LimitedEditionAlpha extends ExpansionSet { this.ratioBoosterMythic = 0; cards.add(new SetCardInfo("Air Elemental", 47, Rarity.UNCOMMON, mage.cards.a.AirElemental.class)); cards.add(new SetCardInfo("Ancestral Recall", 48, Rarity.RARE, mage.cards.a.AncestralRecall.class)); + cards.add(new SetCardInfo("Animate Artifact", 49, Rarity.UNCOMMON, mage.cards.a.AnimateArtifact.class)); cards.add(new SetCardInfo("Animate Dead", 1, Rarity.UNCOMMON, mage.cards.a.AnimateDead.class)); cards.add(new SetCardInfo("Animate Wall", 185, Rarity.RARE, mage.cards.a.AnimateWall.class)); cards.add(new SetCardInfo("Ankh of Mishra", 230, Rarity.RARE, mage.cards.a.AnkhOfMishra.class)); diff --git a/Mage.Sets/src/mage/sets/LimitedEditionBeta.java b/Mage.Sets/src/mage/sets/LimitedEditionBeta.java index c3cc0997f4..cf1830d416 100644 --- a/Mage.Sets/src/mage/sets/LimitedEditionBeta.java +++ b/Mage.Sets/src/mage/sets/LimitedEditionBeta.java @@ -27,6 +27,7 @@ public class LimitedEditionBeta extends ExpansionSet { this.ratioBoosterMythic = 0; cards.add(new SetCardInfo("Air Elemental", 47, Rarity.UNCOMMON, mage.cards.a.AirElemental.class)); cards.add(new SetCardInfo("Ancestral Recall", 48, Rarity.RARE, mage.cards.a.AncestralRecall.class)); + cards.add(new SetCardInfo("Animate Artifact", 49, Rarity.UNCOMMON, mage.cards.a.AnimateArtifact.class)); cards.add(new SetCardInfo("Animate Dead", 1, Rarity.UNCOMMON, mage.cards.a.AnimateDead.class)); cards.add(new SetCardInfo("Animate Wall", 186, Rarity.RARE, mage.cards.a.AnimateWall.class)); cards.add(new SetCardInfo("Ankh of Mishra", 232, Rarity.RARE, mage.cards.a.AnkhOfMishra.class)); diff --git a/Mage.Sets/src/mage/sets/MastersEditionIV.java b/Mage.Sets/src/mage/sets/MastersEditionIV.java index b942b71267..ba8957b1b4 100644 --- a/Mage.Sets/src/mage/sets/MastersEditionIV.java +++ b/Mage.Sets/src/mage/sets/MastersEditionIV.java @@ -65,6 +65,7 @@ public class MastersEditionIV extends ExpansionSet { cards.add(new SetCardInfo("Ali from Cairo", 107, Rarity.RARE, mage.cards.a.AliFromCairo.class)); cards.add(new SetCardInfo("Alluring Scent", 141, Rarity.COMMON, mage.cards.a.AlluringScent.class)); cards.add(new SetCardInfo("Amulet of Kroog", 179, Rarity.COMMON, mage.cards.a.AmuletOfKroog.class)); + cards.add(new SetCardInfo("Animate Artifact", 38, Rarity.UNCOMMON, mage.cards.a.AnimateArtifact.class)); cards.add(new SetCardInfo("Argivian Blacksmith", 4, Rarity.UNCOMMON, mage.cards.a.ArgivianBlacksmith.class)); cards.add(new SetCardInfo("Argothian Pixies", 142, Rarity.COMMON, mage.cards.a.ArgothianPixies.class)); cards.add(new SetCardInfo("Argothian Treefolk", 143, Rarity.UNCOMMON, mage.cards.a.ArgothianTreefolk.class)); diff --git a/Mage.Sets/src/mage/sets/RevisedEdition.java b/Mage.Sets/src/mage/sets/RevisedEdition.java index e8f3f83d32..9ae4314c5a 100644 --- a/Mage.Sets/src/mage/sets/RevisedEdition.java +++ b/Mage.Sets/src/mage/sets/RevisedEdition.java @@ -28,6 +28,7 @@ public class RevisedEdition extends ExpansionSet { cards.add(new SetCardInfo("Air Elemental", 47, Rarity.UNCOMMON, mage.cards.a.AirElemental.class)); cards.add(new SetCardInfo("Aladdin's Lamp", 231, Rarity.RARE, mage.cards.a.AladdinsLamp.class)); cards.add(new SetCardInfo("Aladdin's Ring", 232, Rarity.RARE, mage.cards.a.AladdinsRing.class)); + cards.add(new SetCardInfo("Animate Artifact", 48, Rarity.UNCOMMON, mage.cards.a.AnimateArtifact.class)); cards.add(new SetCardInfo("Animate Dead", 1, Rarity.UNCOMMON, mage.cards.a.AnimateDead.class)); cards.add(new SetCardInfo("Animate Wall", 185, Rarity.RARE, mage.cards.a.AnimateWall.class)); cards.add(new SetCardInfo("Ankh of Mishra", 233, Rarity.RARE, mage.cards.a.AnkhOfMishra.class)); diff --git a/Mage.Sets/src/mage/sets/UnlimitedEdition.java b/Mage.Sets/src/mage/sets/UnlimitedEdition.java index 9e607a279c..22ecb8d97e 100644 --- a/Mage.Sets/src/mage/sets/UnlimitedEdition.java +++ b/Mage.Sets/src/mage/sets/UnlimitedEdition.java @@ -27,6 +27,7 @@ public class UnlimitedEdition extends ExpansionSet { this.ratioBoosterMythic = 0; cards.add(new SetCardInfo("Air Elemental", 47, Rarity.UNCOMMON, mage.cards.a.AirElemental.class)); cards.add(new SetCardInfo("Ancestral Recall", 48, Rarity.RARE, mage.cards.a.AncestralRecall.class)); + cards.add(new SetCardInfo("Animate Artifact", 49, Rarity.UNCOMMON, mage.cards.a.AnimateArtifact.class)); cards.add(new SetCardInfo("Animate Dead", 1, Rarity.UNCOMMON, mage.cards.a.AnimateDead.class)); cards.add(new SetCardInfo("Animate Wall", 185, Rarity.RARE, mage.cards.a.AnimateWall.class)); cards.add(new SetCardInfo("Ankh of Mishra", 231, Rarity.RARE, mage.cards.a.AnkhOfMishra.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/EquippedMatchesFilterCondition.java b/Mage/src/main/java/mage/abilities/condition/common/EquippedMatchesFilterCondition.java index 10994ad989..dfcb7ad0f5 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/EquippedMatchesFilterCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/EquippedMatchesFilterCondition.java @@ -30,7 +30,7 @@ package mage.abilities.condition.common; import mage.abilities.Ability; import mage.abilities.condition.Condition; import mage.constants.Zone; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -42,9 +42,9 @@ import mage.game.permanent.Permanent; */ public class EquippedMatchesFilterCondition implements Condition { - private final FilterCreaturePermanent filter; + private final FilterPermanent filter; - public EquippedMatchesFilterCondition(FilterCreaturePermanent filter) { + public EquippedMatchesFilterCondition(FilterPermanent filter) { this.filter = filter; } From 70fa4334807e109636a5e9937b552ddb58580718 Mon Sep 17 00:00:00 2001 From: MTGfan Date: Sat, 3 Dec 2016 21:48:44 -0500 Subject: [PATCH 3/5] Power Surge ToDo: count untapped land at beginning of turn --- Mage.Sets/src/mage/cards/p/PowerSurge.java | 101 ++++++++++++++++++ Mage.Sets/src/mage/sets/FourthEdition.java | 1 + .../src/mage/sets/LimitedEditionAlpha.java | 1 + .../src/mage/sets/LimitedEditionBeta.java | 1 + Mage.Sets/src/mage/sets/RevisedEdition.java | 1 + Mage.Sets/src/mage/sets/UnlimitedEdition.java | 1 + ...FilterControlledUntappedLandPermanent.java | 61 +++++++++++ 7 files changed, 167 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PowerSurge.java create mode 100644 Mage/src/main/java/mage/filter/common/FilterControlledUntappedLandPermanent.java diff --git a/Mage.Sets/src/mage/cards/p/PowerSurge.java b/Mage.Sets/src/mage/cards/p/PowerSurge.java new file mode 100644 index 0000000000..09d5330b84 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PowerSurge.java @@ -0,0 +1,101 @@ +/* + * 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.p; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.common.FilterControlledUntappedLandPermanent; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author MTGfan + */ +public class PowerSurge extends CardImpl { + + public PowerSurge(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{R}{R}"); + + + // At the beginning of each player's upkeep, Power Surge deals X damage to that player, where X is the number of untapped lands he or she controlled at the beginning of this turn. + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new PowerSurgeDamageEffect(), TargetController.ANY, false, true)); + } + + public PowerSurge(final PowerSurge card) { + super(card); + } + + @Override + public PowerSurge copy() { + return new PowerSurge(this); + } +} + +class PowerSurgeDamageEffect extends OneShotEffect{ + + public PowerSurgeDamageEffect() + { + super(Outcome.Damage); + } + + public PowerSurgeDamageEffect(PowerSurgeDamageEffect copy) + { + super(copy); + } + + @Override + public String getText(Mode mode) { + return "{this} deals X damage to that player where X is the number of untapped lands he or she controlled at the beginning of this turn"; + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(targetPointer.getFirst(game, source)); + if (player != null) { + int damage = game.getBattlefield().getAllActivePermanents(new FilterControlledUntappedLandPermanent(), targetPointer.getFirst(game, source), game).size(); + player.damage(damage, source.getSourceId(), game, false, true); + return true; + } + return false; + } + + @Override + public PowerSurgeDamageEffect copy() { + return new PowerSurgeDamageEffect(this); + } +} diff --git a/Mage.Sets/src/mage/sets/FourthEdition.java b/Mage.Sets/src/mage/sets/FourthEdition.java index 1d254e51db..af3cf35def 100644 --- a/Mage.Sets/src/mage/sets/FourthEdition.java +++ b/Mage.Sets/src/mage/sets/FourthEdition.java @@ -284,6 +284,7 @@ public class FourthEdition extends ExpansionSet { cards.add(new SetCardInfo("Plains", 187, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Plains", 188, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Power Sink", 93, Rarity.COMMON, mage.cards.p.PowerSink.class)); + cards.add(new SetCardInfo("Power Surge", 234, Rarity.RARE, mage.cards.p.PowerSurge.class)); cards.add(new SetCardInfo("Pradesh Gypsies", 149, Rarity.COMMON, mage.cards.p.PradeshGypsies.class)); cards.add(new SetCardInfo("Primal Clay", 360, Rarity.RARE, mage.cards.p.PrimalClay.class)); cards.add(new SetCardInfo("Prodigal Sorcerer", 94, Rarity.COMMON, mage.cards.p.ProdigalSorcerer.class)); diff --git a/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java b/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java index 08d5f7b536..b5256b4454 100644 --- a/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java +++ b/Mage.Sets/src/mage/sets/LimitedEditionAlpha.java @@ -202,6 +202,7 @@ public class LimitedEditionAlpha extends ExpansionSet { cards.add(new SetCardInfo("Plains", 286, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Plateau", 287, Rarity.RARE, mage.cards.p.Plateau.class)); cards.add(new SetCardInfo("Power Sink", 73, Rarity.COMMON, mage.cards.p.PowerSink.class)); + cards.add(new SetCardInfo("Power Surge", 168, Rarity.RARE, mage.cards.p.PowerSurge.class)); cards.add(new SetCardInfo("Prodigal Sorcerer", 74, Rarity.COMMON, mage.cards.p.ProdigalSorcerer.class)); cards.add(new SetCardInfo("Psionic Blast", 75, Rarity.UNCOMMON, mage.cards.p.PsionicBlast.class)); cards.add(new SetCardInfo("Psychic Venom", 76, Rarity.COMMON, mage.cards.p.PsychicVenom.class)); diff --git a/Mage.Sets/src/mage/sets/LimitedEditionBeta.java b/Mage.Sets/src/mage/sets/LimitedEditionBeta.java index cf1830d416..b44c1a95cb 100644 --- a/Mage.Sets/src/mage/sets/LimitedEditionBeta.java +++ b/Mage.Sets/src/mage/sets/LimitedEditionBeta.java @@ -207,6 +207,7 @@ public class LimitedEditionBeta extends ExpansionSet { cards.add(new SetCardInfo("Plains", 291, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Plateau", 292, Rarity.RARE, mage.cards.p.Plateau.class)); cards.add(new SetCardInfo("Power Sink", 73, Rarity.COMMON, mage.cards.p.PowerSink.class)); + cards.add(new SetCardInfo("Power Surge", 169, Rarity.RARE, mage.cards.p.PowerSurge.class)); cards.add(new SetCardInfo("Prodigal Sorcerer", 74, Rarity.COMMON, mage.cards.p.ProdigalSorcerer.class)); cards.add(new SetCardInfo("Psionic Blast", 75, Rarity.UNCOMMON, mage.cards.p.PsionicBlast.class)); cards.add(new SetCardInfo("Psychic Venom", 76, Rarity.COMMON, mage.cards.p.PsychicVenom.class)); diff --git a/Mage.Sets/src/mage/sets/RevisedEdition.java b/Mage.Sets/src/mage/sets/RevisedEdition.java index 9ae4314c5a..255f01dd45 100644 --- a/Mage.Sets/src/mage/sets/RevisedEdition.java +++ b/Mage.Sets/src/mage/sets/RevisedEdition.java @@ -215,6 +215,7 @@ public class RevisedEdition extends ExpansionSet { cards.add(new SetCardInfo("Plains", 295, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Plateau", 296, Rarity.RARE, mage.cards.p.Plateau.class)); cards.add(new SetCardInfo("Power Sink", 74, Rarity.COMMON, mage.cards.p.PowerSink.class)); + cards.add(new SetCardInfo("Power Surge", 169, Rarity.RARE, mage.cards.p.PowerSurge.class)); cards.add(new SetCardInfo("Primal Clay", 271, Rarity.RARE, mage.cards.p.PrimalClay.class)); cards.add(new SetCardInfo("Prodigal Sorcerer", 75, Rarity.COMMON, mage.cards.p.ProdigalSorcerer.class)); cards.add(new SetCardInfo("Psychic Venom", 76, Rarity.COMMON, mage.cards.p.PsychicVenom.class)); diff --git a/Mage.Sets/src/mage/sets/UnlimitedEdition.java b/Mage.Sets/src/mage/sets/UnlimitedEdition.java index 22ecb8d97e..c85b4ee1b2 100644 --- a/Mage.Sets/src/mage/sets/UnlimitedEdition.java +++ b/Mage.Sets/src/mage/sets/UnlimitedEdition.java @@ -207,6 +207,7 @@ public class UnlimitedEdition extends ExpansionSet { cards.add(new SetCardInfo("Plains", 291, Rarity.LAND, mage.cards.basiclands.Plains.class, new CardGraphicInfo(null, true))); cards.add(new SetCardInfo("Plateau", 292, Rarity.RARE, mage.cards.p.Plateau.class)); cards.add(new SetCardInfo("Power Sink", 73, Rarity.COMMON, mage.cards.p.PowerSink.class)); + cards.add(new SetCardInfo("Power Surge", 168, Rarity.RARE, mage.cards.p.PowerSurge.class)); cards.add(new SetCardInfo("Prodigal Sorcerer", 74, Rarity.COMMON, mage.cards.p.ProdigalSorcerer.class)); cards.add(new SetCardInfo("Psionic Blast", 75, Rarity.UNCOMMON, mage.cards.p.PsionicBlast.class)); cards.add(new SetCardInfo("Psychic Venom", 76, Rarity.COMMON, mage.cards.p.PsychicVenom.class)); diff --git a/Mage/src/main/java/mage/filter/common/FilterControlledUntappedLandPermanent.java b/Mage/src/main/java/mage/filter/common/FilterControlledUntappedLandPermanent.java new file mode 100644 index 0000000000..20c4a5ac1c --- /dev/null +++ b/Mage/src/main/java/mage/filter/common/FilterControlledUntappedLandPermanent.java @@ -0,0 +1,61 @@ +/* + * 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.filter.common; + +import mage.constants.CardType; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.permanent.TappedPredicate; + +/** + * + * @author MTGfan + */ +public class FilterControlledUntappedLandPermanent extends FilterControlledPermanent { + + public FilterControlledUntappedLandPermanent() { + this("untapped land you control"); + } + + public FilterControlledUntappedLandPermanent(String name) { + super(name); + this.add(new CardTypePredicate(CardType.LAND)); + this.add(Predicates.not(new TappedPredicate())); + } + + public FilterControlledUntappedLandPermanent(final FilterControlledUntappedLandPermanent filter) { + super(filter); + } + + @Override + public FilterControlledUntappedLandPermanent copy() { + return new FilterControlledUntappedLandPermanent(this); + } + +} From 90aec7c5174b05539c3c24d8858e4e4c040eccc4 Mon Sep 17 00:00:00 2001 From: MTGfan Date: Thu, 8 Dec 2016 22:38:17 -0500 Subject: [PATCH 4/5] Changes to Consecrate Land and Power Surge both not working yet. --- .../src/mage/cards/c/ConsecrateLand.java | 6 +- Mage.Sets/src/mage/cards/p/PowerSurge.java | 7 +- ...UntappedLandsAtBeginningOfTurnWatcher.java | 90 +++++++++++++++++++ 3 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 Mage/src/main/java/mage/watchers/common/UntappedLandsAtBeginningOfTurnWatcher.java diff --git a/Mage.Sets/src/mage/cards/c/ConsecrateLand.java b/Mage.Sets/src/mage/cards/c/ConsecrateLand.java index 3fa4153242..0ac0892f80 100644 --- a/Mage.Sets/src/mage/cards/c/ConsecrateLand.java +++ b/Mage.Sets/src/mage/cards/c/ConsecrateLand.java @@ -30,7 +30,7 @@ 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.ContinuousEffectImpl; import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.CantBeEnchantedSourceEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; @@ -90,7 +90,7 @@ public class ConsecrateLand extends CardImpl { // 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 { +class ConsecrateLandEffect extends ContinuousEffectImpl { private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent(); @@ -99,7 +99,7 @@ class ConsecrateLandEffect extends OneShotEffect { } public ConsecrateLandEffect() { - super(Outcome.Benefit); + super(Duration.WhileOnBattlefield, Outcome.Benefit); } public ConsecrateLandEffect(final ConsecrateLandEffect effect) { diff --git a/Mage.Sets/src/mage/cards/p/PowerSurge.java b/Mage.Sets/src/mage/cards/p/PowerSurge.java index 09d5330b84..1eb7bc9cfc 100644 --- a/Mage.Sets/src/mage/cards/p/PowerSurge.java +++ b/Mage.Sets/src/mage/cards/p/PowerSurge.java @@ -38,9 +38,9 @@ import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.common.FilterControlledUntappedLandPermanent; import mage.game.Game; import mage.players.Player; +import mage.watchers.common.UntappedLandsAtBeginningOfTurnWatcher; /** * @@ -53,7 +53,7 @@ public class PowerSurge extends CardImpl { // At the beginning of each player's upkeep, Power Surge deals X damage to that player, where X is the number of untapped lands he or she controlled at the beginning of this turn. - this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new PowerSurgeDamageEffect(), TargetController.ANY, false, true)); + this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new PowerSurgeDamageEffect(), TargetController.ANY, false, true), new UntappedLandsAtBeginningOfTurnWatcher()); } public PowerSurge(final PowerSurge card) { @@ -87,7 +87,8 @@ class PowerSurgeDamageEffect extends OneShotEffect{ public boolean apply(Game game, Ability source) { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { - int damage = game.getBattlefield().getAllActivePermanents(new FilterControlledUntappedLandPermanent(), targetPointer.getFirst(game, source), game).size(); + UntappedLandsAtBeginningOfTurnWatcher watcher = (UntappedLandsAtBeginningOfTurnWatcher) game.getState().getWatchers().get("UntappedLandsAtBeginningOfTurn"); + int damage = watcher.getUntappedLandCount(targetPointer.getFirst(game, source)); player.damage(damage, source.getSourceId(), game, false, true); return true; } diff --git a/Mage/src/main/java/mage/watchers/common/UntappedLandsAtBeginningOfTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/UntappedLandsAtBeginningOfTurnWatcher.java new file mode 100644 index 0000000000..14a676d9c7 --- /dev/null +++ b/Mage/src/main/java/mage/watchers/common/UntappedLandsAtBeginningOfTurnWatcher.java @@ -0,0 +1,90 @@ +/* + * 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.watchers.common; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import mage.constants.WatcherScope; +import mage.filter.common.FilterControlledUntappedLandPermanent; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.watchers.Watcher; + +/** + * + * @author MTGfan + */ +public class UntappedLandsAtBeginningOfTurnWatcher extends Watcher { + + private final Map untappedLandCount = new HashMap<>(); + + public UntappedLandsAtBeginningOfTurnWatcher() { + super("UntappedLandsAtBeginningOfTurn", WatcherScope.GAME); + } + + public UntappedLandsAtBeginningOfTurnWatcher(final UntappedLandsAtBeginningOfTurnWatcher watcher) { + super(watcher); + for (Entry entry : watcher.untappedLandCount.entrySet()) { + untappedLandCount.put(entry.getKey(), entry.getValue()); + } + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.BEGINNING_PHASE + && game.getPhase() != null) { + UUID playerId = event.getPlayerId(); + if (playerId != null) { + Integer amount = game.getBattlefield().getAllActivePermanents(new FilterControlledUntappedLandPermanent(), playerId, game).size(); + + untappedLandCount.put(playerId, amount); + } + } + } + + public int getUntappedLandCount(UUID playerId) { + Integer amount = untappedLandCount.get(playerId); + if (amount != null) { + return amount; + } + return 0; + } + + @Override + public void reset() { + untappedLandCount.clear(); + } + + @Override + public UntappedLandsAtBeginningOfTurnWatcher copy() { + return new UntappedLandsAtBeginningOfTurnWatcher(this); + } +} From 0fe80503d78a6083ad9a6e6aad320b911796529c Mon Sep 17 00:00:00 2001 From: MTGfan Date: Thu, 8 Dec 2016 22:43:01 -0500 Subject: [PATCH 5/5] Typo Consecrate Land ability2 was not ability2 in the add line --- Mage.Sets/src/mage/cards/c/ConsecrateLand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/c/ConsecrateLand.java b/Mage.Sets/src/mage/cards/c/ConsecrateLand.java index 0ac0892f80..f9f34bb309 100644 --- a/Mage.Sets/src/mage/cards/c/ConsecrateLand.java +++ b/Mage.Sets/src/mage/cards/c/ConsecrateLand.java @@ -75,7 +75,7 @@ public class ConsecrateLand extends CardImpl { 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); + this.addAbility(ability2); } public ConsecrateLand(final ConsecrateLand card) {