mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Disrupting Shoal - Fixed that the converted mana costs of split cards were not handled correctly.
This commit is contained in:
parent
4baa9e5588
commit
41af3e9d4a
3 changed files with 118 additions and 82 deletions
|
@ -33,7 +33,6 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.AlternativeCostSourceAbility;
|
||||
import mage.abilities.costs.common.ExileFromHandCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.ExileFromHandCostCardConvertedMana;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -60,7 +59,6 @@ public class DisruptingShoal extends CardImpl {
|
|||
this.expansionSetCode = "BOK";
|
||||
this.subtype.add("Arcane");
|
||||
|
||||
|
||||
// You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost.
|
||||
FilterOwnedCard filter = new FilterOwnedCard("a blue card with converted mana cost X from your hand");
|
||||
filter.add(new ColorPredicate(ObjectColor.BLUE));
|
||||
|
@ -100,9 +98,8 @@ class DisruptingShoalCounterTargetEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
DynamicValue amount = new ExileFromHandCostCardConvertedMana();
|
||||
Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source));
|
||||
if (spell != null && spell.getConvertedManaCost() == amount.calculate(game, source, this)) {
|
||||
if (spell != null && new ExileFromHandCostCardConvertedMana().isConvertedManaCostEqual(game, source, this, spell.getConvertedManaCost())) {
|
||||
return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -36,12 +36,11 @@ 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 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
|
||||
|
@ -51,6 +50,8 @@ public class DisruptingShoalTest extends CardTestPlayerBase {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
|
||||
|
||||
// You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost.
|
||||
// Counter target spell if its converted mana cost is X.
|
||||
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);
|
||||
|
@ -61,7 +62,6 @@ public class DisruptingShoalTest extends CardTestPlayerBase {
|
|||
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();
|
||||
|
||||
|
@ -78,11 +78,12 @@ public class DisruptingShoalTest extends CardTestPlayerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs
|
||||
* And the X Value can be equal to either half of a fuse card.
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs And
|
||||
* the X Value can be equal to either half of a fuse card.
|
||||
*
|
||||
* Reported bug: "Casting Disrupting Shoal pitching Far // Away does not counter spells with converted mana cost 2 or 3,
|
||||
* which it should. Instead it does counter spells with converted mana cost 5, which it shouldn't".
|
||||
* Reported bug: "Casting Disrupting Shoal pitching Far // Away does not
|
||||
* counter spells with converted mana cost 2 or 3, which it should. Instead
|
||||
* it does counter spells with converted mana cost 5, which it shouldn't".
|
||||
*/
|
||||
@Test
|
||||
public void testWithFuseCardCounterCMCTwo() {
|
||||
|
@ -92,20 +93,22 @@ public class DisruptingShoalTest extends CardTestPlayerBase {
|
|||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
|
||||
|
||||
// You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost.
|
||||
// Counter target spell if its converted mana cost is X.
|
||||
addCard(Zone.HAND, playerB, "Disrupting Shoal", 1);
|
||||
/**
|
||||
* Far {1}{U} Instant Return target creature to its owner's hand. Away
|
||||
* {2}{B} Instant Target player sacrifices a creature. Fuse (You may
|
||||
* cast one or both halves of this card from your hand.)
|
||||
*/
|
||||
addCard(Zone.HAND, playerB, "Disrupting Shoal", 1);
|
||||
addCard(Zone.HAND, playerB, "Far // Away", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Disrupting Shoal", "Grizzly Bears", "Grizzly Bears");
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Disrupting Shoal", "Grizzly Bears");
|
||||
playerB.addChoice("Yes"); // use alternate costs = 2 CMC = Far
|
||||
|
||||
setStopAt(1, PhaseStep.CLEANUP);
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertExileCount(playerB, 1); // Far // Away should be exiled as part of Disrupting alternative cost
|
||||
|
@ -115,11 +118,12 @@ public class DisruptingShoalTest extends CardTestPlayerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs
|
||||
* And the X Value can be equal to either half of a fuse card.
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs And
|
||||
* the X Value can be equal to either half of a fuse card.
|
||||
*
|
||||
* Reported bug: "Casting Disrupting Shoal pitching Far // Away does not counter spells with converted mana cost 2 or 3,
|
||||
* which it should. Instead it does counter spells with converted mana cost 5, which it shouldn't".
|
||||
* Reported bug: "Casting Disrupting Shoal pitching Far // Away does not
|
||||
* counter spells with converted mana cost 2 or 3, which it should. Instead
|
||||
* it does counter spells with converted mana cost 5, which it shouldn't".
|
||||
*/
|
||||
@Test
|
||||
public void testWithFuseCardCounterCMCThree() {
|
||||
|
@ -150,11 +154,13 @@ public class DisruptingShoalTest extends CardTestPlayerBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs
|
||||
* And the X Value can be equal to either half of a fuse card. Not the combined cost of both.
|
||||
* Test that Disrupting Shoal can be played with alternate casting costs And
|
||||
* the X Value can be equal to either half of a fuse card. Not the combined
|
||||
* cost of both.
|
||||
*
|
||||
* Reported bug: "Casting Disrupting Shoal pitching Far // Away does not counter spells with converted mana cost 2 or 3,
|
||||
* which it should. Instead it does counter spells with converted mana cost 5, which it shouldn't".
|
||||
* Reported bug: "Casting Disrupting Shoal pitching Far // Away does not
|
||||
* counter spells with converted mana cost 2 or 3, which it should. Instead
|
||||
* it does counter spells with converted mana cost 5, which it shouldn't".
|
||||
*/
|
||||
@Test
|
||||
public void testWithFuseCardShouldNotCounterCMCFive() {
|
||||
|
|
|
@ -33,6 +33,7 @@ import mage.abilities.costs.common.ExileFromHandCost;
|
|||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
|
@ -59,6 +60,38 @@ public class ExileFromHandCostCardConvertedMana implements DynamicValue {
|
|||
return sourceAbility.getManaCostsToPay().getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method does only work to compare the cmc for one (or the first card)
|
||||
* exiled as a cost
|
||||
*
|
||||
* @param game
|
||||
* @param sourceAbility
|
||||
* @param effect
|
||||
* @param amount cmc to compare against
|
||||
* @return
|
||||
*/
|
||||
public boolean isConvertedManaCostEqual(Game game, Ability sourceAbility, Effect effect, int amount) {
|
||||
for (Cost cost : sourceAbility.getCosts()) {
|
||||
if (cost.isPaid() && cost instanceof ExileFromHandCost) {
|
||||
for (Card card : ((ExileFromHandCost) cost).getCards()) {
|
||||
if (card instanceof SplitCard) {
|
||||
if (((SplitCard) card).getLeftHalfCard().getManaCost().convertedManaCost() == amount) {
|
||||
return true;
|
||||
}
|
||||
if (((SplitCard) card).getRightHalfCard().getManaCost().convertedManaCost() == amount) {
|
||||
return true;
|
||||
}
|
||||
} else if (card.getManaCost().convertedManaCost() == amount) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileFromHandCostCardConvertedMana copy() {
|
||||
return new ExileFromHandCostCardConvertedMana();
|
||||
|
|
Loading…
Reference in a new issue