From 7ad45a2a6e7e9bf0f9520c302672f66fe9b44386 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 10 Oct 2014 10:27:01 +0200 Subject: [PATCH] * Fixed that converted mana costs for stack objects were not always calculated correctly (e.g. a Mental Misstep could counter a Cahlice of the Coid with X=1). --- .../mage/sets/newphyrexia/MentalMisstep.java | 2 ++ .../cards/single/ChaliceOfTheVoidTest.java | 28 +++++++++++++++++-- .../ConvertedManaCostPredicate.java | 18 ++---------- Mage/src/mage/game/stack/Spell.java | 1 + Mage/src/mage/game/stack/StackAbility.java | 8 ++++++ Mage/src/mage/game/stack/StackObject.java | 1 + 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java b/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java index c46c1d2ccf..780aebf1ad 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java @@ -54,6 +54,8 @@ public class MentalMisstep extends CardImpl { super(ownerId, 38, "Mental Misstep", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{UP}"); this.expansionSetCode = "NPH"; this.color.setBlue(true); + + // Counter target spell with converted mana cost 1. this.getSpellAbility().addEffect(new CounterTargetEffect()); this.getSpellAbility().addTarget(new TargetSpell(filter)); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/ChaliceOfTheVoidTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/ChaliceOfTheVoidTest.java index 9d7d6ffcd0..aca0495f38 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/ChaliceOfTheVoidTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/ChaliceOfTheVoidTest.java @@ -46,7 +46,7 @@ public class ChaliceOfTheVoidTest extends CardTestPlayerBase { */ @Test - public void testCopiedSteelHellkite() { + public void testX1CountsFor2CMC() { addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4); addCard(Zone.HAND, playerA, "Chalice of the Void", 2); @@ -56,10 +56,34 @@ public class ChaliceOfTheVoidTest extends CardTestPlayerBase { castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chalice of the Void"); setChoice(playerA, "X=1"); - setStopAt(4, PhaseStep.BEGIN_COMBAT); + setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); assertPermanentCount(playerA, "Chalice of the Void", 2); } + + /* + If X=1 the cmc of Chalice on the stack is 2. So it can't be countered by Mental Misstep + */ + @Test + public void testCantBeCounteredByMentalMisstep() { + addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2); + addCard(Zone.HAND, playerA, "Chalice of the Void", 1); + + addCard(Zone.BATTLEFIELD, playerB, "Island", 1); + addCard(Zone.HAND, playerB, "Mental Misstep", 1); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chalice of the Void"); + setChoice(playerA, "X=1"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Mental Misstep", "Chalice of the Void", "Chalice of the Void"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertHandCount(playerB, "Mental Misstep", 1); // cannot be cast because no legal target exists + assertPermanentCount(playerA, "Chalice of the Void", 1); // was not countered + + } + } diff --git a/Mage/src/mage/filter/predicate/mageobject/ConvertedManaCostPredicate.java b/Mage/src/mage/filter/predicate/mageobject/ConvertedManaCostPredicate.java index edeacbe39b..45c594785d 100644 --- a/Mage/src/mage/filter/predicate/mageobject/ConvertedManaCostPredicate.java +++ b/Mage/src/mage/filter/predicate/mageobject/ConvertedManaCostPredicate.java @@ -28,8 +28,6 @@ package mage.filter.predicate.mageobject; import mage.MageObject; -import mage.abilities.costs.mana.ManaCost; -import mage.abilities.costs.mana.VariableManaCost; import mage.filter.Filter; import mage.filter.predicate.IntComparePredicate; import mage.game.stack.StackObject; @@ -46,19 +44,9 @@ public class ConvertedManaCostPredicate extends IntComparePredicate @Override protected int getInputValue(MageObject input) { - if(input instanceof StackObject){ - int manaCost = 0; - for(ManaCost cost : input.getManaCost()){ - if(cost instanceof VariableManaCost){ - manaCost += ((StackObject)input).getStackAbility().getManaCostsToPay().getX(); - } - else{ - manaCost += cost.convertedManaCost(); - } - } - return manaCost; - } - else{ + if (input instanceof StackObject) { + return ((StackObject) input).getConvertedManaCost(); + } else{ return input.getManaCost().convertedManaCost(); } } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index 84d8346359..eada29d517 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -609,6 +609,7 @@ public class Spell implements StackObject, Card { * treated as the number chosen for it while the object is on the stack. * @return */ + @Override public int getConvertedManaCost() { int cmc = 0; for (Ability spellAbility: spellAbilities) { diff --git a/Mage/src/mage/game/stack/StackAbility.java b/Mage/src/mage/game/stack/StackAbility.java index ce7b9ce67d..bc8ba084a9 100644 --- a/Mage/src/mage/game/stack/StackAbility.java +++ b/Mage/src/mage/game/stack/StackAbility.java @@ -208,6 +208,14 @@ public class StackAbility implements StackObject, Ability { return emptyCosts; } + @Override + public int getConvertedManaCost() { + // Activated abilities have an "activation cost" but they don't have a characteristic related to that while on the stack. + // There are certain effects that interact with the cost to activate an ability (e.g., Training Grounds, Power Artifact) + // but nothing that looks for that quality of an ability once it's on the stack. + return 0; + } + @Override public Effects getEffects() { return ability.getEffects(); diff --git a/Mage/src/mage/game/stack/StackObject.java b/Mage/src/mage/game/stack/StackObject.java index 18ac6e9b3c..791cc6caaf 100644 --- a/Mage/src/mage/game/stack/StackObject.java +++ b/Mage/src/mage/game/stack/StackObject.java @@ -40,6 +40,7 @@ public interface StackObject extends MageObject, Controllable { UUID getSourceId(); void counter(UUID sourceId, Game game); Ability getStackAbility(); + int getConvertedManaCost(); @Override StackObject copy(); }