From 593df4375836ef855298951007ba28da05795522 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 15 Aug 2018 06:47:33 +0400 Subject: [PATCH] Refactoring: replace custom creature tokens with basic class (1 card); Added blink test; --- Mage.Sets/src/mage/cards/d/DimirKeyrune.java | 29 +++++------------ .../cards/continuous/EnsoulArtifactTest.java | 31 ++++++++++++++++++- ...chedWithActivatedAbilityOrSpellEffect.java | 6 ++-- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DimirKeyrune.java b/Mage.Sets/src/mage/cards/d/DimirKeyrune.java index 0611879445f..954042ad97e 100644 --- a/Mage.Sets/src/mage/cards/d/DimirKeyrune.java +++ b/Mage.Sets/src/mage/cards/d/DimirKeyrune.java @@ -17,6 +17,7 @@ import mage.constants.Duration; import mage.constants.Zone; import mage.game.permanent.token.TokenImpl; import mage.game.permanent.token.Token; +import mage.game.permanent.token.custom.CreatureToken; /** * @@ -32,7 +33,12 @@ public final class DimirKeyrune extends CardImpl { this.addAbility(new BlackManaAbility()); // {U}{B}: Dimir Keyrune becomes a 2/2 blue and black Horror and can't be blocked this turn - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect(new DimirKeyruneToken(), "", Duration.EndOfTurn), new ManaCostsImpl("{U}{B}"))); + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesCreatureSourceEffect( + new CreatureToken(2, 2, "2/2 blue and black Horror creature that can't be blocked") + .withColor("UB") + .withSubType(SubType.HORROR) + .withAbility(new CantBeBlockedSourceAbility()), + "", Duration.EndOfTurn), new ManaCostsImpl("{U}{B}"))); } public DimirKeyrune(final DimirKeyrune card) { @@ -43,25 +49,4 @@ public final class DimirKeyrune extends CardImpl { public DimirKeyrune copy() { return new DimirKeyrune(this); } - - private static class DimirKeyruneToken extends TokenImpl { - DimirKeyruneToken() { - super("Horror", "2/2 blue and black Horror until end of turn and can't be blocked this turn"); - cardType.add(CardType.ARTIFACT); - cardType.add(CardType.CREATURE); - color.setBlue(true); - color.setBlack(true); - subtype.add(SubType.HORROR); - power = new MageInt(2); - toughness = new MageInt(2); - this.addAbility(new CantBeBlockedSourceAbility()); - } - public DimirKeyruneToken(final DimirKeyruneToken token) { - super(token); - } - - public DimirKeyruneToken copy() { - return new DimirKeyruneToken(this); - } - } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/EnsoulArtifactTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/EnsoulArtifactTest.java index 2d3819dc0da..abee351081c 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/continuous/EnsoulArtifactTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/continuous/EnsoulArtifactTest.java @@ -2,7 +2,9 @@ package org.mage.test.cards.continuous; import mage.abilities.keyword.IndestructibleAbility; +import mage.constants.CardType; import mage.constants.PhaseStep; +import mage.constants.SubType; import mage.constants.Zone; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -16,8 +18,9 @@ public class EnsoulArtifactTest extends CardTestPlayerBase { /** * Tests boost disappeared after creature died */ + @Test - public void testBoostWithUndying() { + public void test_Boost() { addCard(Zone.BATTLEFIELD, playerA, "Darksteel Citadel", 1); addCard(Zone.BATTLEFIELD, playerA, "Island", 2); @@ -30,7 +33,33 @@ public class EnsoulArtifactTest extends CardTestPlayerBase { execute(); assertAbility(playerA, "Darksteel Citadel", IndestructibleAbility.getInstance(), true); + assertType("Darksteel Citadel", CardType.CREATURE, true); assertPowerToughness(playerA, "Darksteel Citadel", 5, 5); } + @Test + public void test_BoostDisappearedOnBlink() { + addCard(Zone.BATTLEFIELD, playerA, "Darksteel Citadel", 1); + + // blink + addCard(Zone.HAND, playerA, "Momentary Blink", 1); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + + // Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types. + addCard(Zone.HAND, playerA, "Ensoul Artifact"); + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ensoul Artifact", "Darksteel Citadel"); + castSpell(1, PhaseStep.BEGIN_COMBAT, playerA, "Momentary Blink", "Darksteel Citadel"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Momentary Blink", 0); + assertPermanentCount(playerA, "Darksteel Citadel", 1); + assertPowerToughness(playerA, "Darksteel Citadel", 0, 0); + assertType("Darksteel Citadel", CardType.CREATURE, false); + assertAbility(playerA, "Darksteel Citadel", IndestructibleAbility.getInstance(), true); + assertPermanentCount(playerA, "Ensoul Artifact", 0); + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect.java index 18d7b54bb43..d127b409438 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect.java @@ -16,7 +16,6 @@ import mage.game.permanent.token.Token; public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends ContinuousEffectImpl { public enum LoseType { - NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE_AND_PT } @@ -102,6 +101,7 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co } break; + case ColorChangingEffects_5: if (sublayer == SubLayer.NA) { if (loseType == LoseType.ALL) { @@ -116,6 +116,7 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co } } break; + case AbilityAddingRemovingEffects_6: if (sublayer == SubLayer.NA) { switch (loseType) { @@ -132,12 +133,13 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co } break; + case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { permanentAttachedTo.getPower().setValue(token.getPower().getValue()); permanentAttachedTo.getToughness().setValue(token.getToughness().getValue()); - break; } + break; } } if (!attachedExists) {