From 9221e4eb64e654d88d5ddab718415fe00e0a5dc6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 8 Feb 2016 20:16:53 +0100 Subject: [PATCH] * Overload - Fixed that cmc of spells cast with overload were calculated wrongly with the overload costs. --- .../mage/sets/newphyrexia/MentalMisstep.java | 20 +++-- .../sets/returntoravnica/Vandalblast.java | 17 ++--- .../abilities/keywords/OverloadTest.java | 76 +++++++++++++++++++ .../cards/abilities/keywords/SupportTest.java | 65 ++++++++++++++++ .../abilities/keyword/OverloadAbility.java | 24 +++--- .../abilities/keyword/SupportAbility.java | 5 ++ 6 files changed, 173 insertions(+), 34 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/OverloadTest.java create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SupportTest.java diff --git a/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java b/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java index 18825bf349e..ef67b0422ad 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/MentalMisstep.java @@ -25,14 +25,13 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.sets.newphyrexia; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.effects.common.CounterTargetEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.filter.Filter; import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; @@ -44,23 +43,22 @@ import mage.target.TargetSpell; */ public class MentalMisstep extends CardImpl { - private static final FilterSpell filter = new FilterSpell("spell with converted mana cost 1"); + private static final FilterSpell FILTER = new FilterSpell("spell with converted mana cost 1"); - static { - filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, 1)); - } + static { + FILTER.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, 1)); + } - public MentalMisstep (UUID ownerId) { + public MentalMisstep(UUID ownerId) { super(ownerId, 38, "Mental Misstep", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{UP}"); this.expansionSetCode = "NPH"; - // Counter target spell with converted mana cost 1. this.getSpellAbility().addEffect(new CounterTargetEffect()); - this.getSpellAbility().addTarget(new TargetSpell(filter)); + this.getSpellAbility().addTarget(new TargetSpell(FILTER)); } - public MentalMisstep (final MentalMisstep card) { + public MentalMisstep(final MentalMisstep card) { super(card); } diff --git a/Mage.Sets/src/mage/sets/returntoravnica/Vandalblast.java b/Mage.Sets/src/mage/sets/returntoravnica/Vandalblast.java index 651ae6d3e05..e89d3352750 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/Vandalblast.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/Vandalblast.java @@ -28,44 +28,41 @@ package mage.sets.returntoravnica; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.common.DestroyAllEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.keyword.OverloadAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.TimingRule; import mage.filter.common.FilterArtifactPermanent; import mage.filter.predicate.permanent.ControllerPredicate; import mage.target.common.TargetArtifactPermanent; - /** * * @author LevelX2 */ public class Vandalblast extends CardImpl { - private static final FilterArtifactPermanent filter = new FilterArtifactPermanent("artifact you don't control"); + private static final FilterArtifactPermanent FILTER = new FilterArtifactPermanent("artifact you don't control"); static { - filter.add(new ControllerPredicate(TargetController.NOT_YOU)); + FILTER.add(new ControllerPredicate(TargetController.NOT_YOU)); } public Vandalblast(UUID ownerId) { super(ownerId, 111, "Vandalblast", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{R}"); this.expansionSetCode = "RTR"; - // Destroy target artifact you don't control. - this.getSpellAbility().addTarget(new TargetArtifactPermanent(filter)); + this.getSpellAbility().addTarget(new TargetArtifactPermanent(FILTER)); this.getSpellAbility().addEffect(new DestroyTargetEffect()); // Overload {4}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") - this.addAbility(new OverloadAbility(this, new DestroyAllEffect(filter), new ManaCostsImpl("{4}{R}"), TimingRule.SORCERY)); + this.addAbility(new OverloadAbility(this, new DestroyAllEffect(FILTER), new ManaCostsImpl("{4}{R}"), TimingRule.SORCERY)); } @@ -77,4 +74,4 @@ public class Vandalblast extends CardImpl { public Vandalblast copy() { return new Vandalblast(this); } -} \ No newline at end of file +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/OverloadTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/OverloadTest.java new file mode 100644 index 00000000000..805c70cde3f --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/OverloadTest.java @@ -0,0 +1,76 @@ +/* + * 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.keywords; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class OverloadTest extends CardTestPlayerBase { + + /** + * My opponent cast an overloaded Vandalblast, and Xmage would not let me + * cast Mental Misstep on it. + * + * The CMC of a card never changes, and Vandalblast's CMC is always 1. + * + * 4/15/2013 Casting a spell with overload doesn't change that spell's mana + * cost. You just pay the overload cost instead. + */ + @Test + public void testCastByOverloadDoesNotChangeCMC() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); + // Destroy target artifact you don't control. + // Overload {4}{R} (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of "target" with "each.") + addCard(Zone.HAND, playerA, "Vandalblast"); + + addCard(Zone.BATTLEFIELD, playerB, "Island", 1); + // Counter target spell with converted mana cost 1. + addCard(Zone.HAND, playerB, "Mental Misstep", 1); + addCard(Zone.BATTLEFIELD, playerB, "War Horn", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Vandalblast with overload"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerB, "Mental Misstep", "Vandalblast"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertGraveyardCount(playerA, "Vandalblast", 1); + assertGraveyardCount(playerB, "Mental Misstep", 1); + + assertPermanentCount(playerB, "War Horn", 2); + + } + +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SupportTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SupportTest.java new file mode 100644 index 00000000000..204eb03dc30 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/SupportTest.java @@ -0,0 +1,65 @@ +/* + * 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.keywords; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class SupportTest extends CardTestPlayerBase { + + /** + * Support Ability can target its source. Its cannot really. + */ + @Test + public void testCreatureSupport() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 7); + // When Gladehart Cavalry enters the battlefield, support 6. + // Whenever a creature you control with a +1/+1 counter on it dies, you gain 2 life. + addCard(Zone.HAND, playerA, "Gladehart Cavalry"); // {5}{G}{G} 6/6 + + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); + addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Gladehart Cavalry"); + addTarget(playerA, "Silvercoat Lion^Pillarfield Ox^Gladehart Cavalry");// Gladehart Cavalry should not be allowed + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPowerToughness(playerA, "Silvercoat Lion", 3, 3); + assertPowerToughness(playerA, "Pillarfield Ox", 3, 5); + assertPowerToughness(playerA, "Gladehart Cavalry", 6, 6); + } + +} diff --git a/Mage/src/main/java/mage/abilities/keyword/OverloadAbility.java b/Mage/src/main/java/mage/abilities/keyword/OverloadAbility.java index b5abc7ac043..d2c61a51f7c 100644 --- a/Mage/src/main/java/mage/abilities/keyword/OverloadAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/OverloadAbility.java @@ -25,7 +25,6 @@ * authors and should not be interpreted as representing official policies, either expressed * or implied, of BetaSteward_at_googlemail.com. */ - package mage.abilities.keyword; import mage.abilities.SpellAbility; @@ -35,38 +34,37 @@ import mage.cards.Card; import mage.constants.SpellAbilityType; import mage.constants.TimingRule; - /** * 702.94. Overload * * 702.94a. Overload is a keyword that represents two static abilities: one that * functions from any zone in which the spell with overload can be cast and * another that functions while the card is on the stack. Overload [cost] means - * "You may choose to pay [cost] rather than pay this spell's mana cost" and - * "If you chose to pay this spell's overload cost, change its text by replacing - * all instances of the word 'target' with the word 'each.'" Using the overload - * ability follows the rules for paying alternative costs in rules 601.2b and 601.2e-g. + * "You may choose to pay [cost] rather than pay this spell's mana cost" and "If + * you chose to pay this spell's overload cost, change its text by replacing all + * instances of the word 'target' with the word 'each.'" Using the overload + * ability follows the rules for paying alternative costs in rules 601.2b and + * 601.2e-g. * * 702.94b. If a player chooses to pay the overload cost of a spell, that spell * won't require any targets. It may affect objects that couldn't be chosen as * legal targets if the spell were cast without its overload cost being paid. * * 702.94c. Overload's second ability creates a text-changing effect. See rule - * 612, "Text-Changing Effects." + * 612, "Text-Changing Effects." * * @author LevelX2 * */ - public class OverloadAbility extends SpellAbility { - public OverloadAbility(Card card,Effect effect, ManaCosts costs) { + public OverloadAbility(Card card, Effect effect, ManaCosts costs) { this(card, effect, costs, TimingRule.INSTANT); - this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; } - public OverloadAbility(Card card,Effect effect, ManaCosts costs, TimingRule timingRule) { + public OverloadAbility(Card card, Effect effect, ManaCosts costs, TimingRule timingRule) { super(costs, card.getName() + " with overload"); + this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE; this.addEffect(effect); this.timing = timingRule; } @@ -87,7 +85,7 @@ public class OverloadAbility extends SpellAbility { @Override public String getRule() { - return "Overload " + getManaCostsToPay().getText()+ " (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of \"target\" with \"each.\")"; + return "Overload " + getManaCostsToPay().getText() + " (You may cast this spell for its overload cost. If you do, change its text by replacing all instances of \"target\" with \"each.\")"; } -} \ No newline at end of file +} diff --git a/Mage/src/main/java/mage/abilities/keyword/SupportAbility.java b/Mage/src/main/java/mage/abilities/keyword/SupportAbility.java index 248df3d5841..042c8e6bbfe 100644 --- a/Mage/src/main/java/mage/abilities/keyword/SupportAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/SupportAbility.java @@ -36,6 +36,11 @@ import mage.filter.predicate.permanent.AnotherPredicate; import mage.target.common.TargetCreaturePermanent; /** + * 701.32. Support + * + * 701.32a “Support N” on a permanent means “Put a +1/+1 counter on each of up + * to N other target creatures.” “Support N” on an instant or sorcery spell + * means “Put a +1/+1 counter on each of up to N target creatures.” * * @author LevelX2 */