From fb819f1f51bd9fac41d37cadf8d5076bb640da24 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 6 Sep 2015 23:29:58 +0200 Subject: [PATCH] Added test (failing because bug not fixed yet). Some minor changes. --- .../mage/sets/tenthedition/NantukoHusk.java | 11 ++++-- .../cards/copy/FlameshadowConjuringTest.java | 38 +++++++++++++++++++ .../java/org/mage/test/player/TestPlayer.java | 30 ++++++++++++--- .../permanent/SummoningSicknessPredicate.java | 27 +++++++++++++ 4 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 Mage/src/mage/filter/predicate/permanent/SummoningSicknessPredicate.java diff --git a/Mage.Sets/src/mage/sets/tenthedition/NantukoHusk.java b/Mage.Sets/src/mage/sets/tenthedition/NantukoHusk.java index 473cd6334dd..2f8364c56be 100644 --- a/Mage.Sets/src/mage/sets/tenthedition/NantukoHusk.java +++ b/Mage.Sets/src/mage/sets/tenthedition/NantukoHusk.java @@ -28,16 +28,16 @@ package mage.sets.tenthedition; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Rarity; import mage.MageInt; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.common.continuous.BoostSourceEffect; import mage.cards.CardImpl; +import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Rarity; import mage.constants.Zone; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent; /** @@ -54,7 +54,10 @@ public class NantukoHusk extends CardImpl { this.power = new MageInt(2); this.toughness = new MageInt(2); - this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(2, 2, Duration.EndOfTurn), new SacrificeTargetCost(new TargetControlledCreaturePermanent()))); + + // Sacrifice a creature: Nantuko Husk gets +2/+2 until end of turn. + this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new BoostSourceEffect(2, 2, Duration.EndOfTurn), + new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature"))))); } public NantukoHusk(final NantukoHusk card) { diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/copy/FlameshadowConjuringTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/copy/FlameshadowConjuringTest.java index 423ac6c2084..027a72d3c55 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/copy/FlameshadowConjuringTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/copy/FlameshadowConjuringTest.java @@ -72,4 +72,42 @@ public class FlameshadowConjuringTest extends CardTestPlayerBase { assertLife(playerA, 18); } + /** + * I created a token copy of Wurmcoil Engine and sacrificed it. This gave me + * 4 tokens + */ + @Test + public void testWurmcoilEngine() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 7); + // Whenever a nontoken creature enters the battlefield under your control, you may pay {R}. If you do, put a token onto the battlefield that's a copy of that creature. + // That token gains haste. Exile it at the beginning of the next end step. + addCard(Zone.BATTLEFIELD, playerA, "Flameshadow Conjuring", 1); + // Sacrifice a creature: Nantuko Husk gets +2/+2 until end of turn. + addCard(Zone.BATTLEFIELD, playerA, "Nantuko Husk", 1); + + // Deathtouch, lifelink + // When Wurmcoil Engine dies, put a 3/3 colorless Wurm artifact creature token with deathtouch and a 3/3 colorless Wurm artifact creature token with lifelink onto the battlefield. + addCard(Zone.HAND, playerA, "Wurmcoil Engine", 1); // 6/6 - {6} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wurmcoil Engine"); + setChoice(playerA, "Yes"); + + attack(1, playerA, "Wurmcoil Engine"); + attack(1, playerA, "Nantuko Husk"); + + activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Sacrifice a creature"); + // addTarget(playerA, "Wurmcoil Engine[only copy]"); + setChoice(playerA, "Wurmcoil Engine[only copy]"); + setStopAt(1, PhaseStep.END_TURN); + execute(); + + assertPermanentCount(playerA, "Wurmcoil Engine", 1); + assertPowerToughness(playerA, "Nantuko Husk", 4, 4); + assertLife(playerB, 12); + assertLife(playerA, 26); + + assertPermanentCount(playerA, "Wurm", 2); + + } + } diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index 9526cb9bef0..51027f1e2f9 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -71,6 +71,7 @@ import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.permanent.AttackingPredicate; import mage.filter.predicate.permanent.BlockingPredicate; +import mage.filter.predicate.permanent.SummoningSicknessPredicate; import mage.game.Game; import mage.game.Graveyard; import mage.game.Table; @@ -478,6 +479,7 @@ public class TestPlayer implements Player { FilterCreatureForCombat filter = new FilterCreatureForCombat(); filter.add(new NamePredicate(groups[0])); filter.add(Predicates.not(new AttackingPredicate())); + filter.add(Predicates.not(new SummoningSicknessPredicate())); Permanent attacker = findPermanent(filter, computerPlayer.getId(), game); if (attacker != null && attacker.canAttack(defenderId, game)) { computerPlayer.declareAttacker(attacker.getId(), defenderId, game, false); @@ -571,21 +573,37 @@ public class TestPlayer implements Player { String[] targetList = choose2.split("\\^"); boolean targetFound = false; for (String targetName : targetList) { + boolean originOnly = false; + boolean copyOnly = false; + if (targetName.endsWith("]")) { + if (targetName.endsWith("[no copy]")) { + originOnly = true; + targetName = targetName.substring(0, targetName.length() - 9); + } + if (targetName.endsWith("[only copy]")) { + copyOnly = true; + targetName = targetName.substring(0, targetName.length() - 11); + } + } for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filterPermanent, game)) { if (target.getTargets().contains(permanent.getId())) { continue; } if (permanent.getName().equals(targetName)) { if (target.isNotTarget() || ((TargetPermanent) target).canTarget(computerPlayer.getId(), permanent.getId(), null, game)) { - target.add(permanent.getId(), game); - targetFound = true; - break; + if ((permanent.isCopy() && !originOnly) || (!permanent.isCopy() && !copyOnly)) { + target.add(permanent.getId(), game); + targetFound = true; + break; + } } } else if ((permanent.getName() + "-" + permanent.getExpansionSetCode()).equals(targetName)) { if (target.isNotTarget() || ((TargetPermanent) target).canTarget(computerPlayer.getId(), permanent.getId(), null, game)) { - target.add(permanent.getId(), game); - targetFound = true; - break; + if ((permanent.isCopy() && !originOnly) || (!permanent.isCopy() && !copyOnly)) { + target.add(permanent.getId(), game); + targetFound = true; + break; + } } } } diff --git a/Mage/src/mage/filter/predicate/permanent/SummoningSicknessPredicate.java b/Mage/src/mage/filter/predicate/permanent/SummoningSicknessPredicate.java new file mode 100644 index 00000000000..088e2791af5 --- /dev/null +++ b/Mage/src/mage/filter/predicate/permanent/SummoningSicknessPredicate.java @@ -0,0 +1,27 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.filter.predicate.permanent; + +import mage.filter.predicate.Predicate; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author LevelX2 + */ +public class SummoningSicknessPredicate implements Predicate { + + @Override + public boolean apply(Permanent input, Game game) { + return input.hasSummoningSickness(); + } + + @Override + public String toString() { + return "Summoning sickness"; + } +}