mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
* Madness ability - fixed that it ask about madness cast two times (fixes #6674);
This commit is contained in:
parent
f2c09a7193
commit
2e7d01965e
2 changed files with 28 additions and 40 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue