diff --git a/Mage.Sets/src/mage/sets/theros/GodsWilling.java b/Mage.Sets/src/mage/sets/theros/GodsWilling.java index 821ed08b709..f2bfc0b233b 100644 --- a/Mage.Sets/src/mage/sets/theros/GodsWilling.java +++ b/Mage.Sets/src/mage/sets/theros/GodsWilling.java @@ -46,7 +46,6 @@ public class GodsWilling extends CardImpl { super(ownerId, 16, "Gods Willing", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{W}"); this.expansionSetCode = "THS"; - // Target creature you control gains protection from the color of your choice until end of turn. Scry 1. this.getSpellAbility().addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn)); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java index 10d0b3c74e2..457f3407508 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/HexproofTest.java @@ -76,7 +76,9 @@ public class HexproofTest extends CardTestPlayerBase { addCard(Zone.BATTLEFIELD, playerB, "Island", 4); addCard(Zone.HAND, playerB, "Into the Void"); + // Return up to two target creatures to their owners' hands. castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Into the Void", "Elder of Laurels^Arbor Elf"); + // Target creature you control gets +1/+1 and gains hexproof until end of turn. (It can't be the target of spells or abilities your opponents control.) castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerA, "Ranger's Guile", "Elder of Laurels"); setStopAt(2, PhaseStep.END_TURN); 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 bf48c2f8738..e538a04b4a5 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 @@ -446,7 +446,7 @@ public class TestPlayer extends ComputerPlayer { for (String targetName: targetList) { for (Card card: this.getHand().getCards(((TargetCardInHand)target).getFilter(), game)) { if (card.getName().equals(targetName) || (card.getName()+"-"+card.getExpansionSetCode()).equals(targetName)) { - if (((TargetCardInHand)target).canTarget(source.getControllerId(), card.getId(), source, game) && !target.getTargets().contains(card.getId())) { + if (((TargetCardInHand)target).canTarget(this.getId(), card.getId(), source, game) && !target.getTargets().contains(card.getId())) { target.add(card.getId(), game); targetFound = true; break; @@ -663,42 +663,61 @@ public class TestPlayer extends ComputerPlayer { int index = 0; int targetsSet = 0; for (String targetName: targetList) { + if (targetName.startsWith("mode=")) { + int modeNr = Integer.parseInt(targetName.substring(5, 6)); + if (modeNr == 0 || modeNr > ability.getModes().size()) { + throw new UnsupportedOperationException("Given mode number (" + modeNr + ") not available for " + ability.toString()); + } + int modeCounter = 1; + for (Mode mode :ability.getModes().values()) { + if (modeCounter == modeNr) { + ability.getModes().setMode(mode); + index=0; // reset target index if mode changes + break; + } + modeCounter++; + } + targetName = targetName.substring(6); + } + if (ability.getTargets().size() == 0) { + throw new AssertionError("Ability has no targets. " + ability.toString()); + } + if (index >= ability.getTargets().size()) { + break; // this can happen if targets should be set but can't be used because of hexproof e.g. + } + Target currentTarget = ability.getTargets().get(index); if (targetName.startsWith("targetPlayer=")) { target = targetName.substring(targetName.indexOf("targetPlayer=") + 13); for (Player player: game.getPlayers().values()) { if (player.getName().equals(target)) { - ability.getTargets().get(index).addTarget(player.getId(), ability, game); + currentTarget.addTarget(player.getId(), ability, game); index++; targetsSet++; break; } } } else { - if (ability.getTargets().size() == 0) { - throw new AssertionError("Ability has no targets. " + ability.toString()); - } - for (UUID id: ability.getTargets().get(0).possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) { + for (UUID id: currentTarget.possibleTargets(ability.getSourceId(), ability.getControllerId(), game)) { MageObject object = game.getObject(id); if (object != null && ((!targetName.isEmpty() && object.getName().startsWith(targetName)) || (targetName.isEmpty() && object.getName().isEmpty()))) { - if (index >= ability.getTargets().size()) { - index--; + if (currentTarget.getNumberOfTargets() == 1) { + currentTarget.clearChosen(); } - if (ability.getTargets().get(index).getNumberOfTargets() == 1) { - ability.getTargets().get(index).clearChosen(); - } - if (ability.getTargets().get(index) instanceof TargetCreaturePermanentAmount) { + if (currentTarget instanceof TargetCreaturePermanentAmount) { // supports only to set the complete amount to one target - TargetCreaturePermanentAmount targetAmount = (TargetCreaturePermanentAmount) ability.getTargets().get(index); + TargetCreaturePermanentAmount targetAmount = (TargetCreaturePermanentAmount) currentTarget; targetAmount.setAmount(ability, game); int amount = targetAmount.getAmountRemaining(); targetAmount.addTarget(id, amount,ability, game); targetsSet++; } else { - ability.getTargets().get(index).addTarget(id, ability, game); + currentTarget.addTarget(id, ability, game); targetsSet++; } - index++; + if (currentTarget.getTargets().size() == currentTarget.getMaxNumberOfTargets()) { + index++; + } break; } } 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 771de0af82d..abb23bd72ad 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 @@ -850,6 +850,14 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement player.addAction(turnNum, step, "activate:Cast " + cardName + "$targetPlayer=" + target.getName() + "$manaInPool=" + manaInPool); } + /** + * + * @param turnNum + * @param step + * @param player + * @param cardName + * @param targetName for modes you can add "mode=3" before target name, multiple targets can be seperated by ^ + */ public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName) { player.addAction(turnNum, step, "activate:Cast " + cardName + "$target=" + targetName); } diff --git a/Mage/src/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java b/Mage/src/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java index 1767fb43c20..a6af9b8dcc6 100644 --- a/Mage/src/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/continuous/GainProtectionFromColorTargetEffect.java @@ -51,7 +51,7 @@ public class GainProtectionFromColorTargetEffect extends GainAbilityTargetEffect public GainProtectionFromColorTargetEffect(Duration duration) { super(new ProtectionAbility(new FilterCard()), duration); - choice = new ChoiceColor(); + choice = new ChoiceColor(true); } public GainProtectionFromColorTargetEffect(final GainProtectionFromColorTargetEffect effect) {