* Madness ability - fixed that it ask about madness cast two times (fixes #6674);

This commit is contained in:
Oleg Agafonov 2020-06-19 23:42:45 +04:00
parent f2c09a7193
commit 2e7d01965e
2 changed files with 28 additions and 40 deletions

View file

@ -23,15 +23,11 @@ public class MadnessTest extends CardTestPlayerBase {
* card into their graveyard. 702.34b Casting a spell using its
* madness ability follows the rules for paying alternative costs in rules
* 601.2b and 601.2eg.
*
*/
/**
* <p>
* Arrogant Wurm 3GG Creature -- Wurm 4/4 Trample Madness {2}{G} (If you
* discard this card, you may cast it for its madness cost instead of
* putting it into your graveyard.)
*
*/
/**
* <p>
* Raven's Crime B Sorcery Target player discards a card. Retrace (You may
* cast this card from your graveyard by discarding a land card in addition
* to paying its other costs.)
@ -45,7 +41,6 @@ public class MadnessTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Raven's Crime", playerA);
setChoice(playerA, "Yes"); // use madness triggered ability
setChoice(playerA, "Yes"); // use madness cast
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
@ -125,7 +120,6 @@ public class MadnessTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Haunting Hymn", playerA);
setChoice(playerA, "Yes"); // use madness triggered ability
setChoice(playerA, "Yes"); // use madness cast
setChoice(playerA, "X=4");
addTargetAmount(playerA, "Pillarfield Ox", 4);
@ -177,15 +171,14 @@ public class MadnessTest extends CardTestPlayerBase {
addCard(Zone.HAND, playerA, "Forest");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Falkenrath Gorger");
setChoice(playerA, "Yes"); // Discard a card and put a +1/+1 counter on that creature, it gains haste until end of turn, and it becomes a Vampire in addition to its other types?
setChoice(playerA, "Asylum Visitor"); // Card to discard from Falkenrath entering by Olivia effect
setChoice(playerA, "Asylum Visito"); // Madness {1}{B}
setChoice(playerA, "Yes"); // use madness triggered ability
setChoice(playerA, "Yes"); // use madness cast
setChoice(playerA, "Yes"); // use madness triggered ability
setChoice(playerA, "Yes"); // Discard a card and put a +1/+1 counter on that creature, it gains haste until end of turn, and it becomes a Vampire in addition to its other types?
setChoice(playerA, "Forest");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();

View file

@ -1,6 +1,5 @@
package mage.abilities.keyword;
import java.util.UUID;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -13,35 +12,33 @@ import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SpellAbilityCastMode;
import mage.constants.SpellAbilityType;
import mage.constants.Zone;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.stack.Spell;
import mage.players.Player;
import java.util.UUID;
/**
* 702.33. Madness
*
* <p>
* 702.33a. Madness is a keyword that represents two abilities.
*
* <p>
* The first is a static ability that functions while the card with madness is
* in a player's hand. The second is a triggered ability that functions when the
* first ability is applied.
*
* <p>
* "Madness [cost]" means "If a player would discard this card, that player
* discards it, but may exile it instead of putting it into their graveyard" and
* "When this card is exiled this way, its owner may cast it by paying [cost]
* rather than paying its mana cost. If that player doesn't, they put this
* card into their graveyard.
*
* <p>
* 702.33b. Casting a spell using its madness ability follows the rules for
* paying alternative costs in rules 601.2b and 601.2e-g.
*
* <p>
* SOI Changes: If you discard a card with madness, you exile it instead of
* putting it into your graveyard. Note that the mandatory discard into exile is
* a small change from previous rules. Before, you could discard a card with
@ -52,7 +49,7 @@ import mage.players.Player;
*/
public class MadnessAbility extends StaticAbility {
private String rule;
private final String rule;
@SuppressWarnings("unchecked")
public MadnessAbility(Card card, ManaCosts madnessCost) {
@ -205,26 +202,24 @@ class MadnessCastEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player owner = null;
Card card = game.getCard(source.getSourceId());
if (card != null) {
owner = game.getPlayer(card.getOwnerId());
if (card == null) {
return false;
}
if (owner != null && card != null
&& owner.chooseUse(outcome, "Cast " + card.getLogName() + " by madness?", source, game)) {
// replace with the new cost
SpellAbility castByMadness = card.getSpellAbility().copy();
ManaCosts<ManaCost> costRef = castByMadness.getManaCostsToPay();
castByMadness.setSpellAbilityType(SpellAbilityType.BASE_ALTERNATE);
castByMadness.setSpellAbilityCastMode(SpellAbilityCastMode.MADNESS);
costRef.clear();
costRef.add(madnessCost);
boolean result = owner.cast(castByMadness, game, false, new MageObjectReference(source.getSourceObject(game), game));
return result;
Player owner = game.getPlayer(card.getOwnerId());
if (owner == null) {
return false;
}
return false;
// replace with the new cost
SpellAbility castByMadness = card.getSpellAbility().copy();
ManaCosts<ManaCost> costRef = castByMadness.getManaCostsToPay();
castByMadness.setSpellAbilityType(SpellAbilityType.BASE_ALTERNATE);
castByMadness.setSpellAbilityCastMode(SpellAbilityCastMode.MADNESS);
costRef.clear();
costRef.add(madnessCost);
return owner.cast(castByMadness, game, false, new MageObjectReference(source.getSourceObject(game), game));
}
@Override