diff --git a/Mage.Sets/src/mage/cards/d/DevastationTide.java b/Mage.Sets/src/mage/cards/d/DevastationTide.java index 5f405d9122e..413a35a3241 100644 --- a/Mage.Sets/src/mage/cards/d/DevastationTide.java +++ b/Mage.Sets/src/mage/cards/d/DevastationTide.java @@ -46,7 +46,7 @@ public class DevastationTide extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{U}"); // Return all nonland permanents to their owners' hands. - this.getSpellAbility().addEffect(new ReturnToHandFromBattlefieldAllEffect(new FilterNonlandPermanent())); + this.getSpellAbility().addEffect(new ReturnToHandFromBattlefieldAllEffect(new FilterNonlandPermanent("nonland permanents"))); // Miracle {1}{U} this.addAbility(new MiracleAbility(this, new ManaCostsImpl("{1}{U}"))); diff --git a/Mage.Sets/src/mage/cards/e/Evacuation.java b/Mage.Sets/src/mage/cards/e/Evacuation.java index 1285d5ef9e9..b6eed7398d2 100644 --- a/Mage.Sets/src/mage/cards/e/Evacuation.java +++ b/Mage.Sets/src/mage/cards/e/Evacuation.java @@ -29,16 +29,11 @@ package mage.cards.e; import java.util.UUID; +import mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect; import mage.constants.CardType; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -51,7 +46,7 @@ public class Evacuation extends CardImpl { // Return all creatures to their owners' hands. - this.getSpellAbility().addEffect(new EvacuationEffect()); + this.getSpellAbility().addEffect(new ReturnToHandFromBattlefieldAllEffect(new FilterCreaturePermanent("creatures"))); } public Evacuation(final Evacuation card) { @@ -63,32 +58,3 @@ public class Evacuation extends CardImpl { return new Evacuation(this); } } - - -class EvacuationEffect extends OneShotEffect { - - - - public EvacuationEffect() { - super(Outcome.ReturnToHand); - staticText = "Return all creatures to their owners' hands"; - } - - public EvacuationEffect(final EvacuationEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) { - creature.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - return true; - } - - @Override - public EvacuationEffect copy() { - return new EvacuationEffect(this); - } -} - diff --git a/Mage.Sets/src/mage/cards/h/Hibernation.java b/Mage.Sets/src/mage/cards/h/Hibernation.java index f7e0634cef3..4d03f9208ae 100644 --- a/Mage.Sets/src/mage/cards/h/Hibernation.java +++ b/Mage.Sets/src/mage/cards/h/Hibernation.java @@ -29,18 +29,13 @@ package mage.cards.h; import java.util.UUID; +import mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect; import mage.constants.CardType; import mage.ObjectColor; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -48,12 +43,17 @@ import mage.game.permanent.Permanent; */ public class Hibernation extends CardImpl { + private static final FilterPermanent filter = new FilterPermanent("green permanents"); + static { + filter.add(new ColorPredicate(ObjectColor.GREEN)); + } + public Hibernation(UUID ownerId, CardSetInfo setInfo) { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}"); // Return all green permanents to their owners' hands. - this.getSpellAbility().addEffect(new HibernationEffect()); + this.getSpellAbility().addEffect(new ReturnToHandFromBattlefieldAllEffect(filter)); } public Hibernation(final Hibernation card) { @@ -65,34 +65,3 @@ public class Hibernation extends CardImpl { return new Hibernation(this); } } - - -class HibernationEffect extends OneShotEffect { - - private static final FilterPermanent filter = new FilterPermanent("green permanents"); - static { - filter.add(new ColorPredicate(ObjectColor.GREEN)); - } - - public HibernationEffect() { - super(Outcome.ReturnToHand); - staticText = "Return all green permanents to their owners' hands"; - } - - public HibernationEffect(final HibernationEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { - permanent.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - return true; - } - - @Override - public HibernationEffect copy() { - return new HibernationEffect(this); - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/r/Rebuild.java b/Mage.Sets/src/mage/cards/r/Rebuild.java index 2e34dcf4612..832edc49adf 100644 --- a/Mage.Sets/src/mage/cards/r/Rebuild.java +++ b/Mage.Sets/src/mage/cards/r/Rebuild.java @@ -29,18 +29,13 @@ package mage.cards.r; import java.util.UUID; +import mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect; import mage.constants.CardType; -import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.CyclingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.common.FilterArtifactPermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -53,7 +48,7 @@ public class Rebuild extends CardImpl { // Return all artifacts to their owners' hands. - this.getSpellAbility().addEffect(new RebuildEffect()); + this.getSpellAbility().addEffect(new ReturnToHandFromBattlefieldAllEffect(new FilterArtifactPermanent("artifacts"))); // Cycling {2} this.addAbility(new CyclingAbility(new ManaCostsImpl("{2}"))); } @@ -67,28 +62,3 @@ public class Rebuild extends CardImpl { return new Rebuild(this); } } - -class RebuildEffect extends OneShotEffect { - public RebuildEffect() { - super(Outcome.ReturnToHand); - staticText = "Return all artifacts to their owner's hand."; - } - - public RebuildEffect(final RebuildEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), source.getSourceId(), game)) { - creature.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - return true; - } - - @Override - public RebuildEffect copy() { - return new RebuildEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/cards/s/Sunder.java b/Mage.Sets/src/mage/cards/s/Sunder.java index f6f2f4cd73e..c759c0578bf 100644 --- a/Mage.Sets/src/mage/cards/s/Sunder.java +++ b/Mage.Sets/src/mage/cards/s/Sunder.java @@ -28,16 +28,11 @@ package mage.cards.s; import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.common.FilterLandPermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -49,7 +44,7 @@ public class Sunder extends CardImpl { super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}{U}"); // Return all lands to their owners' hands. - this.getSpellAbility().addEffect(new SunderEffect()); + this.getSpellAbility().addEffect(new ReturnToHandFromBattlefieldAllEffect(new FilterLandPermanent("lands"))); } public Sunder(final Sunder card) { @@ -61,28 +56,3 @@ public class Sunder extends CardImpl { return new Sunder(this); } } - -class SunderEffect extends OneShotEffect { - - public SunderEffect() { - super(Outcome.ReturnToHand); - staticText = "Return all lands to their owners' hands"; - } - - public SunderEffect(final SunderEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - for (Permanent land : game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game)) { - land.moveToZone(Zone.HAND, source.getSourceId(), game, true); - } - return true; - } - - @Override - public SunderEffect copy() { - return new SunderEffect(this); - } -}