diff --git a/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java b/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java index a4bbe3f58f3..d9590de8ffa 100644 --- a/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java +++ b/Mage.Sets/src/mage/sets/fatereforged/TorrentElemental.java @@ -33,7 +33,9 @@ import mage.abilities.Ability; import mage.abilities.common.ActivateAsSorceryActivatedAbility; import mage.abilities.common.AttacksTriggeredAbility; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.Card; import mage.cards.CardImpl; @@ -44,7 +46,6 @@ import mage.constants.SetTargetPointer; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -63,8 +64,9 @@ public class TorrentElemental extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); // Whenever Torrent Elemental attacks, tap all creatures defending player controls. - this.addAbility(new AttacksTriggeredAbility(new TorrentElementalEffect(), false, null, SetTargetPointer.PLAYER)); - + Effect effect = new TapAllTargetPlayerControlsEffect(new FilterCreaturePermanent()); + effect.setText("tap all creatures defending player controls."); + this.addAbility(new AttacksTriggeredAbility(effect, false, null, SetTargetPointer.PLAYER)); // {3}{B/G}{B/G}: Put Torrent Elemental from exile onto the battlefield tapped. Activate this ability only any time you could cast a sorcery. Ability ability = new ActivateAsSorceryActivatedAbility(Zone.EXILED, new ReturnSourceFromExileToBattlefieldEffect(true), new ManaCostsImpl("{3}{B/G}{B/G}")); this.addAbility(ability); @@ -81,31 +83,6 @@ public class TorrentElemental extends CardImpl { } } -class TorrentElementalEffect extends OneShotEffect { - - public TorrentElementalEffect() { - super(Outcome.Tap); - this.staticText = "tap all creatures defending player controls"; - } - - public TorrentElementalEffect(final TorrentElementalEffect effect) { - super(effect); - } - - @Override - public TorrentElementalEffect copy() { - return new TorrentElementalEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), getTargetPointer().getFirst(game, source), game)) { - permanent.tap(game); - } - return true; - } -} - class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect { private boolean tapped; @@ -172,4 +149,4 @@ class ReturnSourceFromExileToBattlefieldEffect extends OneShotEffect { staticText = sb.toString(); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/invasion/TectonicInstability.java b/Mage.Sets/src/mage/sets/invasion/TectonicInstability.java new file mode 100644 index 00000000000..5cbdd9b6bed --- /dev/null +++ b/Mage.Sets/src/mage/sets/invasion/TectonicInstability.java @@ -0,0 +1,65 @@ +/* + * 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.sets.invasion; + +import java.util.UUID; +import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; +import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect; +import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.SetTargetPointer; +import mage.constants.Zone; +import mage.filter.common.FilterLandPermanent; + +/** + * + * @author LoneFox + + */ +public class TectonicInstability extends CardImpl { + + public TectonicInstability(UUID ownerId) { + super(ownerId, 173, "Tectonic Instability", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}"); + this.expansionSetCode = "INV"; + + // Whenever a land enters the battlefield, tap all lands its controller controls. + this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, + new TapAllTargetPlayerControlsEffect(new FilterLandPermanent()), new FilterLandPermanent(), + false, SetTargetPointer.PLAYER, "Whenever a land enters the battlefield, tap all lands its controller controls.")); + } + + public TectonicInstability(final TectonicInstability card) { + super(card); + } + + @Override + public TectonicInstability copy() { + return new TectonicInstability(this); + } +} diff --git a/Mage.Sets/src/mage/sets/limitedalpha/ManaShort.java b/Mage.Sets/src/mage/sets/limitedalpha/ManaShort.java index 68a31f8db1c..9a1f38eec6e 100644 --- a/Mage.Sets/src/mage/sets/limitedalpha/ManaShort.java +++ b/Mage.Sets/src/mage/sets/limitedalpha/ManaShort.java @@ -27,16 +27,14 @@ */ package mage.sets.limitedalpha; -import java.util.List; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; import mage.filter.common.FilterLandPermanent; -import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -52,7 +50,6 @@ public class ManaShort extends CardImpl { super(ownerId, 66, "Mana Short", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{2}{U}"); this.expansionSetCode = "LEA"; - // Tap all lands target player controls and empty his or her mana pool. this.getSpellAbility().addEffect(new ManaShortEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); @@ -68,13 +65,13 @@ public class ManaShort extends CardImpl { } } -class ManaShortEffect extends OneShotEffect { +class ManaShortEffect extends TapAllTargetPlayerControlsEffect { public ManaShortEffect() { - super(Outcome.Detriment); + super(new FilterLandPermanent("lands")); staticText = "Tap all lands target player controls and empty his or her mana pool"; } - + public ManaShortEffect(final ManaShortEffect effect) { super(effect); } @@ -83,24 +80,15 @@ class ManaShortEffect extends OneShotEffect { public ManaShortEffect copy() { return new ManaShortEffect(this); } - + @Override public boolean apply(Game game, Ability source) { Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { - FilterLandPermanent filter = new FilterLandPermanent(); - filter.add(new ControllerIdPredicate(targetPlayer.getId())); - - List lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); - for (Permanent land : lands) { - land.tap(game); - } - + if(targetPlayer != null) { + super.apply(game, source); targetPlayer.getManaPool().emptyPool(game); - return true; } return false; } - } diff --git a/Mage.Sets/src/mage/sets/lorwyn/MistbindClique.java b/Mage.Sets/src/mage/sets/lorwyn/MistbindClique.java index 5eaf9d8f525..3809f1350bc 100644 --- a/Mage.Sets/src/mage/sets/lorwyn/MistbindClique.java +++ b/Mage.Sets/src/mage/sets/lorwyn/MistbindClique.java @@ -27,14 +27,13 @@ */ package mage.sets.lorwyn; -import java.util.List; import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.ZoneChangeTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect; import mage.abilities.keyword.ChampionAbility; import mage.abilities.keyword.FlashAbility; import mage.abilities.keyword.FlyingAbility; @@ -44,11 +43,9 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterLandPermanent; -import mage.filter.predicate.permanent.ControllerIdPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; -import mage.game.permanent.Permanent; import mage.target.TargetPlayer; /** @@ -92,14 +89,14 @@ class MistbindCliqueAbility extends ZoneChangeTriggeredAbility { public MistbindCliqueAbility() { // ability has to trigger independant where the source object is now - super(Zone.ALL, Zone.BATTLEFIELD, Zone.EXILED, new MistbindCliqueTapEffect(), "When a Faerie is championed with {this}, ", false); + super(Zone.ALL, Zone.BATTLEFIELD, Zone.EXILED, new TapAllTargetPlayerControlsEffect(new FilterLandPermanent("lands")), "When a Faerie is championed with {this}, ", false); this.addTarget(new TargetPlayer()); } public MistbindCliqueAbility(MistbindCliqueAbility ability) { super(ability); } - + @Override public MistbindCliqueAbility copy() { return new MistbindCliqueAbility(this); @@ -113,44 +110,11 @@ class MistbindCliqueAbility extends ZoneChangeTriggeredAbility { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getSourceId() != null && event.getSourceId().equals(getSourceId())) { - ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; if (zEvent.getTarget() != null && zEvent.getTarget().hasSubtype("Faerie")) { return true; - } + } } return false; } } - -class MistbindCliqueTapEffect extends OneShotEffect { - - public MistbindCliqueTapEffect() { - super(Outcome.Tap); - staticText = "tap all lands target player controls"; - } - - public MistbindCliqueTapEffect(final MistbindCliqueTapEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - if (source.getFirstTarget() == null) { - return false; - } - - FilterLandPermanent filter = new FilterLandPermanent(); - filter.add(new ControllerIdPredicate(source.getFirstTarget())); - - List lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); - for (Permanent land : lands) { - land.tap(game); - } - return true; - } - - @Override - public MistbindCliqueTapEffect copy() { - return new MistbindCliqueTapEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java index 0a6ed85ffc3..70999f3afea 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/DawnglareInvoker.java @@ -27,23 +27,18 @@ */ package mage.sets.riseoftheeldrazi; -import java.util.List; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -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.OneShotEffect; +import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.ControllerIdPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPlayer; /** @@ -63,7 +58,7 @@ public class DawnglareInvoker extends CardImpl { this.addAbility(FlyingAbility.getInstance()); SimpleActivatedAbility ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, - new DawnglareInvokerEffect(), + new TapAllTargetPlayerControlsEffect(new FilterCreaturePermanent("creatures")), new ManaCostsImpl("{8}")); ability.addTarget(new TargetPlayer()); this.addAbility(ability); @@ -78,36 +73,3 @@ public class DawnglareInvoker extends CardImpl { return new DawnglareInvoker(this); } } - -class DawnglareInvokerEffect extends OneShotEffect { - - public DawnglareInvokerEffect() { - super(Outcome.Tap); - staticText = "Tap all creatures target player controls"; - } - - public DawnglareInvokerEffect(final DawnglareInvokerEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - if (source.getFirstTarget() == null) { - return false; - } - - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.add(new ControllerIdPredicate(source.getFirstTarget())); - - List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); - for (Permanent creature : creatures) { - creature.tap(game); - } - return true; - } - - @Override - public DawnglareInvokerEffect copy() { - return new DawnglareInvokerEffect(this); - } -} diff --git a/Mage.Sets/src/mage/sets/shardsofalara/NayaCharm.java b/Mage.Sets/src/mage/sets/shardsofalara/NayaCharm.java index ecca5d6752a..cc48836bb53 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/NayaCharm.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/NayaCharm.java @@ -29,19 +29,14 @@ package mage.sets.shardsofalara; import java.util.List; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.abilities.Ability; import mage.abilities.Mode; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.ReturnToHandTargetEffect; +import mage.abilities.effects.common.TapAllTargetPlayerControlsEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.permanent.ControllerIdPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPlayer; import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCreaturePermanent; @@ -56,7 +51,6 @@ public class NayaCharm extends CardImpl { super(ownerId, 180, "Naya Charm", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{R}{G}{W}"); this.expansionSetCode = "ALA"; - // Choose one - Naya Charm deals 3 damage to target creature; this.getSpellAbility().addEffect(new DamageTargetEffect(3)); this.getSpellAbility().addTarget(new TargetCreaturePermanent()); @@ -67,7 +61,7 @@ public class NayaCharm extends CardImpl { this.getSpellAbility().addMode(mode); // or tap all creatures target player controls. mode = new Mode(); - mode.getEffects().add(new NayaCharmEffect()); + mode.getEffects().add(new TapAllTargetPlayerControlsEffect(new FilterCreaturePermanent("creatures"))); mode.getTargets().add(new TargetPlayer()); this.getSpellAbility().addMode(mode); } @@ -81,36 +75,3 @@ public class NayaCharm extends CardImpl { return new NayaCharm(this); } } - -class NayaCharmEffect extends OneShotEffect { - - public NayaCharmEffect() { - super(Outcome.Tap); - staticText = "Tap all creatures target player controls"; - } - - public NayaCharmEffect(final NayaCharmEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - if (source.getFirstTarget() == null) { - return false; - } - - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.add(new ControllerIdPredicate(source.getFirstTarget())); - - List creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); - for (Permanent creature : creatures) { - creature.tap(game); - } - return true; - } - - @Override - public NayaCharmEffect copy() { - return new NayaCharmEffect(this); - } -} diff --git a/Mage/src/mage/abilities/effects/common/TapAllTargetPlayerControlsEffect.java b/Mage/src/mage/abilities/effects/common/TapAllTargetPlayerControlsEffect.java new file mode 100644 index 00000000000..0ad564a7211 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/TapAllTargetPlayerControlsEffect.java @@ -0,0 +1,86 @@ +/* + * 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 java.util.List; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.predicate.permanent.ControllerIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author LoneFox + */ +public class TapAllTargetPlayerControlsEffect extends OneShotEffect { + + private FilterPermanent filter; + + public TapAllTargetPlayerControlsEffect(FilterPermanent filter) { + super(Outcome.Tap); + this.filter = filter; + } + + public TapAllTargetPlayerControlsEffect(final TapAllTargetPlayerControlsEffect effect) { + super(effect); + filter = effect.filter.copy(); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(targetPointer.getFirst(game, source)); + if(player != null) { + filter.add(new ControllerIdPredicate(player.getId())); + List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); + for(Permanent p : permanents) { + p.tap(game); + } + return true; + } + return false; + } + + @Override + public TapAllTargetPlayerControlsEffect copy() { + return new TapAllTargetPlayerControlsEffect(this); + } + + @Override + public String getText(Mode mode) { + if(staticText != null && !staticText.isEmpty()) { + return staticText; + } + return "tap all " + filter.getMessage() + " target player controls"; + } +}