diff --git a/Mage.Sets/src/mage/cards/d/DevoutInvocation.java b/Mage.Sets/src/mage/cards/d/DevoutInvocation.java index f08faaa041..567c3b194e 100644 --- a/Mage.Sets/src/mage/cards/d/DevoutInvocation.java +++ b/Mage.Sets/src/mage/cards/d/DevoutInvocation.java @@ -1,12 +1,9 @@ - package mage.cards.d; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.effects.OneShotEffect; +import mage.abilities.hint.ValueHint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -14,22 +11,31 @@ import mage.constants.Outcome; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.game.permanent.token.AngelToken; import mage.players.Player; import mage.target.TargetPermanent; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; /** - * * @author jeffwadsworth */ public final class DevoutInvocation extends CardImpl { + static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creatures you control"); + + static { + filter.add(TappedPredicate.UNTAPPED); + } + public DevoutInvocation(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{6}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{W}"); // Tap any number of untapped creatures you control. Create a 4/4 white Angel creature token with flying for each creature tapped this way. this.getSpellAbility().addEffect(new DevoutInvocationEffect()); - + this.getSpellAbility().addHint(new ValueHint(filter.getMessage(), new PermanentsOnBattlefieldCount(filter))); } private DevoutInvocation(final DevoutInvocation card) { @@ -44,14 +50,8 @@ public final class DevoutInvocation extends CardImpl { class DevoutInvocationEffect extends OneShotEffect { - private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creatures you control"); - - static { - filter.add(TappedPredicate.UNTAPPED); - } - public DevoutInvocationEffect() { - super(Outcome.PutCreatureInPlay); + super(Outcome.AIDontUseIt); staticText = "Tap any number of untapped creatures you control. Create a 4/4 white Angel creature token with flying for each creature tapped this way"; } @@ -62,35 +62,30 @@ class DevoutInvocationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int tappedAmount = 0; - TargetPermanent target = new TargetPermanent(0, 1, filter, false); - while (controller.canRespond()) { - target.clearChosen(); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - Map options = new HashMap<>(); - options.put("UI.right.btn.text", "Tapping complete"); - controller.choose(outcome, target, source.getControllerId(), game, options); - if (!target.getTargets().isEmpty()) { - UUID creature = target.getFirstTarget(); - if (creature != null) { - game.getPermanent(creature).tap(source, game); - tappedAmount++; - } - } else { - break; - } - } else { - break; - } - } - if (tappedAmount > 0) { - AngelToken angelToken = new AngelToken(); - angelToken.putOntoBattlefield(tappedAmount, game, source, source.getControllerId()); - } - return true; + if (controller == null) { + return false; } - return false; + + TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, DevoutInvocation.filter, true); + controller.choose(outcome, target, source.getSourceId(), game); + if (target.getTargets().isEmpty()) { + return false; + } + + int tappedAmount = 0; + for (UUID permanentId : target.getTargets()) { + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null && permanent.tap(source, game)) { + tappedAmount++; + } + } + + if (tappedAmount > 0) { + AngelToken angelToken = new AngelToken(); + angelToken.putOntoBattlefield(tappedAmount, game, source, source.getControllerId()); + } + + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java b/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java index eeb45455b2..8b65230b2e 100644 --- a/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java +++ b/Mage.Sets/src/mage/cards/h/HarmonyOfNature.java @@ -1,34 +1,40 @@ - package mage.cards.h; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.effects.OneShotEffect; +import mage.abilities.hint.ValueHint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; /** - * * @author fireshoes */ public final class HarmonyOfNature extends CardImpl { + static final FilterControlledPermanent filter = new FilterControlledPermanent("untapped creatures you control"); + + static { + filter.add(TappedPredicate.UNTAPPED); + } + public HarmonyOfNature(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}"); // Tap any number of untapped creatures you control. You gain 4 life for each creature tapped this way. this.getSpellAbility().addEffect(new HarmonyOfNatureEffect()); + this.getSpellAbility().addHint(new ValueHint(filter.getMessage(), new PermanentsOnBattlefieldCount(filter))); } private HarmonyOfNature(final HarmonyOfNature card) { @@ -42,16 +48,9 @@ public final class HarmonyOfNature extends CardImpl { } class HarmonyOfNatureEffect extends OneShotEffect { - - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("untapped creatures you control"); - - static { - filter.add(TargetController.YOU.getControllerPredicate()); - filter.add(TappedPredicate.UNTAPPED); - } public HarmonyOfNatureEffect() { - super(Outcome.GainLife); + super(Outcome.AIDontUseIt); staticText = "Tap any number of untapped creatures you control. You gain 4 life for each creature tapped this way"; } @@ -62,34 +61,28 @@ class HarmonyOfNatureEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int tappedAmount = 0; - TargetPermanent target = new TargetPermanent(0, 1, filter, false); - while (true) { - target.clearChosen(); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { - Map options = new HashMap<>(); - options.put("UI.right.btn.text", "Tapping complete"); - controller.choose(outcome, target, source.getControllerId(), game, options); - if (!target.getTargets().isEmpty()) { - UUID creature = target.getFirstTarget(); - if (creature != null) { - game.getPermanent(creature).tap(source, game); - tappedAmount++; - } - } else { - break; - } - } else { - break; - } - } - if (tappedAmount > 0) { - controller.gainLife(tappedAmount * 4, game, source); - } - return true; + if (controller == null) { + return false; } - return false; + + TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, HarmonyOfNature.filter, true); + controller.choose(outcome, target, source.getSourceId(), game); + if (target.getTargets().isEmpty()) { + return false; + } + + int tappedAmount = 0; + for (UUID permanentId : target.getTargets()) { + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null && permanent.tap(source, game)) { + tappedAmount++; + } + } + + if (tappedAmount > 0) { + controller.gainLife(tappedAmount * 4, game, source); + } + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java b/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java index 14ab154bc4..a3d30b01d4 100644 --- a/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java +++ b/Mage.Sets/src/mage/cards/m/MarshalingTheTroops.java @@ -1,34 +1,40 @@ - package mage.cards.m; -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; import mage.abilities.effects.OneShotEffect; +import mage.abilities.hint.ValueHint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.filter.common.FilterCreaturePermanent; +import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.permanent.TappedPredicate; import mage.game.Game; +import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; /** - * * @author fireshoes */ public final class MarshalingTheTroops extends CardImpl { + static final FilterControlledPermanent filter = new FilterControlledPermanent("untapped creatures you control"); + + static { + filter.add(TappedPredicate.UNTAPPED); + } + public MarshalingTheTroops(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}"); // Tap any number of untapped creatures you control. You gain 4 life for each creature tapped this way. this.getSpellAbility().addEffect(new MarshalingTheTroopsEffect()); + this.getSpellAbility().addHint(new ValueHint(filter.getMessage(), new PermanentsOnBattlefieldCount(filter))); } private MarshalingTheTroops(final MarshalingTheTroops card) { @@ -42,16 +48,9 @@ public final class MarshalingTheTroops extends CardImpl { } class MarshalingTheTroopsEffect extends OneShotEffect { - - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("untapped creatures you control"); - - static { - filter.add(TargetController.YOU.getControllerPredicate()); - filter.add(TappedPredicate.UNTAPPED); - } public MarshalingTheTroopsEffect() { - super(Outcome.GainLife); + super(Outcome.AIDontUseIt); staticText = "Tap any number of untapped creatures you control. You gain 4 life for each creature tapped this way"; } @@ -62,34 +61,28 @@ class MarshalingTheTroopsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int tappedAmount = 0; - TargetPermanent target = new TargetPermanent(0, 1, filter, false); - while (true) { - target.clearChosen(); - if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) { - Map options = new HashMap<>(); - options.put("UI.right.btn.text", "Tapping complete"); - controller.choose(outcome, target, source.getControllerId(), game, options); - if (!target.getTargets().isEmpty()) { - UUID creature = target.getFirstTarget(); - if (creature != null) { - game.getPermanent(creature).tap(source, game); - tappedAmount++; - } - } else { - break; - } - } else { - break; - } - } - if (tappedAmount > 0) { - controller.gainLife(tappedAmount * 4, game, source); - } - return true; + if (controller == null) { + return false; } - return false; + + TargetPermanent target = new TargetControlledPermanent(0, Integer.MAX_VALUE, MarshalingTheTroops.filter, true); + controller.choose(outcome, target, source.getSourceId(), game); + if (target.getTargets().isEmpty()) { + return false; + } + + int tappedAmount = 0; + for (UUID permanentId : target.getTargets()) { + Permanent permanent = game.getPermanent(permanentId); + if (permanent != null && permanent.tap(source, game)) { + tappedAmount++; + } + } + + if (tappedAmount > 0) { + controller.gainLife(tappedAmount * 4, game, source); + } + return true; } @Override diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/WrathOfGodTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/WrathOfGodTest.java index cbafdd2ebf..5828bf3e20 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/WrathOfGodTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/oneshot/destroy/WrathOfGodTest.java @@ -1,4 +1,3 @@ - package org.mage.test.cards.abilities.oneshot.destroy; import mage.constants.PhaseStep; @@ -7,34 +6,36 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author LevelX2 */ public class WrathOfGodTest extends CardTestPlayerBase { @Test public void testDestroy() { - addCard(Zone.BATTLEFIELD, playerA, "Plains",4); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 4); addCard(Zone.HAND, playerA, "Wrath of God"); - addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // If Mossbridge Troll would be destroyed, regenerate it. // Tap any number of untapped creatures you control other than Mossbridge Troll with total power 10 or greater: Mossbridge Troll gets +20/+20 until end of turn. - addCard(Zone.BATTLEFIELD, playerA, "Mossbridge Troll"); + addCard(Zone.BATTLEFIELD, playerA, "Mossbridge Troll"); // Flying // Darksteel Gargoyle is indestructible. ("Destroy" effects and lethal damage don't destroy it.) - addCard(Zone.BATTLEFIELD, playerA, "Darksteel Gargoyle"); + addCard(Zone.BATTLEFIELD, playerA, "Darksteel Gargoyle"); + + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); + addCard(Zone.BATTLEFIELD, playerB, "Mossbridge Troll"); + addCard(Zone.BATTLEFIELD, playerB, "Darksteel Gargoyle"); - addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); - addCard(Zone.BATTLEFIELD, playerB, "Mossbridge Troll"); - addCard(Zone.BATTLEFIELD, playerB, "Darksteel Gargoyle"); - castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wrath of God"); + setStrictChooseMode(true); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); + assertPermanentCount(playerA, "Silvercoat Lion", 0); assertPermanentCount(playerA, "Mossbridge Troll", 0); assertPermanentCount(playerA, "Darksteel Gargoyle", 1);