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.

This commit is contained in:
LevelX2 2013-02-14 14:50:41 +01:00
parent 8d3796ef7a
commit e4145c90b5
3 changed files with 31 additions and 22 deletions

View file

@ -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();
}

View file

@ -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<MiracleAbility> {
return new MiracleAbility(this);
}
}
}

View file

@ -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<MiracleWatcher> {
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<ManaCost> 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<ManaCost> 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<MiracleWatcher> {
}
controller.cast(card.getSpellAbility(), game, false);
break;
} else {
game.getStack().poll();
}
}
}