From 92e5a771165cc5e0a74e13385cd2149c26a31a8a Mon Sep 17 00:00:00 2001 From: magenoxx Date: Sat, 5 May 2012 18:08:39 +0400 Subject: [PATCH] Some fixes for Miracle keyword. Added displaying spell in the stack --- .../mage/watchers/common/MiracleWatcher.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Mage/src/mage/watchers/common/MiracleWatcher.java b/Mage/src/mage/watchers/common/MiracleWatcher.java index 4dbb6f0b55..b3355656a1 100644 --- a/Mage/src/mage/watchers/common/MiracleWatcher.java +++ b/Mage/src/mage/watchers/common/MiracleWatcher.java @@ -37,6 +37,7 @@ import mage.abilities.keyword.MiracleAbility; import mage.cards.Card; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.stack.StackAbility; import mage.players.Player; import mage.watchers.WatcherImpl; @@ -91,12 +92,25 @@ public class MiracleWatcher extends WatcherImpl { for (Ability ability : card.getAbilities()) { if (ability instanceof MiracleAbility) { Player controller = game.getPlayer(ability.getControllerId()); + // FIXME: I don't like that I need to call it manually + // it's the place for bugs + game.getContinuousEffects().costModification(ability, game); ManaCosts manaCostsToPay = ability.getManaCostsToPay(); - if (controller != null && controller.chooseUse(Constants.Outcome.Benefit, "Use Miracle " + manaCostsToPay.getText() + "?", game)) { - if (manaCostsToPay.pay(ability, game, ability.getSourceId(), ability.getControllerId(), false)) { - controller.cast(card.getSpellAbility(), game, true); + if (controller != null) { + game.getStack().add(new StackAbility(ability, controller.getId())); + if (controller.chooseUse(Constants.Outcome.Benefit, "Use Miracle " + manaCostsToPay.getText() + "?", game)) { + game.getStack().poll(); + ManaCosts costRef = card.getSpellAbility().getManaCostsToPay(); + // replace with the new cost + costRef.clear(); + for (ManaCost manaCost : manaCostsToPay) { + costRef.add(manaCost); + } + controller.cast(card.getSpellAbility(), game, false); + break; + } else { + game.getStack().poll(); } - break; } } }