use ReturnToHandFromBattlefieldAllEffect

This commit is contained in:
Neil Gentleman 2016-10-16 15:47:10 -07:00
parent 24c5513d86
commit 51f0b551c8
5 changed files with 14 additions and 139 deletions

View file

@ -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}")));

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}