spjspj - Implement Paradoxical Outcome (KLD) (done with addition to SweepEffect)

This commit is contained in:
spjspj 2016-09-08 17:09:47 +10:00
parent 67f29124f8
commit 8cd3ec1135
2 changed files with 92 additions and 2 deletions

View file

@ -32,6 +32,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -48,16 +49,27 @@ import mage.util.CardUtil;
public class SweepEffect extends OneShotEffect {
private final String sweepSubtype;
private FilterPermanent setFilter = null;
public SweepEffect(String sweepSubtype) {
super(Outcome.Benefit);
this.sweepSubtype = sweepSubtype;
this.staticText = "<i>Sweep</i> - Return any number of " + sweepSubtype + (sweepSubtype.endsWith("s") ? "" : "s") + " you control to their owner's hand";
}
public SweepEffect(FilterPermanent filter, String text) {
super(Outcome.Benefit);
this.sweepSubtype = text;
this.staticText = "Return any number of " + text + " you control to their owner's hand";
this.setFilter = filter;
}
public SweepEffect(final SweepEffect effect) {
super(effect);
this.sweepSubtype = effect.sweepSubtype;
this.setFilter = effect.setFilter;
}
@Override
@ -69,8 +81,14 @@ public class SweepEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterPermanent filter = new FilterControlledLandPermanent(new StringBuilder("any number of ").append(sweepSubtype).append("s you control").toString());
filter.add(new SubtypePredicate(sweepSubtype));
FilterPermanent filter;
if (setFilter == null) {
filter = new FilterControlledLandPermanent(new StringBuilder("any number of ").append(sweepSubtype).append("s you control").toString());
filter.add(new SubtypePredicate(sweepSubtype));
} else {
filter = setFilter;
}
Target target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true);
if (controller.chooseTarget(outcome, target, source, game)) {
game.getState().setValue(CardUtil.getCardZoneString("sweep", source.getSourceId(), game), target.getTargets().size());