From 69b78031a3e2b06b98efcbdc4669f3616be7d0c3 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Tue, 26 Jan 2021 13:59:52 -0600 Subject: [PATCH] [KHM] Implemented Haunting Voyage --- .../src/mage/cards/h/HauntingVoyage.java | 98 +++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + 2 files changed, 99 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/h/HauntingVoyage.java diff --git a/Mage.Sets/src/mage/cards/h/HauntingVoyage.java b/Mage.Sets/src/mage/cards/h/HauntingVoyage.java new file mode 100644 index 0000000000..c4ee1dc563 --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HauntingVoyage.java @@ -0,0 +1,98 @@ +package mage.cards.h; + +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.condition.common.ForetoldCondition; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; +import mage.abilities.keyword.ForetellAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.common.FilterBySubtypeCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * + * @author weirddan455 + */ +public final class HauntingVoyage extends CardImpl { + + public HauntingVoyage(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{B}{B}"); + + // Choose a creature type. Return up to two creature cards of the chosen type from your graveyard to the battlefield. + // If this spell was foretold, return all creature cards of the chosen type from your graveyard to the battlefield instead. + this.getSpellAbility().addEffect(new ChooseCreatureTypeEffect(Outcome.PutCreatureInPlay)); + this.getSpellAbility().addEffect(new HauntingVoyageEffect()); + + // Foretell {5}{B}{B} + this.addAbility(new ForetellAbility(this, "{5}{B}{B}")); + } + + private HauntingVoyage(final HauntingVoyage card) { + super(card); + } + + @Override + public HauntingVoyage copy() { + return new HauntingVoyage(this); + } +} + +class HauntingVoyageEffect extends OneShotEffect { + + public HauntingVoyageEffect() { + super(Outcome.PutCreatureInPlay); + staticText = "Return up to two creature cards of the chosen type from your graveyard to the battlefield. " + + "If this spell was foretold, return all creature cards of the chosen type from your graveyard to the battlefield instead"; + } + + private HauntingVoyageEffect(final HauntingVoyageEffect effect) { + super(effect); + } + + public HauntingVoyageEffect copy() { + return new HauntingVoyageEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + SubType chosenSubType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game); + if (controller != null && chosenSubType != null) { + Set cardsToBattlefield = new LinkedHashSet<>(); + if (!ForetoldCondition.instance.apply(game, source)) { + TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 2, new FilterBySubtypeCard(chosenSubType), true); + controller.chooseTarget(outcome, target, source, game); + for (UUID cardId : target.getTargets()) { + Card card = game.getCard(cardId); + if (card != null) { + cardsToBattlefield.add(card); + } + } + } else { + for (UUID cardId : controller.getGraveyard()) { + Card card = game.getCard(cardId); + if (card != null && card.hasSubtype(chosenSubType, game)) { + cardsToBattlefield.add(card); + } + } + } + if (!cardsToBattlefield.isEmpty()) { + controller.moveCards(cardsToBattlefield, Zone.BATTLEFIELD, source, game); + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index e2b31ae5b3..f1f5d6c388 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -161,6 +161,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Halvar, God of Battle", 15, Rarity.MYTHIC, mage.cards.h.HalvarGodOfBattle.class)); cards.add(new SetCardInfo("Harald Unites the Elves", 213, Rarity.RARE, mage.cards.h.HaraldUnitesTheElves.class)); cards.add(new SetCardInfo("Harald, King of Skemfar", 212, Rarity.UNCOMMON, mage.cards.h.HaraldKingOfSkemfar.class)); + cards.add(new SetCardInfo("Haunting Voyage", 98, Rarity.MYTHIC, mage.cards.h.HauntingVoyage.class)); cards.add(new SetCardInfo("Hengegate Pathway", 260, Rarity.RARE, mage.cards.h.HengegatePathway.class)); cards.add(new SetCardInfo("Highland Forest", 261, Rarity.COMMON, mage.cards.h.HighlandForest.class)); cards.add(new SetCardInfo("Horizon Seeker", 175, Rarity.COMMON, mage.cards.h.HorizonSeeker.class));