From 645518076582bfffa912170a6f3d469a4d735e1c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 14 Jan 2020 17:42:58 +0100 Subject: [PATCH] * Some code clean up and a new test. --- Mage.Sets/src/mage/cards/d/DiamondKnight.java | 4 +- .../cards/triggers/SpellCastTriggerTest.java | 50 +++++++++++++++++++ .../base/impl/CardTestPlayerAPIImpl.java | 3 +- .../mage/filter/predicate/Predicates.java | 2 +- .../mageobject/ChosenSubtypePredicate.java | 4 +- 5 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DiamondKnight.java b/Mage.Sets/src/mage/cards/d/DiamondKnight.java index adccd6c302..406854098e 100644 --- a/Mage.Sets/src/mage/cards/d/DiamondKnight.java +++ b/Mage.Sets/src/mage/cards/d/DiamondKnight.java @@ -15,11 +15,11 @@ import mage.constants.Outcome; import mage.constants.SubType; import mage.counters.CounterType; import mage.filter.FilterSpell; -import mage.filter.predicate.ObjectPlayerPredicate; import mage.filter.predicate.ObjectSourcePlayer; import mage.game.Game; import java.util.UUID; +import mage.filter.predicate.ObjectSourcePlayerPredicate; /** * @author TheElk801 @@ -59,7 +59,7 @@ public final class DiamondKnight extends CardImpl { } } -enum DiamondKnightPredicate implements ObjectPlayerPredicate> { +enum DiamondKnightPredicate implements ObjectSourcePlayerPredicate> { instance; @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java index 65fb8c29b6..5dad6f58ac 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/triggers/SpellCastTriggerTest.java @@ -119,4 +119,54 @@ public class SpellCastTriggerTest extends CardTestPlayerBase { assertHandCount(playerA, 5); // one normally drawn + 4 from Read the Bones } + + @Test + public void testDiamondKnightTrigger() { + addCard(Zone.BATTLEFIELD, playerA, "Volcanic Island", 6); + + // Vigilance + // As Diamond Knight enters the battlefield, choose a color. + // Whenever you cast a spell of the chosen color, put a +1/+1 counter on Diamond Knight. + addCard(Zone.HAND, playerA, "Diamond Knight", 1); // Creature 1/1 - {3} + + // Target 3 damage + addCard(Zone.HAND, playerA, "Lightning Bolt", 1); // {R} + // Draw a card. + // Escape—{2}{U}, Exile five other cards from your graveyard. + addCard(Zone.HAND, playerA, "Glimpse of Freedom", 1); // Instant {1}{U} + addCard(Zone.GRAVEYARD, playerA, "Mountain", 5); // Instant {1}{U} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Diamond Knight"); + setChoice(playerA, "Blue"); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", playerB); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Glimpse of Freedom"); + + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Glimpse of Freedom"); + setChoice(playerA,"Mountain"); + setChoice(playerA,"Mountain"); + setChoice(playerA,"Mountain"); + setChoice(playerA,"Mountain"); + setChoice(playerA,"Mountain"); + + + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + setStrictChooseMode(true); + execute(); + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Diamond Knight", 1); + assertPowerToughness(playerA, "Diamond Knight", 3, 3); + assertGraveyardCount(playerA, "Lightning Bolt", 1); + assertLife(playerB, 17); + assertGraveyardCount(playerA, "Glimpse of Freedom", 1); + assertExileCount(playerA, 5); + assertHandCount(playerA, 3); + + } + + + + } diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index e789aff52e..1f8c4638e7 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -1552,7 +1552,8 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement /** * For use choices set "Yes" or "No" the the choice string. For X values set * "X=[xValue]" example: for X=3 set choice string to "X=3". - * + *
For ColorChoice use "Red", "Green", "Blue", "Black" or "White" + * * @param player * @param choice */ diff --git a/Mage/src/main/java/mage/filter/predicate/Predicates.java b/Mage/src/main/java/mage/filter/predicate/Predicates.java index 33ff0d2cc7..6e6796c711 100644 --- a/Mage/src/main/java/mage/filter/predicate/Predicates.java +++ b/Mage/src/main/java/mage/filter/predicate/Predicates.java @@ -195,7 +195,7 @@ public final class Predicates { } static List defensiveCopy(Iterable iterable) { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList<>(); for (T element : iterable) { list.add(checkNotNull(element)); } diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java index aaf8518193..bbde6c6b86 100644 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java @@ -4,14 +4,14 @@ package mage.filter.predicate.mageobject; import mage.MageObject; import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.constants.SubType; -import mage.filter.predicate.ObjectPlayerPredicate; import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.game.Game; /** * @author LoneFox */ -public enum ChosenSubtypePredicate implements ObjectPlayerPredicate> { +public enum ChosenSubtypePredicate implements ObjectSourcePlayerPredicate> { instance; @Override