* Some code clean up and a new test.

This commit is contained in:
LevelX2 2020-01-14 17:42:58 +01:00
parent 92eba9861d
commit 6455180765
5 changed files with 57 additions and 6 deletions

View file

@ -15,11 +15,11 @@ import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.ObjectPlayerPredicate;
import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayer;
import mage.game.Game; import mage.game.Game;
import java.util.UUID; import java.util.UUID;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
/** /**
* @author TheElk801 * @author TheElk801
@ -59,7 +59,7 @@ public final class DiamondKnight extends CardImpl {
} }
} }
enum DiamondKnightPredicate implements ObjectPlayerPredicate<ObjectSourcePlayer<MageObject>> { enum DiamondKnightPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {
instance; instance;
@Override @Override

View file

@ -119,4 +119,54 @@ public class SpellCastTriggerTest extends CardTestPlayerBase {
assertHandCount(playerA, 5); // one normally drawn + 4 from Read the Bones 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);
}
} }

View file

@ -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 * 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". * "X=[xValue]" example: for X=3 set choice string to "X=3".
* * <br>For ColorChoice use "Red", "Green", "Blue", "Black" or "White"
*
* @param player * @param player
* @param choice * @param choice
*/ */

View file

@ -195,7 +195,7 @@ public final class Predicates {
} }
static <T> List<T> defensiveCopy(Iterable<T> iterable) { static <T> List<T> defensiveCopy(Iterable<T> iterable) {
ArrayList<T> list = new ArrayList<T>(); ArrayList<T> list = new ArrayList<>();
for (T element : iterable) { for (T element : iterable) {
list.add(checkNotNull(element)); list.add(checkNotNull(element));
} }

View file

@ -4,14 +4,14 @@ package mage.filter.predicate.mageobject;
import mage.MageObject; import mage.MageObject;
import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.predicate.ObjectPlayerPredicate;
import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game; import mage.game.Game;
/** /**
* @author LoneFox * @author LoneFox
*/ */
public enum ChosenSubtypePredicate implements ObjectPlayerPredicate<ObjectSourcePlayer<MageObject>> { public enum ChosenSubtypePredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {
instance; instance;
@Override @Override