From e4145c90b5c3bad8e9f8521d426bbee171d7bc6e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 14 Feb 2013 14:50:41 +0100 Subject: [PATCH] Fixed issue #135 that cards with miracle were always shown on the stack if it was possible to cast them with miracle also if the owner of the card dicided not to use the miracle ability. Minor formating. --- .../java/mage/client/game/HelperPanel.java | 10 +++++-- .../abilities/keyword/MiracleAbility.java | 14 +++++++-- .../mage/watchers/common/MiracleWatcher.java | 29 +++++++++---------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/game/HelperPanel.java b/Mage.Client/src/main/java/mage/client/game/HelperPanel.java index b5b5ac0b5bf..7f70cbc7604 100644 --- a/Mage.Client/src/main/java/mage/client/game/HelperPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/HelperPanel.java @@ -28,10 +28,10 @@ package mage.client.game; -import mage.client.components.MageTextArea; -import javax.swing.*; import java.awt.*; +import javax.swing.*; +import mage.client.components.MageTextArea; /** * Panel with buttons that copy the state of feedback panel. @@ -91,6 +91,7 @@ public class HelperPanel extends JPanel { container.add(btnRight); btnLeft.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (linkLeft != null) {{ setState("",false,"",false); @@ -101,6 +102,7 @@ public class HelperPanel extends JPanel { }); btnRight.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (linkRight != null) {{ setState("",false,"",false); @@ -111,6 +113,7 @@ public class HelperPanel extends JPanel { }); btnSpecial.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(java.awt.event.ActionEvent evt) { if (linkSpecial != null) {{ setState("",false,"",false); @@ -153,13 +156,14 @@ public class HelperPanel extends JPanel { public void setMessage(String message) { if (message.startsWith("Use alternative cost")) { textArea.setText("Use alternative cost?"); - } else if (message.contains("Use")) { + } else if (message.length() > 30 && message.contains("Use")) { textArea.setText("Use ability?"); } else { textArea.setText(message); } } + @Override public void requestFocus() { this.btnRight.requestFocus(); } diff --git a/Mage/src/mage/abilities/keyword/MiracleAbility.java b/Mage/src/mage/abilities/keyword/MiracleAbility.java index fcc563f274c..6fa5d8ab81f 100644 --- a/Mage/src/mage/abilities/keyword/MiracleAbility.java +++ b/Mage/src/mage/abilities/keyword/MiracleAbility.java @@ -33,8 +33,16 @@ import mage.abilities.StaticAbility; import mage.abilities.costs.Cost; /** - * Miracle ability: - * You may cast this card for its miracle cost when you draw it if it's the first card you drew this turn. + * 702.92. Miracle + * + * 702.92a Miracle is a static ability linked to a triggered ability (see rule 603.10). + * "Miracle [cost]" means "You may reveal this card from your hand as you draw it if + * it's the first card you've drawn this turn. When you reveal this card this way, + * you may cast it by paying [cost] rather than its mana cost." + * + * 702.92b If a player chooses to reveal a card using its miracle ability, he or she + * plays with that card revealed until that card leaves his or her hand, that ability + * resolves, or that ability otherwise leaves the stack. * * @author noxx */ @@ -64,4 +72,4 @@ public class MiracleAbility extends StaticAbility { return new MiracleAbility(this); } -} \ No newline at end of file +} diff --git a/Mage/src/mage/watchers/common/MiracleWatcher.java b/Mage/src/mage/watchers/common/MiracleWatcher.java index 4812a65baaf..db5505aeb13 100644 --- a/Mage/src/mage/watchers/common/MiracleWatcher.java +++ b/Mage/src/mage/watchers/common/MiracleWatcher.java @@ -28,8 +28,13 @@ package mage.watchers.common; -import mage.Constants; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.UUID; +import mage.Constants.Outcome; import mage.Constants.WatcherScope; +import mage.Constants.Zone; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; @@ -39,14 +44,10 @@ import mage.cards.Cards; import mage.cards.CardsImpl; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.stack.StackAbility; import mage.players.Player; import mage.watchers.WatcherImpl; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; + /** * Counts amount of cards drawn this turn by players. @@ -97,17 +98,15 @@ 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) { - game.getStack().add(new StackAbility(ability, controller.getId())); - Cards cards = new CardsImpl(Constants.Zone.PICK); + // 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(); + Cards cards = new CardsImpl(Zone.PICK); cards.add(card); controller.lookAtCards("Miracle", cards, game); - if (controller.chooseUse(Constants.Outcome.Benefit, "Use Miracle " + manaCostsToPay.getText() + "?", game)) { - game.getStack().poll(); + if (controller.chooseUse(Outcome.Benefit, "Use Miracle " + manaCostsToPay.getText() + "?", game)) { controller.revealCards("Miracle", cards, game); ManaCosts costRef = card.getSpellAbility().getManaCostsToPay(); // replace with the new cost @@ -117,8 +116,6 @@ public class MiracleWatcher extends WatcherImpl { } controller.cast(card.getSpellAbility(), game, false); break; - } else { - game.getStack().poll(); } } }