[DMU] Implemented Danitha, Benalia's Hope

This commit is contained in:
Daniel Bomar 2022-09-08 13:19:59 -05:00
parent 48df6902e1
commit 2a227af0be
No known key found for this signature in database
GPG key ID: C86C8658F4023918
3 changed files with 123 additions and 6 deletions

View file

@ -14,6 +14,7 @@ import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.card.AuraCardCanAttachToPermanentId;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -72,9 +73,11 @@ class BoonweaverGiantEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) { return false; }
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
UUID sourcePermanentId = sourcePermanent == null ? null : sourcePermanent.getId();
FilterCard filter = new FilterCard("Aura card");
filter.add(CardType.ENCHANTMENT.getPredicate());
filter.add(SubType.AURA.getPredicate());
filter.add(new AuraCardCanAttachToPermanentId(sourcePermanentId));
Card card = null;
@ -105,13 +108,12 @@ class BoonweaverGiantEffect extends OneShotEffect {
// Aura card found - attach it
if (card != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
game.getState().setValue("attachTo:" + card.getId(), permanent);
if (sourcePermanent != null) {
game.getState().setValue("attachTo:" + card.getId(), sourcePermanent);
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
if (permanent != null) {
return permanent.addAttachment(card.getId(), source, game);
if (sourcePermanent != null) {
return sourcePermanent.addAttachment(card.getId(), source, game);
}
}
return true;

View file

@ -0,0 +1,114 @@
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.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;
/**
*
* @author weirddan455
*/
public final class DanithaBenaliasHope extends CardImpl {
public DanithaBenaliasHope(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.KNIGHT);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
// First strike
this.addAbility(FirstStrikeAbility.getInstance());
// Vigilance
this.addAbility(VigilanceAbility.getInstance());
// Lifelink
this.addAbility(LifelinkAbility.getInstance());
// 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.
this.addAbility(new EntersBattlefieldTriggeredAbility(new DanithaBenaliasHopeEffect(), true));
}
private DanithaBenaliasHope(final DanithaBenaliasHope card) {
super(card);
}
@Override
public DanithaBenaliasHope copy() {
return new DanithaBenaliasHope(this);
}
}
class DanithaBenaliasHopeEffect extends OneShotEffect {
public DanithaBenaliasHopeEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "put an Aura or Equipment card from your hand or graveyard onto the battlefield attached to Danitha";
}
private DanithaBenaliasHopeEffect(final DanithaBenaliasHopeEffect effect) {
super(effect);
}
@Override
public DanithaBenaliasHopeEffect copy() {
return new DanithaBenaliasHopeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
UUID sourcePermanentId = sourcePermanent == null ? null : sourcePermanent.getId();
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);
}
target.setNotTarget(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);
}
}
}
return true;
}
}

View file

@ -86,6 +86,7 @@ public final class DominariaUnited extends ExpansionSet {
cards.add(new SetCardInfo("Crystal Grotto", 246, Rarity.COMMON, mage.cards.c.CrystalGrotto.class));
cards.add(new SetCardInfo("Cult Conscript", 88, Rarity.UNCOMMON, mage.cards.c.CultConscript.class));
cards.add(new SetCardInfo("Cut Down", 89, Rarity.UNCOMMON, mage.cards.c.CutDown.class));
cards.add(new SetCardInfo("Danitha, Benalia's Hope", 15, Rarity.RARE, mage.cards.d.DanithaBenaliasHope.class));
cards.add(new SetCardInfo("Deathbloom Gardener", 159, Rarity.COMMON, mage.cards.d.DeathbloomGardener.class));
cards.add(new SetCardInfo("Destroy Evil", 17, Rarity.COMMON, mage.cards.d.DestroyEvil.class));
cards.add(new SetCardInfo("Djinn of the Fountain", 47, Rarity.UNCOMMON, mage.cards.d.DjinnOfTheFountain.class));