From 2a227af0be5ad021c09424e71dfd938213168497 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Thu, 8 Sep 2022 13:19:59 -0500 Subject: [PATCH] [DMU] Implemented Danitha, Benalia's Hope --- .../src/mage/cards/b/BoonweaverGiant.java | 14 ++- .../src/mage/cards/d/DanithaBenaliasHope.java | 114 ++++++++++++++++++ Mage.Sets/src/mage/sets/DominariaUnited.java | 1 + 3 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DanithaBenaliasHope.java diff --git a/Mage.Sets/src/mage/cards/b/BoonweaverGiant.java b/Mage.Sets/src/mage/cards/b/BoonweaverGiant.java index 058afd270ab..e0fa1b145ab 100644 --- a/Mage.Sets/src/mage/cards/b/BoonweaverGiant.java +++ b/Mage.Sets/src/mage/cards/b/BoonweaverGiant.java @@ -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; diff --git a/Mage.Sets/src/mage/cards/d/DanithaBenaliasHope.java b/Mage.Sets/src/mage/cards/d/DanithaBenaliasHope.java new file mode 100644 index 00000000000..0dcd13685aa --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DanithaBenaliasHope.java @@ -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; + } +} diff --git a/Mage.Sets/src/mage/sets/DominariaUnited.java b/Mage.Sets/src/mage/sets/DominariaUnited.java index 0654bdb2947..c5f6eccb8ba 100644 --- a/Mage.Sets/src/mage/sets/DominariaUnited.java +++ b/Mage.Sets/src/mage/sets/DominariaUnited.java @@ -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));