diff --git a/Mage.Sets/src/mage/cards/a/AwakenTheAncient.java b/Mage.Sets/src/mage/cards/a/AwakenTheAncient.java index 37549cb360..1dc0f1b818 100644 --- a/Mage.Sets/src/mage/cards/a/AwakenTheAncient.java +++ b/Mage.Sets/src/mage/cards/a/AwakenTheAncient.java @@ -65,7 +65,8 @@ public class AwakenTheAncient extends CardImpl { this.addAbility(ability); // Enchanted Mountain is a 7/7 red Giant creature with haste. It's still a land. - Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new GiantToken(), "Enchanted Mountain is a 7/7 red Giant creature with haste. It's still a land", Duration.WhileOnBattlefield)); + Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect( + new GiantToken(), "Enchanted Mountain is a 7/7 red Giant creature with haste. It's still a land", Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR)); this.addAbility(ability2); } diff --git a/Mage.Sets/src/mage/cards/c/CorruptedZendikon.java b/Mage.Sets/src/mage/cards/c/CorruptedZendikon.java index 01744b45ca..e63ced72db 100644 --- a/Mage.Sets/src/mage/cards/c/CorruptedZendikon.java +++ b/Mage.Sets/src/mage/cards/c/CorruptedZendikon.java @@ -68,7 +68,7 @@ public class CorruptedZendikon extends CardImpl { // Enchanted land is a 3/3 black Ooze creature. It's still a land. Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new CorruptedZendikonOozeToken(), - "Enchanted land is a 3/3 black Ooze creature. It's still a land.", Duration.WhileOnBattlefield)); + "Enchanted land is a 3/3 black Ooze creature. It's still a land.", Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR)); this.addAbility(ability2); // When enchanted land dies, return that card to its owner's hand. diff --git a/Mage.Sets/src/mage/cards/c/CrusherZendikon.java b/Mage.Sets/src/mage/cards/c/CrusherZendikon.java index c6b9ab3fc9..0f3d07b837 100644 --- a/Mage.Sets/src/mage/cards/c/CrusherZendikon.java +++ b/Mage.Sets/src/mage/cards/c/CrusherZendikon.java @@ -67,7 +67,8 @@ public class CrusherZendikon extends CardImpl { Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); // Enchanted land is a 4/2 red Beast creature with trample. It's still a land. - Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new BeastToken(), "Enchanted land is a 4/2 red Beast creature with trample. It's still a land.", Duration.WhileOnBattlefield)); + Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect( + new BeastToken(), "Enchanted land is a 4/2 red Beast creature with trample. It's still a land.", Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR)); this.addAbility(ability2); // When enchanted land dies, return that card to its owner's hand. Ability ability3 = new DiesAttachedTriggeredAbility(new ReturnToHandAttachedEffect(), "enchanted land", false); diff --git a/Mage.Sets/src/mage/cards/d/DeepFreeze.java b/Mage.Sets/src/mage/cards/d/DeepFreeze.java index a7b21e6873..3af29de23e 100644 --- a/Mage.Sets/src/mage/cards/d/DeepFreeze.java +++ b/Mage.Sets/src/mage/cards/d/DeepFreeze.java @@ -69,7 +69,7 @@ public class DeepFreeze extends CardImpl { this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new DeepFreezeToken(), "Enchanted creature has base power and toughness 0/4, has defender, loses all other abilities, and is a blue Wall in addition to its other colors and types", - Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ABILITIES_AND_PT) + Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ABILITIES) )); } diff --git a/Mage.Sets/src/mage/cards/g/GuardianZendikon.java b/Mage.Sets/src/mage/cards/g/GuardianZendikon.java index a8d3d66af3..02ba012b78 100644 --- a/Mage.Sets/src/mage/cards/g/GuardianZendikon.java +++ b/Mage.Sets/src/mage/cards/g/GuardianZendikon.java @@ -70,7 +70,8 @@ public class GuardianZendikon extends CardImpl { Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); - Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new WallToken(), "Enchanted land is a 2/6 white wall creature with defender. It's still a land", Duration.WhileOnBattlefield)); + Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect( + new GuardianZendikonWallToken(), "Enchanted land is a 2/6 white wall creature with defender. It's still a land", Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR)); this.addAbility(ability2); Ability ability3 = new DiesAttachedTriggeredAbility(new ReturnToHandAttachedEffect(), "enchanted land", false); @@ -87,9 +88,9 @@ public class GuardianZendikon extends CardImpl { } } -class WallToken extends TokenImpl { +class GuardianZendikonWallToken extends TokenImpl { - WallToken() { + GuardianZendikonWallToken() { super("", "2/6 white wall creature with defender"); cardType.add(CardType.CREATURE); color.setWhite(true); @@ -98,11 +99,11 @@ class WallToken extends TokenImpl { toughness = new MageInt(6); this.addAbility(DefenderAbility.getInstance()); } - public WallToken(final WallToken token) { + public GuardianZendikonWallToken(final GuardianZendikonWallToken token) { super(token); } - public WallToken copy() { - return new WallToken(this); + public GuardianZendikonWallToken copy() { + return new GuardianZendikonWallToken(this); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/l/LivingTerrain.java b/Mage.Sets/src/mage/cards/l/LivingTerrain.java index 019471ebb0..21c05cb293 100644 --- a/Mage.Sets/src/mage/cards/l/LivingTerrain.java +++ b/Mage.Sets/src/mage/cards/l/LivingTerrain.java @@ -61,7 +61,8 @@ public class LivingTerrain extends CardImpl { Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); // Enchanted land is a 5/6 green Treefolk creature that's still a land. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new TreefolkToken(), "Enchanted land is a 5/6 green Treefolk creature that's still a land", Duration.WhileOnBattlefield))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect( + new TreefolkToken(), "Enchanted land is a 5/6 green Treefolk creature that's still a land", Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR))); } public LivingTerrain(final LivingTerrain card) { diff --git a/Mage.Sets/src/mage/cards/v/VastwoodZendikon.java b/Mage.Sets/src/mage/cards/v/VastwoodZendikon.java index 2e667eb368..b86de1f50b 100644 --- a/Mage.Sets/src/mage/cards/v/VastwoodZendikon.java +++ b/Mage.Sets/src/mage/cards/v/VastwoodZendikon.java @@ -69,7 +69,7 @@ public class VastwoodZendikon extends CardImpl { Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect( new ElementalCreatureToken(6, 4, "6/4 green Elemental creature", new ObjectColor("G")), - "Enchanted land is a 6/4 green Elemental creature. It's still a land", Duration.WhileOnBattlefield )); + "Enchanted land is a 6/4 green Elemental creature. It's still a land", Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR)); this.addAbility(ability2); Ability ability3 = new DiesAttachedTriggeredAbility(new ReturnToHandAttachedEffect(), "enchanted land", false); diff --git a/Mage.Sets/src/mage/cards/w/WindZendikon.java b/Mage.Sets/src/mage/cards/w/WindZendikon.java index 44b4444888..836e9fafdc 100644 --- a/Mage.Sets/src/mage/cards/w/WindZendikon.java +++ b/Mage.Sets/src/mage/cards/w/WindZendikon.java @@ -66,7 +66,9 @@ public class WindZendikon extends CardImpl { Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); - Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(new ElementalToken(), "Enchanted land is a 2/2 blue Elemental creature with flying. It's still a land", Duration.WhileOnBattlefield)); + Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect( + new WindZendikonElementalToken(), "Enchanted land is a 2/2 blue Elemental creature with flying. It's still a land", + Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.COLOR)); this.addAbility(ability2); Ability ability3 = new DiesAttachedTriggeredAbility(new ReturnToHandAttachedEffect(), "enchanted land", false); @@ -82,8 +84,8 @@ public class WindZendikon extends CardImpl { return new WindZendikon(this); } - class ElementalToken extends TokenImpl { - ElementalToken() { + class WindZendikonElementalToken extends TokenImpl { + WindZendikonElementalToken() { super("", "2/2 blue Elemental creature with flying"); cardType.add(CardType.CREATURE); color.setBlue(true); @@ -92,12 +94,12 @@ public class WindZendikon extends CardImpl { toughness = new MageInt(2); addAbility(FlyingAbility.getInstance()); } - public ElementalToken(final ElementalToken token) { + public WindZendikonElementalToken(final WindZendikonElementalToken token) { super(token); } - public ElementalToken copy() { - return new ElementalToken(this); + public WindZendikonElementalToken copy() { + return new WindZendikonElementalToken(this); } } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BecomesCreatureAttachedTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BecomesCreatureAttachedTest.java new file mode 100644 index 0000000000..7b2b927014 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/BecomesCreatureAttachedTest.java @@ -0,0 +1,114 @@ +/* + * 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.continuous; + +import mage.ObjectColor; +import mage.abilities.AbilitiesImpl; +import mage.abilities.keyword.DefenderAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.constants.CardType; +import mage.constants.PhaseStep; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.permanent.Permanent; +import org.junit.Assert; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author JayDi85 + */ +public class BecomesCreatureAttachedTest extends CardTestPlayerBase { + + // Dryad Arbor -- green creature land + + @Test + public void test_CreatureLandWithColor() { + addCard(Zone.BATTLEFIELD, playerA, "Dryad Arbor", 1); + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Dryad Arbor", 1); + assertPowerToughness(playerA, "Dryad Arbor", 1, 1); + // land + assertColor(playerA, "Forest", "WUBGR", false); + // dryad + assertColor(playerA, "Dryad Arbor", "G", true); + assertColor(playerA, "Dryad Arbor", "WUBR", false); + } + + @Test + public void test_AttachToLandWithColorReplace() { + // Enchanted land is a 2/2 blue Elemental creature with flying. It’s still a land. + addCard(Zone.HAND, playerA, "Wind Zendikon", 1); + addCard(Zone.BATTLEFIELD, playerA, "Island", 1); + + addCard(Zone.BATTLEFIELD, playerA, "Dryad Arbor", 1); + + // attach to forest and check color changing + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wind Zendikon", "Dryad Arbor"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Dryad Arbor", 1); + assertPowerToughness(playerA, "Dryad Arbor", 2, 2); + assertType("Dryad Arbor", CardType.CREATURE, true); + assertType("Dryad Arbor", CardType.LAND, true); + assertAbilities(playerA, "Dryad Arbor", new AbilitiesImpl<>(FlyingAbility.getInstance())); + assertColor(playerA, "Dryad Arbor", "U", true); + assertColor(playerA, "Dryad Arbor", "WBGR", false); + } + + @Test + public void test_AttachToLandWithColorAdd() { + // Enchanted land is a 2/2 blue Elemental creature with flying. It’s still a land. + addCard(Zone.HAND, playerA, "Deep Freeze", 1); + addCard(Zone.BATTLEFIELD, playerA, "Island", 3); + + addCard(Zone.BATTLEFIELD, playerA, "Dryad Arbor", 1); + + // attach to forest and check color changing + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Deep Freeze", "Dryad Arbor"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertPermanentCount(playerA, "Dryad Arbor", 1); + assertPowerToughness(playerA, "Dryad Arbor", 0, 4); + assertType("Dryad Arbor", CardType.CREATURE, true); + assertType("Dryad Arbor", CardType.LAND, true); + assertType("Dryad Arbor", CardType.LAND, SubType.WALL); + assertAbilities(playerA, "Dryad Arbor", new AbilitiesImpl<>(DefenderAbility.getInstance())); + assertColor(playerA, "Dryad Arbor", "UG", true); + assertColor(playerA, "Dryad Arbor", "WBR", false); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java index aca32daee2..ae71f50586 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedEffect.java @@ -40,7 +40,7 @@ import mage.game.permanent.token.Token; public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { public enum LoseType { - NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE_AND_PT, ABILITIES_AND_PT + NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE, COLOR } protected Token token; @@ -98,7 +98,7 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { switch (loseType) { case ALL: case ALL_BUT_COLOR: - case ABILITIES_SUBTYPE_AND_PT: + case ABILITIES_SUBTYPE: permanent.getSubtype(game).retainAll(SubType.getLandTypes(false)); break; } @@ -107,12 +107,12 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { permanent.getSubtype(game).add(t); } } - } break; + case ColorChangingEffects_5: if (sublayer == SubLayer.NA) { - if (loseType == LoseType.ALL) { + if (loseType == LoseType.ALL || loseType == LoseType.COLOR) { permanent.getColor(game).setBlack(false); permanent.getColor(game).setGreen(false); permanent.getColor(game).setBlue(false); @@ -124,29 +124,29 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl { } } break; + case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { switch (loseType) { case ALL: case ALL_BUT_COLOR: case ABILITIES: - case ABILITIES_AND_PT: - case ABILITIES_SUBTYPE_AND_PT: + case ABILITIES_SUBTYPE: permanent.removeAllAbilities(source.getSourceId(), game); break; } for (Ability ability : token.getAbilities()) { permanent.addAbility(ability, source.getSourceId(), game); } - } break; + case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { permanent.getPower().setValue(token.getPower().getValue()); permanent.getToughness().setValue(token.getToughness().getValue()); - break; } + break; } } return true;