adjust Danitha, Benalia's Hope

eliminate superfluous hand/graveyard selection choice

(related to #11213)
This commit is contained in:
xenohedron 2023-09-27 20:51:54 -04:00
parent 41874b0b4b
commit f4ad851233
2 changed files with 139 additions and 25 deletions

View file

@ -1,17 +1,14 @@
package mage.cards.d; package mage.cards.d;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.*;
import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.keyword.LifelinkAbility; import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl; import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardSetInfo; import mage.cards.*;
import mage.constants.*;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.predicate.Predicates; import mage.filter.predicate.Predicates;
import mage.filter.predicate.card.AuraCardCanAttachToPermanentId; import mage.filter.predicate.card.AuraCardCanAttachToPermanentId;
@ -19,8 +16,8 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInYourGraveyard; import java.util.UUID;
/** /**
* *
@ -84,29 +81,27 @@ class DanithaBenaliasHopeEffect extends OneShotEffect {
} }
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
UUID sourcePermanentId = sourcePermanent == null ? null : sourcePermanent.getId(); UUID sourcePermanentId = sourcePermanent == null ? null : sourcePermanent.getId();
String sourcePermanentName = sourcePermanent == null ? "" : sourcePermanent.getName();
FilterCard filter = new FilterCard("an Aura or Equipment card"); FilterCard filter = new FilterCard("an Aura or Equipment card");
filter.add(Predicates.or( filter.add(Predicates.or(
Predicates.and(SubType.AURA.getPredicate(), new AuraCardCanAttachToPermanentId(sourcePermanentId)), Predicates.and(SubType.AURA.getPredicate(), new AuraCardCanAttachToPermanentId(sourcePermanentId)),
SubType.EQUIPMENT.getPredicate() SubType.EQUIPMENT.getPredicate()
)); ));
TargetCard target; Cards cards = new CardsImpl();
if (controller.chooseUse(outcome, "Look in Hand or Graveyard?", null, "Hand", "Graveyard", source, game)) { cards.addAllCards(controller.getHand().getCards(filter, game));
target = new TargetCardInHand(filter); cards.addAllCards(controller.getGraveyard().getCards(filter, game));
} else { TargetCard target = new TargetCard(Zone.ALL, filter);
target = new TargetCardInYourGraveyard(filter);
}
target.withNotTarget(true); target.withNotTarget(true);
if (target.canChoose(controller.getId(), source, game)) { target.withChooseHint("to attach to " + sourcePermanentName);
controller.chooseTarget(outcome, target, source, game); controller.choose(outcome, cards, target, source, game);
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
if (card != null) { if (card != null) {
if (sourcePermanent != null) { if (sourcePermanent != null) {
game.getState().setValue("attachTo:" + card.getId(), sourcePermanent); game.getState().setValue("attachTo:" + card.getId(), sourcePermanent);
} }
controller.moveCards(card, Zone.BATTLEFIELD, source, game); controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if (sourcePermanent != null) { if (sourcePermanent != null) {
sourcePermanent.addAttachment(card.getId(), source, game); sourcePermanent.addAttachment(card.getId(), source, game);
}
} }
} }
return true; return true;

View file

@ -0,0 +1,119 @@
package org.mage.test.cards.single.dmu;
import mage.abilities.keyword.DeathtouchAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.player.TestPlayer;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author xenohedron
*/
public class DanithaBenaliasHopeTest extends CardTestPlayerBase {
private static final String danitha = "Danitha, Benalia's Hope"; // {4}{W} 4/4 First strike, vigilance, lifelink
// When Danitha, Benalia's Hope enters the battlefield, you may put an Aura or Equipment card
// from your hand or graveyard onto the battlefield attached to Danitha.
private static final String wings = "Nimbus Wings"; // Enchanted creature gets +1/+2 and has flying.
private static final String flail = "Gorgon Flail"; // Equipped creature gets +1/+1 and has deathtouch.
private static final String swords = "Swords to Plowshares"; // Exile target creature. Its controller gains life equal to its power.
@Test
public void testAuraFromGraveyard() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.GRAVEYARD, playerA, wings);
addCard(Zone.HAND, playerA, danitha);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
setChoice(playerA, wings);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, danitha, 5, 6);
assertAbility(playerA, danitha, FlyingAbility.getInstance(), true);
}
@Test
public void testNothingToAttach() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.HAND, playerA, danitha);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // attempt to use ability
setChoice(playerA, TestPlayer.CHOICE_SKIP);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, danitha, 4, 4);
}
@Test
public void testEquipmentFromHand() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
addCard(Zone.HAND, playerA, flail);
addCard(Zone.HAND, playerA, danitha);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
setChoice(playerA, flail);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, danitha, 5, 5);
assertAbility(playerA, danitha, DeathtouchAbility.getInstance(), true);
}
@Test
public void testEquipmentFromHandButExiled() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
addCard(Zone.HAND, playerA, flail);
addCard(Zone.HAND, playerA, danitha);
addCard(Zone.HAND, playerA, swords);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, swords, danitha);
setChoice(playerA, flail);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, flail, 1);
assertExileCount(playerA, danitha, 1);
assertLife(playerA, 24);
}
@Test
public void testAuraFromGraveyardButExiled() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 6);
addCard(Zone.GRAVEYARD, playerA, wings);
addCard(Zone.HAND, playerA, danitha);
addCard(Zone.HAND, playerA, swords);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, danitha);
setChoice(playerA, true); // use ability
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, swords, danitha);
setChoice(playerA, TestPlayer.CHOICE_SKIP); // no longer can attach Aura
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertGraveyardCount(playerA, wings, 1);
assertExileCount(playerA, danitha, 1);
assertLife(playerA, 24);
}
}