* Tap any number of untapped creatures - added card hint, improved targeting, fixed cheating (example: Harmony Of Nature);

This commit is contained in:
Oleg Agafonov 2021-09-05 13:02:16 +04:00
parent fe4d4c0834
commit bf67c4c6b4
4 changed files with 123 additions and 141 deletions

View file

@ -1,12 +1,9 @@
package mage.cards.d; 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.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
@ -14,22 +11,31 @@ import mage.constants.Outcome;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.permanent.TappedPredicate; import mage.filter.predicate.permanent.TappedPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.AngelToken; import mage.game.permanent.token.AngelToken;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/** /**
*
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public final class DevoutInvocation extends CardImpl { 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) { 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. // 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().addEffect(new DevoutInvocationEffect());
this.getSpellAbility().addHint(new ValueHint(filter.getMessage(), new PermanentsOnBattlefieldCount(filter)));
} }
private DevoutInvocation(final DevoutInvocation card) { private DevoutInvocation(final DevoutInvocation card) {
@ -44,14 +50,8 @@ public final class DevoutInvocation extends CardImpl {
class DevoutInvocationEffect extends OneShotEffect { class DevoutInvocationEffect extends OneShotEffect {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("untapped creatures you control");
static {
filter.add(TappedPredicate.UNTAPPED);
}
public DevoutInvocationEffect() { 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"; 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,36 +62,31 @@ class DevoutInvocationEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
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; int tappedAmount = 0;
TargetPermanent target = new TargetPermanent(0, 1, filter, false); for (UUID permanentId : target.getTargets()) {
while (controller.canRespond()) { Permanent permanent = game.getPermanent(permanentId);
target.clearChosen(); if (permanent != null && permanent.tap(source, game)) {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
Map<String, Serializable> 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++; tappedAmount++;
} }
} else {
break;
}
} else {
break;
}
} }
if (tappedAmount > 0) { if (tappedAmount > 0) {
AngelToken angelToken = new AngelToken(); AngelToken angelToken = new AngelToken();
angelToken.putOntoBattlefield(tappedAmount, game, source, source.getControllerId()); angelToken.putOntoBattlefield(tappedAmount, game, source, source.getControllerId());
} }
return true; return true;
} }
return false;
}
@Override @Override
public DevoutInvocationEffect copy() { public DevoutInvocationEffect copy() {

View file

@ -1,34 +1,40 @@
package mage.cards.h; 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.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.TappedPredicate; import mage.filter.predicate.permanent.TappedPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class HarmonyOfNature extends CardImpl { 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) { 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. // 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().addEffect(new HarmonyOfNatureEffect());
this.getSpellAbility().addHint(new ValueHint(filter.getMessage(), new PermanentsOnBattlefieldCount(filter)));
} }
private HarmonyOfNature(final HarmonyOfNature card) { private HarmonyOfNature(final HarmonyOfNature card) {
@ -43,15 +49,8 @@ public final class HarmonyOfNature extends CardImpl {
class HarmonyOfNatureEffect extends OneShotEffect { 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() { 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"; staticText = "Tap any number of untapped creatures you control. You gain 4 life for each creature tapped this way";
} }
@ -62,35 +61,29 @@ class HarmonyOfNatureEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
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; int tappedAmount = 0;
TargetPermanent target = new TargetPermanent(0, 1, filter, false); for (UUID permanentId : target.getTargets()) {
while (true) { Permanent permanent = game.getPermanent(permanentId);
target.clearChosen(); if (permanent != null && permanent.tap(source, game)) {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) {
Map<String, Serializable> 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++; tappedAmount++;
} }
} else {
break;
}
} else {
break;
}
} }
if (tappedAmount > 0) { if (tappedAmount > 0) {
controller.gainLife(tappedAmount * 4, game, source); controller.gainLife(tappedAmount * 4, game, source);
} }
return true; return true;
} }
return false;
}
@Override @Override
public HarmonyOfNatureEffect copy() { public HarmonyOfNatureEffect copy() {

View file

@ -1,34 +1,40 @@
package mage.cards.m; 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.Ability;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.TappedPredicate; import mage.filter.predicate.permanent.TappedPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/** /**
*
* @author fireshoes * @author fireshoes
*/ */
public final class MarshalingTheTroops extends CardImpl { 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) { 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. // 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().addEffect(new MarshalingTheTroopsEffect());
this.getSpellAbility().addHint(new ValueHint(filter.getMessage(), new PermanentsOnBattlefieldCount(filter)));
} }
private MarshalingTheTroops(final MarshalingTheTroops card) { private MarshalingTheTroops(final MarshalingTheTroops card) {
@ -43,15 +49,8 @@ public final class MarshalingTheTroops extends CardImpl {
class MarshalingTheTroopsEffect extends OneShotEffect { 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() { 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"; staticText = "Tap any number of untapped creatures you control. You gain 4 life for each creature tapped this way";
} }
@ -62,35 +61,29 @@ class MarshalingTheTroopsEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
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; int tappedAmount = 0;
TargetPermanent target = new TargetPermanent(0, 1, filter, false); for (UUID permanentId : target.getTargets()) {
while (true) { Permanent permanent = game.getPermanent(permanentId);
target.clearChosen(); if (permanent != null && permanent.tap(source, game)) {
if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && target.choose(Outcome.Tap, source.getControllerId(), source.getSourceId(), game)) {
Map<String, Serializable> 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++; tappedAmount++;
} }
} else {
break;
}
} else {
break;
}
} }
if (tappedAmount > 0) { if (tappedAmount > 0) {
controller.gainLife(tappedAmount * 4, game, source); controller.gainLife(tappedAmount * 4, game, source);
} }
return true; return true;
} }
return false;
}
@Override @Override
public MarshalingTheTroopsEffect copy() { public MarshalingTheTroopsEffect copy() {

View file

@ -1,4 +1,3 @@
package org.mage.test.cards.abilities.oneshot.destroy; package org.mage.test.cards.abilities.oneshot.destroy;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
@ -7,7 +6,6 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class WrathOfGodTest extends CardTestPlayerBase { public class WrathOfGodTest extends CardTestPlayerBase {
@ -33,8 +31,11 @@ public class WrathOfGodTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wrath of God"); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wrath of God");
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT); setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute(); execute();
assertAllCommandsUsed();
assertPermanentCount(playerA, "Silvercoat Lion", 0); assertPermanentCount(playerA, "Silvercoat Lion", 0);
assertPermanentCount(playerA, "Mossbridge Troll", 0); assertPermanentCount(playerA, "Mossbridge Troll", 0);
assertPermanentCount(playerA, "Darksteel Gargoyle", 1); assertPermanentCount(playerA, "Darksteel Gargoyle", 1);