From ce771b422b4a36ccc9ca0c1f248aea26c4314b51 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 2 May 2013 16:07:48 +0200 Subject: [PATCH] [minor] rework of Toils of Night and Day (was not rule conform) and Void (use filter.match instead of direct compare). --- .../ToilsOfNightAndDay.java | 37 ++++++------------- Mage.Sets/src/mage/sets/invasion/Void.java | 11 +++++- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/ToilsOfNightAndDay.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/ToilsOfNightAndDay.java index cb556e06b8..ad1512d86a 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/ToilsOfNightAndDay.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/ToilsOfNightAndDay.java @@ -35,6 +35,7 @@ import mage.Constants.Rarity; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; +import mage.filter.FilterPermanent; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -53,8 +54,7 @@ public class ToilsOfNightAndDay extends CardImpl { this.color.setBlue(true); // You may tap or untap target permanent, then you may tap or untap another target permanent. this.getSpellAbility().addEffect(new ToilsOfNightAndDayEffect()); - this.getSpellAbility().addTarget(new TargetPermanent()); - this.getSpellAbility().addTarget(new TargetPermanent()); + this.getSpellAbility().addTarget(new TargetPermanent(0, 2, new FilterPermanent(), false)); } public ToilsOfNightAndDay(final ToilsOfNightAndDay card) { @@ -85,36 +85,21 @@ public class ToilsOfNightAndDay extends CardImpl { @Override public boolean apply(Game game, Ability source) { - boolean result = false; - Player player = game.getPlayer(source.getControllerId()); if (player != null) { - Permanent permanent = game.getPermanent(source.getFirstTarget()); - if (permanent != null) { - if (permanent.isTapped()) { - if (player.chooseUse(Constants.Outcome.Untap, "Untap that permanent?", game)) { - result |= permanent.untap(game); - } - } else { - if (player.chooseUse(Constants.Outcome.Tap, "Tap that permanent?", game)) { - result |= permanent.tap(game); - } - } - } - permanent = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (permanent != null) { - if (permanent.isTapped()) { - if (player.chooseUse(Constants.Outcome.Untap, "Untap that permanent?", game)) { - result |= permanent.untap(game); - } - } else { - if (player.chooseUse(Constants.Outcome.Tap, "Tap that permanent?", game)) { - result |= permanent.tap(game); + for (UUID targetId : source.getTargets().get(0).getTargets()) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null) { + if (player.chooseUse(Constants.Outcome.Tap, new StringBuilder("Tap ").append(permanent.getName()).append("?").toString(), game)) { + permanent.tap(game); + } else if (player.chooseUse(Constants.Outcome.Untap, new StringBuilder("Untap ").append(permanent.getName()).append("?").toString(), game)) { + permanent.untap(game); } } } + return true; } - return result; + return false; } } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/invasion/Void.java b/Mage.Sets/src/mage/sets/invasion/Void.java index c1fa6c874a..2742ab9191 100644 --- a/Mage.Sets/src/mage/sets/invasion/Void.java +++ b/Mage.Sets/src/mage/sets/invasion/Void.java @@ -39,6 +39,11 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.choices.Choice; import mage.choices.ChoiceImpl; +import mage.filter.Filter; +import mage.filter.FilterCard; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -106,11 +111,15 @@ class VoidEffect extends OneShotEffect { permanent.destroy(source.getId(), game, false); } } + FilterCard filterCard = new FilterCard(); + filterCard.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, number)); + filterCard.add(Predicates.not(new CardTypePredicate(CardType.LAND))); + Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); if (targetPlayer != null) { targetPlayer.revealCards("Void", targetPlayer.getHand(), game); for (Card card : targetPlayer.getHand().getCards(game)) { - if (!card.getCardType().contains(CardType.LAND) && card.getManaCost().convertedManaCost() == number) { + if (filterCard.match(card, game)) { card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false); } }