From 32227e27ff10ec8104a614b824bf986e9fcedead Mon Sep 17 00:00:00 2001 From: Evan Kranzler <theelk801@gmail.com> Date: Tue, 31 May 2022 18:39:37 -0400 Subject: [PATCH] [CLB] Implemented Druidic Ritual --- Mage.Sets/src/mage/cards/d/DruidicRitual.java | 115 ++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 116 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/d/DruidicRitual.java diff --git a/Mage.Sets/src/mage/cards/d/DruidicRitual.java b/Mage.Sets/src/mage/cards/d/DruidicRitual.java new file mode 100644 index 0000000000..78408d472a --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DruidicRitual.java @@ -0,0 +1,115 @@ +package mage.cards.d; + +import mage.abilities.Ability; +import mage.abilities.dynamicvalue.common.CardTypeAssignment; +import mage.abilities.effects.OneShotEffect; +import mage.cards.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DruidicRitual extends CardImpl { + + public DruidicRitual(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}"); + + // You may mill three cards. Then return up to one creature card and up to one land card from your graveyard to your hand. + this.getSpellAbility().addEffect(new DruidicRitualEffect()); + } + + private DruidicRitual(final DruidicRitual card) { + super(card); + } + + @Override + public DruidicRitual copy() { + return new DruidicRitual(this); + } +} + +class DruidicRitualEffect extends OneShotEffect { + + DruidicRitualEffect() { + super(Outcome.Benefit); + staticText = "you may mill three cards. Then return up to one creature card " + + "and up to one land card from your graveyard to your hand"; + } + + private DruidicRitualEffect(final DruidicRitualEffect effect) { + super(effect); + } + + @Override + public DruidicRitualEffect copy() { + return new DruidicRitualEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + if (player.chooseUse(outcome, "Mill three cards?", source, game)) { + player.millCards(3, source, game); + } + TargetCard target = new RevivalExperimentTarget(); + player.choose(outcome, target, source, game); + player.moveCards(new CardsImpl(target.getTargets()), Zone.HAND, source, game); + return true; + } +} + +class RevivalExperimentTarget extends TargetCardInYourGraveyard { + + private static final CardTypeAssignment cardTypeAssigner = new CardTypeAssignment(CardType.CREATURE, CardType.LAND); + + RevivalExperimentTarget() { + super(0, 2, StaticFilters.FILTER_CARD_CREATURE_OR_LAND, true); + } + + private RevivalExperimentTarget(final RevivalExperimentTarget target) { + super(target); + } + + @Override + public RevivalExperimentTarget copy() { + return new RevivalExperimentTarget(this); + } + + @Override + public boolean canTarget(UUID playerId, UUID id, Ability ability, Game game) { + if (!super.canTarget(playerId, id, ability, game)) { + return false; + } + Card card = game.getCard(id); + if (card == null) { + return false; + } + if (this.getTargets().isEmpty()) { + return true; + } + Cards cards = new CardsImpl(this.getTargets()); + cards.add(card); + return cardTypeAssigner.getRoleCount(cards, game) >= cards.size(); + } + + + @Override + public Set<UUID> possibleTargets(UUID sourceControllerId, Ability source, Game game) { + Set<UUID> possibleTargets = super.possibleTargets(sourceControllerId, source, game); + possibleTargets.removeIf(uuid -> !this.canTarget(sourceControllerId, uuid, null, game)); + return possibleTargets; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index a567dc6ff4..356b61326a 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -107,6 +107,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Dread Linnorm", 225, Rarity.COMMON, mage.cards.d.DreadLinnorm.class)); cards.add(new SetCardInfo("Dream Fracture", 66, Rarity.COMMON, mage.cards.d.DreamFracture.class)); cards.add(new SetCardInfo("Drillworks Mole", 311, Rarity.UNCOMMON, mage.cards.d.DrillworksMole.class)); + cards.add(new SetCardInfo("Druidic Ritual", 227, Rarity.COMMON, mage.cards.d.DruidicRitual.class)); cards.add(new SetCardInfo("Duke Ulder Ravengard", 272, Rarity.RARE, mage.cards.d.DukeUlderRavengard.class)); cards.add(new SetCardInfo("Dungeon Delver", 67, Rarity.UNCOMMON, mage.cards.d.DungeonDelver.class)); cards.add(new SetCardInfo("Dungeoneer's Pack", 312, Rarity.UNCOMMON, mage.cards.d.DungeoneersPack.class));