From 4bdc4936f0504a73625f2bb0d4f45174d1613418 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 14 Jul 2016 17:14:06 +0200 Subject: [PATCH] * Fixed Mid's Dilation bugs (fixes #2077). --- .../mage/sets/eldritchmoon/MindsDilation.java | 62 +++---------------- .../BecomesCreatureSourceEffect.java | 12 ++-- .../watchers/common/SpellsCastWatcher.java | 1 + 3 files changed, 19 insertions(+), 56 deletions(-) diff --git a/Mage.Sets/src/mage/sets/eldritchmoon/MindsDilation.java b/Mage.Sets/src/mage/sets/eldritchmoon/MindsDilation.java index ca777a1c68..06354f26eb 100644 --- a/Mage.Sets/src/mage/sets/eldritchmoon/MindsDilation.java +++ b/Mage.Sets/src/mage/sets/eldritchmoon/MindsDilation.java @@ -32,15 +32,11 @@ import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.SpellCastOpponentTriggeredAbility; -import mage.abilities.effects.AsThoughEffectImpl; -import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; -import mage.constants.AsThoughEffectType; import mage.constants.CardType; -import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; @@ -64,8 +60,7 @@ public class MindsDilation extends CardImpl { // Whenever an opponent casts his or her first spell each turn, that player exiles the top card of his or her library. If it's a nonland card, // you may cast it without paying its mana cost. - Ability ability = new MindsDilationTriggeredAbility(new MindsDilationEffect(), false); - this.addAbility(ability, new SpellsCastWatcher()); + this.addAbility(new MindsDilationTriggeredAbility(new MindsDilationEffect(), false), new SpellsCastWatcher()); } public MindsDilation(final MindsDilation card) { @@ -113,7 +108,7 @@ class MindsDilationTriggeredAbility extends SpellCastOpponentTriggeredAbility { @Override public String getRule() { return "Whenever an opponent casts his or her first spell each turn, that player exiles the top card of his or her library." - + " If it's a nonland card, you may cast it without paying its mana cost"; + + " If it's a nonland card, you may cast it without paying its mana cost."; } } @@ -121,7 +116,7 @@ class MindsDilationEffect extends OneShotEffect { MindsDilationEffect() { super(Outcome.Benefit); - this.staticText = "that player exiles the top card of his or her library. If it's a nonland card, you may cast it without paying its mana cost."; + this.staticText = "that player exiles the top card of his or her library. If it's a nonland card, you may cast it without paying its mana cost"; } MindsDilationEffect(final MindsDilationEffect effect) { @@ -140,12 +135,13 @@ class MindsDilationEffect extends OneShotEffect { Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source)); if (controller != null && sourceObject != null && opponent != null) { if (opponent.getLibrary().size() > 0) { - Card card = opponent.getLibrary().removeFromTop(game); - if (card != null) { - opponent.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source.getSourceId(), game, Zone.LIBRARY, true); - ContinuousEffect effect = new MindsDilationCastFromExileEffect(); - effect.setTargetPointer(new FixedTarget(card.getId())); - game.addEffect(effect, source); + Card card = opponent.getLibrary().getFromTop(game); + if (card != null && opponent.moveCards(card, Zone.EXILED, source, game)) { + if (!card.getCardType().contains(CardType.LAND)) { + if (controller.chooseUse(outcome, "Cast " + card.getLogName() + " without paying its mana cost from exile?", source, game)) { + controller.cast(card.getSpellAbility(), game, true); + } + } } } return true; @@ -153,41 +149,3 @@ class MindsDilationEffect extends OneShotEffect { return false; } } - -class MindsDilationCastFromExileEffect extends AsThoughEffectImpl { - - MindsDilationCastFromExileEffect() { - super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit); - staticText = "If it's a nonland card, you may cast it without paying its mana cost"; - } - - MindsDilationCastFromExileEffect(final MindsDilationCastFromExileEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public MindsDilationCastFromExileEffect copy() { - return new MindsDilationCastFromExileEffect(this); - } - - @Override - public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { - UUID targetId = getTargetPointer().getFirst(game, source); - Player controller = game.getPlayer(source.getControllerId()); - if (targetId != null && controller != null) { - Card card = game.getCard(targetId); - if (card != null && !card.getCardType().contains(CardType.LAND) && game.getState().getZone(targetId) == Zone.EXILED) { - if (controller.chooseUse(outcome, "Cast " + card.getLogName() + "?", source, game)) { - controller.cast(card.getSpellAbility(), game, true); - } - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureSourceEffect.java index 2a04f2e1a1..99399d7c27 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureSourceEffect.java @@ -50,8 +50,8 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements protected Token token; protected String type; protected boolean losePreviousTypes; - protected DynamicValue power; - protected DynamicValue toughness; + protected DynamicValue power = null; + protected DynamicValue toughness = null; public BecomesCreatureSourceEffect(Token token, String type, Duration duration) { this(token, type, duration, false, false); @@ -77,8 +77,12 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements this.token = effect.token.copy(); this.type = effect.type; this.losePreviousTypes = effect.losePreviousTypes; - this.power = effect.power.copy(); - this.toughness = effect.toughness.copy(); + if (effect.power != null) { + this.power = effect.power.copy(); + } + if (effect.toughness != null) { + this.toughness = effect.toughness.copy(); + } } @Override diff --git a/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java b/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java index a175971151..f0309d0ff8 100644 --- a/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/SpellsCastWatcher.java @@ -32,6 +32,7 @@ public class SpellsCastWatcher extends Watcher { public SpellsCastWatcher(final SpellsCastWatcher watcher) { super(watcher); + this.spellsCast.putAll(watcher.spellsCast); } @Override