From 4298e66e028b8231da39296bdd7cd5450386b450 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 25 May 2015 16:51:09 +0200 Subject: [PATCH] * Changeling - Fixed that some non creature subtypes of cards (e.g. Arcane) were positive filtered for Changeling (fixes #991). --- .../LongForgottenGohei.java | 4 +- .../abilities/keywords/ChangelingTest.java | 63 +++++++++++++++++++ Mage/src/mage/MageObjectImpl.java | 12 ++-- Mage/src/mage/util/CardUtil.java | 12 +++- 4 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/LongForgottenGohei.java b/Mage.Sets/src/mage/sets/championsofkamigawa/LongForgottenGohei.java index 2cac959bbe7..35429ee0b0a 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/LongForgottenGohei.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/LongForgottenGohei.java @@ -45,7 +45,7 @@ import mage.filter.predicate.mageobject.SubtypePredicate; /** * - * @author Ludwig + * @author LevelX2 */ public class LongForgottenGohei extends CardImpl { @@ -61,8 +61,10 @@ public class LongForgottenGohei extends CardImpl { public LongForgottenGohei(UUID ownerId) { super(ownerId, 261, "Long-Forgotten Gohei", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{3}"); this.expansionSetCode = "CHK"; + // Arcane spells you cast cost {1} less to cast. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SpellsCostReductionControllerEffect(arcaneFilter, 1))); + // Spirit creatures you control get +1/+1. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, spiritFilter, false))); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java new file mode 100644 index 00000000000..c2010548151 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ChangelingTest.java @@ -0,0 +1,63 @@ +/* + * 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 ChangelingTest extends CardTestPlayerBase { + + /** + * Casting changelings with a Long-Forgotten Gohei in play reduces its casting cost by {1}. + */ + + @Test + public void testLongForgottenGohei() { + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + addCard(Zone.HAND, playerA, "Woodland Changeling"); + + addCard(Zone.BATTLEFIELD, playerA, "Long-Forgotten Gohei"); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Woodland Changeling"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Woodland Changeling", 0); // Casting cost of spell is not reduced so not on the battlefield + assertHandCount(playerA, "Woodland Changeling", 1); + + } + +} \ No newline at end of file diff --git a/Mage/src/mage/MageObjectImpl.java b/Mage/src/mage/MageObjectImpl.java index ea8ec877183..83eb715b6fa 100644 --- a/Mage/src/mage/MageObjectImpl.java +++ b/Mage/src/mage/MageObjectImpl.java @@ -40,6 +40,7 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.keyword.ChangelingAbility; import mage.constants.CardType; import mage.game.Game; +import mage.util.CardUtil; import mage.util.GameLog; public abstract class MageObjectImpl implements MageObject { @@ -176,17 +177,14 @@ public abstract class MageObjectImpl implements MageObject { } if (this.subtype.contains(value)) { return true; - } - else { // checking for Changeling - // first make sure input parameter is not creature type + } else { // checking for Changeling + // first make sure input parameter is a creature type // if so, then ChangelingAbility doesn't matter - if (value.equals("Mountain") || value.equals("Island") || value.equals("Plains") - || value.equals("Forest") || value.equals("Swamp") || value.equals("Aura") - || value.equals("Equipment") || value.equals("Fortification") || value.equals("Shrine")) { + if (CardUtil.isNonCreatureSubtype(value)) { return false; } // as it is creature subtype, then check the existence of Changeling - return abilities.contains(ChangelingAbility.getInstance()) || this.subtype.contains(ChangelingAbility.ALL_CREATURE_TYPE); + return abilities.contains(ChangelingAbility.getInstance()) || this.subtype.contains(ChangelingAbility.ALL_CREATURE_TYPE); } } diff --git a/Mage/src/mage/util/CardUtil.java b/Mage/src/mage/util/CardUtil.java index 32705d881b6..475c3a2c107 100644 --- a/Mage/src/mage/util/CardUtil.java +++ b/Mage/src/mage/util/CardUtil.java @@ -28,6 +28,7 @@ package mage.util; +import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -74,6 +75,12 @@ public class CardUtil { static String numberStrings[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "ninteen", "twenty"}; + public static final String[] NON_CHANGELING_SUBTYPES_VALUES = new String[] { "Mountain", "Forest", "Plains", "Swamp", "Island", + "Aura", "Curse", "Shrine", + "Equipment", "Fortification", "Contraption", + "Trap", "Arcane"}; + public static final Set NON_CREATURE_SUBTYPES = new HashSet<>(Arrays.asList(NON_CHANGELING_SUBTYPES_VALUES)); + /** * Checks whether two cards share card types. * @@ -637,5 +644,8 @@ public class CardUtil { } return mana; } - + + public static boolean isNonCreatureSubtype(String subtype) { + return NON_CREATURE_SUBTYPES.contains(subtype); + } }