From 3315d036648a7d9dbfd6ed950bda70461f154f0f Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 3 Apr 2024 10:15:11 -0400 Subject: [PATCH] [BIG] Implement Omenpath Journey --- .../src/mage/cards/o/OmenpathJourney.java | 124 ++++++++++++++++++ Mage.Sets/src/mage/sets/TheBigScore.java | 1 + 2 files changed, 125 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/o/OmenpathJourney.java diff --git a/Mage.Sets/src/mage/cards/o/OmenpathJourney.java b/Mage.Sets/src/mage/cards/o/OmenpathJourney.java new file mode 100644 index 00000000000..cd0419fd783 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OmenpathJourney.java @@ -0,0 +1,124 @@ +package mage.cards.o; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInLibrary; +import mage.target.common.TargetCardWithDifferentNameInLibrary; +import mage.util.CardUtil; + +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class OmenpathJourney extends CardImpl { + + public OmenpathJourney(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); + + // When Omenpath Journey enters the battlefield, search your library for up to five land cards that have different names, exile them, then shuffle. + this.addAbility(new EntersBattlefieldTriggeredAbility(new OmenpathJourneySearchEffect())); + + // At the beginning of your end step, choose a card at random exiled with Omenpath Journey and put it onto the battlefield tapped. + this.addAbility(new BeginningOfEndStepTriggeredAbility( + new OmenpathJourneyChooseEffect(), TargetController.YOU, false + )); + } + + private OmenpathJourney(final OmenpathJourney card) { + super(card); + } + + @Override + public OmenpathJourney copy() { + return new OmenpathJourney(this); + } +} + +class OmenpathJourneySearchEffect extends OneShotEffect { + + OmenpathJourneySearchEffect() { + super(Outcome.Benefit); + staticText = "search your library for up to five land cards that have different names, exile them, then shuffle"; + } + + private OmenpathJourneySearchEffect(final OmenpathJourneySearchEffect effect) { + super(effect); + } + + @Override + public OmenpathJourneySearchEffect copy() { + return new OmenpathJourneySearchEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + TargetCardInLibrary target = new TargetCardWithDifferentNameInLibrary( + 0, 5, StaticFilters.FILTER_CARD_LAND + ); + player.searchLibrary(target, source, game); + Set cards = target + .getTargets() + .stream() + .map(uuid -> player.getLibrary().getCard(uuid, game)) + .filter(Objects::nonNull) + .collect(Collectors.toSet()); + player.moveCardsToExile( + cards, source, game, true, + CardUtil.getExileZoneId(game, source), + CardUtil.getSourceName(game, source) + ); + player.shuffleLibrary(source, game); + return true; + } +} + +class OmenpathJourneyChooseEffect extends OneShotEffect { + + OmenpathJourneyChooseEffect() { + super(Outcome.Benefit); + staticText = "choose a card at random exiled with {this} and put it onto the battlefield tapped"; + } + + private OmenpathJourneyChooseEffect(final OmenpathJourneyChooseEffect effect) { + super(effect); + } + + @Override + public OmenpathJourneyChooseEffect copy() { + return new OmenpathJourneyChooseEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source)); + return player != null + && exileZone != null + && !exileZone.isEmpty() + && player.moveCards( + exileZone.getRandom(game), Zone.BATTLEFIELD, source, game, + true, false, false, null + ); + } +} diff --git a/Mage.Sets/src/mage/sets/TheBigScore.java b/Mage.Sets/src/mage/sets/TheBigScore.java index 538d33cdb9e..73dbbd42d8d 100644 --- a/Mage.Sets/src/mage/sets/TheBigScore.java +++ b/Mage.Sets/src/mage/sets/TheBigScore.java @@ -30,6 +30,7 @@ public final class TheBigScore extends ExpansionSet { cards.add(new SetCardInfo("Lotus Ring", 24, Rarity.MYTHIC, mage.cards.l.LotusRing.class)); cards.add(new SetCardInfo("Molten Duplication", 14, Rarity.MYTHIC, mage.cards.m.MoltenDuplication.class)); cards.add(new SetCardInfo("Oltec Matterweaver", 3, Rarity.MYTHIC, mage.cards.o.OltecMatterweaver.class)); + cards.add(new SetCardInfo("Omenpath Journey", 18, Rarity.MYTHIC, mage.cards.o.OmenpathJourney.class)); cards.add(new SetCardInfo("Pest Control", 22, Rarity.MYTHIC, mage.cards.p.PestControl.class)); cards.add(new SetCardInfo("Rest in Peace", 4, Rarity.MYTHIC, mage.cards.r.RestInPeace.class)); cards.add(new SetCardInfo("Simulacrum Synthesizer", 6, Rarity.MYTHIC, mage.cards.s.SimulacrumSynthesizer.class));