diff --git a/Mage/src/mage/abilities/effects/AuraReplacementEffect.java b/Mage/src/mage/abilities/effects/AuraReplacementEffect.java index eb62e657c20..8c4a0e063e9 100644 --- a/Mage/src/mage/abilities/effects/AuraReplacementEffect.java +++ b/Mage/src/mage/abilities/effects/AuraReplacementEffect.java @@ -119,8 +119,8 @@ public class AuraReplacementEffect extends ReplacementEffectImpl { if (targetId == null) { Target target = card.getSpellAbility().getTargets().get(0); enchantCardInGraveyard = target instanceof TargetCardInGraveyard; - if (enchantCardInGraveyard && target != null) { - target.clearChosen(); + if (target != null) { + target.clearChosen(); // neccessary if e.g. aura is blinked multiple times } Player player = game.getPlayer(card.getOwnerId()); Outcome auraOutcome = Outcome.BoostCreature; diff --git a/Mage/src/mage/abilities/keyword/SuspendAbility.java b/Mage/src/mage/abilities/keyword/SuspendAbility.java index 559b9c5c9a4..03b50951133 100644 --- a/Mage/src/mage/abilities/keyword/SuspendAbility.java +++ b/Mage/src/mage/abilities/keyword/SuspendAbility.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.keyword; import java.util.ArrayList; @@ -63,93 +62,97 @@ import mage.players.Player; * * 502.59. Suspend * - * 502.59a Suspend is a keyword that represents three abilities. The first is a static - * ability that functions while the card with suspend is in a player's hand. The second - * and third are triggered abilities that function in the removed-from-the-game zone. - * "Suspend N--[cost]" means "If you could play this card from your hand, you may pay - * [cost] and remove it from the game with N time counters on it. This is a special - * action that doesn't use the stack," and "At the beginning of your upkeep, if this - * card is suspended, remove a time counter from it," and "When the last time counter - * is removed from this card, if it's removed from the game, play it without paying its - * mana cost if able. If you can't, it remains removed from the game. If you play it - * this way and it's a creature, it gains haste until you lose control of it." + * 502.59a Suspend is a keyword that represents three abilities. The first is a + * static ability that functions while the card with suspend is in a player's + * hand. The second and third are triggered abilities that function in the + * removed-from-the-game zone. "Suspend N--[cost]" means "If you could play this + * card from your hand, you may pay [cost] and remove it from the game with N + * time counters on it. This is a special action that doesn't use the stack," + * and "At the beginning of your upkeep, if this card is suspended, remove a + * time counter from it," and "When the last time counter is removed from this + * card, if it's removed from the game, play it without paying its mana cost if + * able. If you can't, it remains removed from the game. If you play it this way + * and it's a creature, it gains haste until you lose control of it." * - * 502.59b A card is "suspended" if it's in the removed-from-the-game zone, has suspend, - * and has a time counter on it. + * 502.59b A card is "suspended" if it's in the removed-from-the-game zone, has + * suspend, and has a time counter on it. * - * 502.59c Playing a spell as an effect of its suspend ability follows the rules for - * paying alternative costs in rules 409.1b and 409.1f-h. + * 502.59c Playing a spell as an effect of its suspend ability follows the rules + * for paying alternative costs in rules 409.1b and 409.1f-h. * - * The phrase "if you could play this card from your hand" checks only for timing - * restrictions and permissions. This includes both what's inherent in the card's - * type (for example, if the card with suspend is a creature, it must be your main - * phase and the stack must be empty) and what's imposed by other abilities, such - * as flash or Meddling Mage's ability. Whether you could actually follow all steps - * in playing the card is irrelevant. If the card is impossible to play due to a - * lack of legal targets or an unpayable mana cost, for example, it may still be - * removed from the game with suspend. + * The phrase "if you could play this card from your hand" checks only for + * timing restrictions and permissions. This includes both what's inherent in + * the card's type (for example, if the card with suspend is a creature, it must + * be your main phase and the stack must be empty) and what's imposed by other + * abilities, such as flash or Meddling Mage's ability. Whether you could + * actually follow all steps in playing the card is irrelevant. If the card is + * impossible to play due to a lack of legal targets or an unpayable mana cost, + * for example, it may still be removed from the game with suspend. * - * Removing a card from the game with its suspend ability is not playing that card. - * This action doesn't use the stack and can't be responded to. + * Removing a card from the game with its suspend ability is not playing that + * card. This action doesn't use the stack and can't be responded to. * * If a spell with suspend has targets, the targets are chosen when the spell is * played, not when it's removed from the game. * - * If the first triggered ability of suspend is countered, no time counter is removed. - * The ability will trigger again during its owner's next upkeep. + * If the first triggered ability of suspend is countered, no time counter is + * removed. The ability will trigger again during its owner's next upkeep. * - * When the last time counter is removed from a suspended card, the second triggered - * ability of suspend will trigger. It doesn't matter why the time counter was removed - * or whose effect removed it. (The _Time Spiral_ reminder text is misleading on this point.) + * When the last time counter is removed from a suspended card, the second + * triggered ability of suspend will trigger. It doesn't matter why the time + * counter was removed or whose effect removed it. (The _Time Spiral_ reminder + * text is misleading on this point.) * - * If the second triggered ability of suspend is countered, the card can't be played. - * It remains in the removed-from-the-game zone without any time counters on it for the - * rest of the game, and it's no longer considered suspended. + * If the second triggered ability of suspend is countered, the card can't be + * played. It remains in the removed-from-the-game zone without any time + * counters on it for the rest of the game, and it's no longer considered + * suspended. * - * If the second triggered ability of suspend resolves, the card's owner must play the - * spell if possible, even if that player doesn't want to. Normal timing considerations - * for the spell are ignored (for example, if the suspended card is a creature and this - * ability resolves during your upkeep, you’re able to play the card), but other play - * restrictions are not ignored. + * If the second triggered ability of suspend resolves, the card's owner must + * play the spell if possible, even if that player doesn't want to. Normal + * timing considerations for the spell are ignored (for example, if the + * suspended card is a creature and this ability resolves during your upkeep, + * you’re able to play the card), but other play restrictions are not ignored. * - * If the second triggered ability of suspend resolves and the suspended card can't be - * played due to a lack of legal targets or a play restriction, for example, it remains - * in the removed-from-the-game zone without any time counters on it for the rest of the - * game, and it's no longer considered suspended. + * If the second triggered ability of suspend resolves and the suspended card + * can't be played due to a lack of legal targets or a play restriction, for + * example, it remains in the removed-from-the-game zone without any time + * counters on it for the rest of the game, and it's no longer considered + * suspended. * - * As the second triggered ability of suspend resolves, if playing the suspended card - * involves an additional cost, the card's owner must pay that cost if able. If he or - * she can't, the card remains removed from the game. If the additional cost includes - * mana, the situation is more complex. If the player has enough mana in his or her mana - * pool to pay the cost, that player must do so. If the player can't possibly pay the - * cost, the card remains removed from the game. However, if the player has the means - * to produce enough mana to pay the cost, then he or she has a choice: The player may - * play the spell, produce mana, and pay the cost. Or the player may choose to play no - * mana abilities, thus making the card impossible to play because the additional mana - * can't be paid. + * As the second triggered ability of suspend resolves, if playing the suspended + * card involves an additional cost, the card's owner must pay that cost if + * able. If he or she can't, the card remains removed from the game. If the + * additional cost includes mana, the situation is more complex. If the player + * has enough mana in his or her mana pool to pay the cost, that player must do + * so. If the player can't possibly pay the cost, the card remains removed from + * the game. However, if the player has the means to produce enough mana to pay + * the cost, then he or she has a choice: The player may play the spell, produce + * mana, and pay the cost. Or the player may choose to play no mana abilities, + * thus making the card impossible to play because the additional mana can't be + * paid. * - * A creature played via suspend comes into play with haste. It still has haste after - * the first turn it's in play as long as the same player controls it. As soon as another - * player takes control of it, it loses haste. + * A creature played via suspend comes into play with haste. It still has haste + * after the first turn it's in play as long as the same player controls it. As + * soon as another player takes control of it, it loses haste. * * * @author LevelX2 * */ - - public class SuspendAbility extends ActivatedAbilityImpl { private String ruleText; private boolean gainedTemporary; /** - * Gives the card the SuspendAbility - * - * @param suspend - amount of time counters, if Integer.MAX_VALUE is set there will be {X} costs and X counters added - * @param cost - null is used for temporary gained suspend ability - * @param card - card that has the suspend ability - */ + * Gives the card the SuspendAbility + * + * @param suspend - amount of time counters, if Integer.MAX_VALUE is set + * there will be {X} costs and X counters added + * @param cost - null is used for temporary gained suspend ability + * @param card - card that has the suspend ability + */ public SuspendAbility(int suspend, ManaCost cost, Card card) { this(suspend, cost, card, false); } @@ -165,16 +168,16 @@ public class SuspendAbility extends ActivatedAbilityImpl { } StringBuilder sb = new StringBuilder("Suspend "); if (cost != null) { - sb.append(suspend == Integer.MAX_VALUE ? "X":suspend).append(" - ").append(cost.getText()); + sb.append(suspend == Integer.MAX_VALUE ? "X" : suspend).append(" - ").append(cost.getText()); if (!shortRule) { sb.append(" (Rather than cast this card from your hand, pay ") - .append(cost.getText()) - .append(" and exile it with ") - .append((suspend == 1 ? "a time counter": (suspend == Integer.MAX_VALUE ? "X time counters": suspend + " time counters"))) - .append(" on it.") - .append(" At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost.") - .append(card.getCardType().contains(CardType.CREATURE)? " If you play it this way and it's a creature, it gains haste until you lose control of it.":"") - .append(")"); + .append(cost.getText()) + .append(" and exile it with ") + .append((suspend == 1 ? "a time counter" : (suspend == Integer.MAX_VALUE ? "X time counters" : suspend + " time counters"))) + .append(" on it.") + .append(" At the beginning of your upkeep, remove a time counter. When the last is removed, cast it without paying its mana cost.") + .append(card.getCardType().contains(CardType.CREATURE) ? " If you play it this way and it's a creature, it gains haste until you lose control of it." : "") + .append(")"); } if (card.getManaCost().isEmpty()) { setRuleAtTheTop(true); @@ -186,8 +189,9 @@ public class SuspendAbility extends ActivatedAbilityImpl { } /** - * Adds suspend to a card that does not have it regularly - * e.g. Epochrasite or added by Jhoira of the Ghitu + * Adds suspend to a card that does not have it regularly e.g. Epochrasite + * or added by Jhoira of the Ghitu + * * @param card * @param source * @param game @@ -229,10 +233,10 @@ public class SuspendAbility extends ActivatedAbilityImpl { @Override public boolean canActivate(UUID playerId, Game game) { MageObject object = game.getObject(sourceId); - return (object.getCardType().contains(CardType.INSTANT) || - object.hasAbility(FlashAbility.getInstance().getId(), game) || - game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game) || - game.canPlaySorcery(playerId)); + return (object.getCardType().contains(CardType.INSTANT) + || object.hasAbility(FlashAbility.getInstance().getId(), game) + || game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game) + || game.canPlaySorcery(playerId)); } @Override @@ -252,11 +256,12 @@ public class SuspendAbility extends ActivatedAbilityImpl { } class SuspendExileEffect extends OneShotEffect { + private int suspend; public SuspendExileEffect(int suspend) { super(Outcome.PutCardInPlay); - this.staticText = new StringBuilder("Suspend ").append(suspend == Integer.MAX_VALUE ? "X":suspend).toString(); + this.staticText = new StringBuilder("Suspend ").append(suspend == Integer.MAX_VALUE ? "X" : suspend).toString(); this.suspend = suspend; } @@ -281,8 +286,9 @@ class SuspendExileEffect extends OneShotEffect { suspend = source.getManaCostsToPay().getX(); } card.addCounters(CounterType.TIME.createInstance(suspend), game); - if (!game.isSimulation()) - game.informPlayers(new StringBuilder(controller.getLogName()).append(" suspends (").append(suspend).append(") ").append(card.getName()).toString()); + if (!game.isSimulation()) { + game.informPlayers(controller.getLogName() + " suspends (" + suspend + ") " + card.getLogName()); + } return true; } } @@ -357,14 +363,14 @@ class SuspendPlayCardEffect extends OneShotEffect { List abilitiesToRemove = new ArrayList<>(); for (Ability ability : card.getAbilities()) { if (ability instanceof SuspendAbility) { - if (((SuspendAbility)ability).isGainedTemporary()) { + if (((SuspendAbility) ability).isGainedTemporary()) { abilitiesToRemove.add(ability); } } } if (!abilitiesToRemove.isEmpty()) { for (Ability ability : card.getAbilities()) { - if (ability instanceof SuspendBeginningOfUpkeepTriggeredAbility || ability instanceof SuspendPlayCardAbility ) { + if (ability instanceof SuspendBeginningOfUpkeepTriggeredAbility || ability instanceof SuspendPlayCardAbility) { abilitiesToRemove.add(ability); } } @@ -434,4 +440,4 @@ class SuspendBeginningOfUpkeepTriggeredAbility extends ConditionalTriggeredAbili public SuspendBeginningOfUpkeepTriggeredAbility copy() { return new SuspendBeginningOfUpkeepTriggeredAbility(this); } -} \ No newline at end of file +} diff --git a/Mage/src/mage/abilities/keyword/VanishingUpkeepAbility.java b/Mage/src/mage/abilities/keyword/VanishingUpkeepAbility.java index 0d7d96b7c57..188ef1bf5a6 100644 --- a/Mage/src/mage/abilities/keyword/VanishingUpkeepAbility.java +++ b/Mage/src/mage/abilities/keyword/VanishingUpkeepAbility.java @@ -31,14 +31,14 @@ public class VanishingUpkeepAbility extends BeginningOfUpkeepTriggeredAbility { @Override public String getRule() { - return new StringBuilder("Vanishing ") - .append(vanishingAmount) - .append(" (This permanent enters the battlefield with ").append(CardUtil.numberToText(vanishingAmount)) - .append(" time counters on it. At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)").toString(); + return "Vanishing " + vanishingAmount + + " (This permanent enters the battlefield with " + CardUtil.numberToText(vanishingAmount) + + " time counters on it. At the beginning of your upkeep, remove a time counter from it. When the last is removed, sacrifice it.)"; } } class VanishingEffect extends OneShotEffect { + VanishingEffect() { super(Outcome.Sacrifice); } @@ -47,7 +47,6 @@ class VanishingEffect extends OneShotEffect { super(effect); } - @Override public boolean apply(Game game, Ability source) { Permanent p = game.getPermanent(source.getSourceId()); @@ -55,6 +54,7 @@ class VanishingEffect extends OneShotEffect { int amount = p.getCounters().getCount(CounterType.TIME); if (amount > 0) { p.removeCounters(CounterType.TIME.createInstance(), game); + game.informPlayers("Removed a time counter from " + p.getLogName() + " (" + amount + " left)"); } return true; }