* Changeling - Fixed that some non creature subtypes of cards (e.g. Arcane) were positive filtered for Changeling (fixes #991).

This commit is contained in:
LevelX2 2015-05-25 16:51:09 +02:00
parent b753654384
commit 4298e66e02
4 changed files with 82 additions and 9 deletions

View file

@ -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)));
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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<String> 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);
}
}