mirror of
https://github.com/correl/mage.git
synced 2024-11-16 03:00:12 +00:00
[minor] rework of Toils of Night and Day (was not rule conform) and Void (use filter.match instead of direct compare).
This commit is contained in:
parent
d32600dbb1
commit
ce771b422b
2 changed files with 21 additions and 27 deletions
|
@ -35,6 +35,7 @@ import mage.Constants.Rarity;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.filter.FilterPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -53,8 +54,7 @@ public class ToilsOfNightAndDay extends CardImpl<ToilsOfNightAndDay> {
|
||||||
this.color.setBlue(true);
|
this.color.setBlue(true);
|
||||||
// You may tap or untap target permanent, then you may tap or untap another target permanent.
|
// You may tap or untap target permanent, then you may tap or untap another target permanent.
|
||||||
this.getSpellAbility().addEffect(new ToilsOfNightAndDayEffect());
|
this.getSpellAbility().addEffect(new ToilsOfNightAndDayEffect());
|
||||||
this.getSpellAbility().addTarget(new TargetPermanent());
|
this.getSpellAbility().addTarget(new TargetPermanent(0, 2, new FilterPermanent(), false));
|
||||||
this.getSpellAbility().addTarget(new TargetPermanent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToilsOfNightAndDay(final ToilsOfNightAndDay card) {
|
public ToilsOfNightAndDay(final ToilsOfNightAndDay card) {
|
||||||
|
@ -85,36 +85,21 @@ public class ToilsOfNightAndDay extends CardImpl<ToilsOfNightAndDay> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
for (UUID targetId : source.getTargets().get(0).getTargets()) {
|
||||||
if (permanent != null) {
|
Permanent permanent = game.getPermanent(targetId);
|
||||||
if (permanent.isTapped()) {
|
if (permanent != null) {
|
||||||
if (player.chooseUse(Constants.Outcome.Untap, "Untap that permanent?", game)) {
|
if (player.chooseUse(Constants.Outcome.Tap, new StringBuilder("Tap ").append(permanent.getName()).append("?").toString(), game)) {
|
||||||
result |= permanent.untap(game);
|
permanent.tap(game);
|
||||||
}
|
} else if (player.chooseUse(Constants.Outcome.Untap, new StringBuilder("Untap ").append(permanent.getName()).append("?").toString(), game)) {
|
||||||
} else {
|
permanent.untap(game);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,6 +39,11 @@ import mage.cards.Card;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.choices.ChoiceImpl;
|
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.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
@ -106,11 +111,15 @@ class VoidEffect extends OneShotEffect<VoidEffect> {
|
||||||
permanent.destroy(source.getId(), game, false);
|
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));
|
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
targetPlayer.revealCards("Void", targetPlayer.getHand(), game);
|
targetPlayer.revealCards("Void", targetPlayer.getHand(), game);
|
||||||
for (Card card : targetPlayer.getHand().getCards(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);
|
card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue