Skip to content

Commit

Permalink
adjust Danitha, Benalia's Hope
Browse files Browse the repository at this point in the history
eliminate superfluous hand/graveyard selection choice

(related to #11213)
  • Loading branch information
xenohedron committed Sep 28, 2023
1 parent 41874b0 commit f4ad851
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 25 deletions.
45 changes: 20 additions & 25 deletions Mage.Sets/src/mage/cards/d/DanithaBenaliasHope.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package mage.cards.d;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.constants.*;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.abilities.keyword.LifelinkAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.*;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.card.AuraCardCanAttachToPermanentId;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInYourGraveyard;

import java.util.UUID;

/**
*
Expand Down Expand Up @@ -84,29 +81,27 @@ public boolean apply(Game game, Ability source) {
}
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
UUID sourcePermanentId = sourcePermanent == null ? null : sourcePermanent.getId();
String sourcePermanentName = sourcePermanent == null ? "" : sourcePermanent.getName();
FilterCard filter = new FilterCard("an Aura or Equipment card");
filter.add(Predicates.or(
Predicates.and(SubType.AURA.getPredicate(), new AuraCardCanAttachToPermanentId(sourcePermanentId)),
SubType.EQUIPMENT.getPredicate()
));
TargetCard target;
if (controller.chooseUse(outcome, "Look in Hand or Graveyard?", null, "Hand", "Graveyard", source, game)) {
target = new TargetCardInHand(filter);
} else {
target = new TargetCardInYourGraveyard(filter);
}
Cards cards = new CardsImpl();
cards.addAllCards(controller.getHand().getCards(filter, game));
cards.addAllCards(controller.getGraveyard().getCards(filter, game));
TargetCard target = new TargetCard(Zone.ALL, filter);
target.withNotTarget(true);
if (target.canChoose(controller.getId(), source, game)) {
controller.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (sourcePermanent != null) {
game.getState().setValue("attachTo:" + card.getId(), sourcePermanent);
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if (sourcePermanent != null) {
sourcePermanent.addAttachment(card.getId(), source, game);
}
target.withChooseHint("to attach to " + sourcePermanentName);
controller.choose(outcome, cards, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (sourcePermanent != null) {
game.getState().setValue("attachTo:" + card.getId(), sourcePermanent);
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if (sourcePermanent != null) {
sourcePermanent.addAttachment(card.getId(), source, game);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}

0 comments on commit f4ad851

Please sign in to comment.