mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
* Fixed that for "Shoal" spells a wrong CMC was calculated while on the stack, if alternate casting cost was used (fixes #696).
This commit is contained in:
parent
103f2f4883
commit
974951e18d
7 changed files with 109 additions and 6 deletions
|
|
@ -61,7 +61,7 @@ public class BlazingShoal extends CardImpl {
|
|||
FilterOwnedCard filter = new FilterOwnedCard("a red card with converted mana cost X from your hand");
|
||||
filter.add(new ColorPredicate(ObjectColor.RED));
|
||||
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter),true)));
|
||||
|
||||
// Target creature gets +X/+0 until end of turn.
|
||||
this.getSpellAbility().addEffect(new BoostTargetEffect(new ExileFromHandCostCardConvertedMana(), new StaticValue(0), Duration.EndOfTurn));
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class DisruptingShoal extends CardImpl {
|
|||
FilterOwnedCard filter = new FilterOwnedCard("a blue card with converted mana cost X from your hand");
|
||||
filter.add(new ColorPredicate(ObjectColor.BLUE));
|
||||
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
|
||||
|
||||
// 2/1/2005: Disrupting Shoal can target any spell, but does nothing unless that spell's converted mana cost is X.
|
||||
// Counter target spell if its converted mana cost is X.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class NourishingShoal extends CardImpl {
|
|||
FilterOwnedCard filter = new FilterOwnedCard("a green card with converted mana cost X from your hand");
|
||||
filter.add(new ColorPredicate(ObjectColor.GREEN));
|
||||
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
|
||||
|
||||
// You gain X life.
|
||||
this.getSpellAbility().addEffect(new GainLifeEffect(new ExileFromHandCostCardConvertedMana()));
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class ShiningShoal extends CardImpl {
|
|||
FilterOwnedCard filter = new FilterOwnedCard("a white card with converted mana cost X from your hand");
|
||||
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
|
||||
|
||||
// The next X damage that a source of your choice would deal to you and/or creatures you control this turn is dealt to target creature or player instead.
|
||||
this.getSpellAbility().addEffect(new ShiningShoalPreventDamageTargetEffect(Duration.EndOfTurn, new ExileFromHandCostCardConvertedMana()));
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class SickeningShoal extends CardImpl {
|
|||
FilterOwnedCard filter = new FilterOwnedCard("a black card with converted mana cost X from your hand");
|
||||
filter.add(new ColorPredicate(ObjectColor.BLACK));
|
||||
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
|
||||
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
|
||||
|
||||
// Target creature gets -X/-X until end of turn.
|
||||
DynamicValue x = new SignInversionDynamicValue(new ExileFromHandCostCardConvertedMana());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package org.mage.test.cards.abilities.oneshot.counterspell;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DisruptingShoalTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs
|
||||
* And the X Value is equal to the CMC of the exiled blue card
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testWithBlueCardsInHand() {
|
||||
addCard(Zone.HAND, playerA, "Pillarfield Ox");
|
||||
addCard(Zone.HAND, playerA, "Spell Snare");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
|
||||
|
||||
addCard(Zone.HAND, playerB, "Disrupting Shoal");
|
||||
addCard(Zone.HAND, playerB, "Mistfire Adept", 2); // blue cards with 4 CMC to pay Disrupting Shoal
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pillarfield Ox");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Disrupting Shoal", "Pillarfield Ox", "Pillarfield Ox");
|
||||
playerB.addChoice("Yes"); // use alternate costs = Mistfire Adept = CMC = 4
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Spell Snare", "Disrupting Shoal", "Disrupting Shoal");
|
||||
|
||||
|
||||
setStopAt(1, PhaseStep.CLEANUP);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertGraveyardCount(playerB,"Disrupting Shoal", 1);
|
||||
assertExileCount(playerB, 1); // Mistfire Adept
|
||||
assertHandCount(playerB, "Mistfire Adept", 1); // One Left
|
||||
|
||||
assertHandCount(playerA, "Spell Snare", 1); // Can't be cast -> no valid target
|
||||
|
||||
assertGraveyardCount(playerA, "Pillarfield Ox", 1);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -31,8 +31,10 @@ package mage.abilities.costs.common;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -47,31 +49,50 @@ import mage.target.common.TargetCardInHand;
|
|||
public class ExileFromHandCost extends CostImpl {
|
||||
|
||||
List<Card> cards = new ArrayList<>();
|
||||
private boolean setXFromCMC;
|
||||
|
||||
public ExileFromHandCost(TargetCardInHand target) {
|
||||
this(target, false);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param target
|
||||
* @param setXFromCMC the spells X value on the stack is set to the converted mana costs of the exiled card
|
||||
*/
|
||||
public ExileFromHandCost(TargetCardInHand target, boolean setXFromCMC) {
|
||||
this.addTarget(target);
|
||||
this.text = "exile " + target.getTargetName();
|
||||
this.setXFromCMC = setXFromCMC;
|
||||
}
|
||||
|
||||
public ExileFromHandCost(ExileFromHandCost cost) {
|
||||
public ExileFromHandCost(final ExileFromHandCost cost) {
|
||||
super(cost);
|
||||
for (Card card: cost.cards) {
|
||||
this.cards.add(card.copy());
|
||||
}
|
||||
this.setXFromCMC = cost.setXFromCMC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
if (targets.choose(Outcome.Exile, controllerId, sourceId, game)) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
int cmc = 0;
|
||||
for (UUID targetId: targets.get(0).getTargets()) {
|
||||
Card card = player.getHand().get(targetId, game);
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
cmc += card.getManaCost().convertedManaCost();
|
||||
this.cards.add(card);
|
||||
paid |= player.moveCardToExileWithInfo(card, null, null, ability.getSourceId(), game, Zone.HAND);
|
||||
}
|
||||
if (paid && setXFromCMC) {
|
||||
VariableManaCost vmc = new VariableManaCost();
|
||||
vmc.setAmount(cmc);
|
||||
vmc.setPaid();
|
||||
ability.getManaCostsToPay().add(vmc);
|
||||
}
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue