diff --git a/Mage.Sets/src/mage/cards/p/PsionicRitual.java b/Mage.Sets/src/mage/cards/p/PsionicRitual.java new file mode 100644 index 00000000000..f4d2fb3bdcf --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PsionicRitual.java @@ -0,0 +1,106 @@ +package mage.cards.p; + +import mage.ApprovingObject; +import mage.abilities.Ability; +import mage.abilities.costs.common.TapTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileSpellEffect; +import mage.abilities.keyword.ReplicateAbility; +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.StaticFilters; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.permanent.TappedPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; +import mage.target.common.TargetControlledPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PsionicRitual extends CardImpl { + + private static final FilterControlledPermanent filter + = new FilterControlledPermanent(SubType.HORROR, "an untapped Horror you control"); + + static { + filter.add(TappedPredicate.UNTAPPED); + } + + public PsionicRitual(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{U}{U}"); + + // Replicate—Tap an untapped Horror you control. + this.addAbility(new ReplicateAbility(new TapTargetCost(new TargetControlledPermanent(filter)))); + + // Exile target instant or sorcery card from a graveyard and copy it. You may cast the copy without paying its mana cost. + this.getSpellAbility().addEffect(new PsionicRitualEffect()); + this.getSpellAbility().addTarget(new TargetCardInGraveyard(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY)); + + // Exile Psionic Ritual. + this.getSpellAbility().addEffect(new ExileSpellEffect().concatBy("
")); + } + + private PsionicRitual(final PsionicRitual card) { + super(card); + } + + @Override + public PsionicRitual copy() { + return new PsionicRitual(this); + } +} + +class PsionicRitualEffect extends OneShotEffect { + + PsionicRitualEffect() { + super(Outcome.Benefit); + staticText = "exile target instant or sorcery card from a graveyard " + + "and copy it. You may cast the copy without paying its mana cost"; + } + + private PsionicRitualEffect(final PsionicRitualEffect effect) { + super(effect); + } + + @Override + public PsionicRitualEffect copy() { + return new PsionicRitualEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Card card = game.getCard(getTargetPointer().getFirst(game, source)); + if (player == null || card == null) { + return false; + } + player.moveCards(card, Zone.EXILED, source, game); + Card copiedCard = game.copyCard(card, source, source.getControllerId()); + if (copiedCard == null) { + return false; + } + game.getExile().add(source.getSourceId(), "", copiedCard); + game.getState().setZone(copiedCard.getId(), Zone.EXILED); + if (copiedCard.getSpellAbility() == null || !player.chooseUse( + outcome, "Cast the copied card without paying mana cost?", source, game + )) { + return false; + } + game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), Boolean.TRUE); + player.cast( + player.chooseAbilityForCast(copiedCard, game, true), + game, true, new ApprovingObject(source, game) + ); + game.getState().setValue("PlayFromNotOwnHandZone" + copiedCard.getId(), null); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 4d2fef27d0d..a41aba190ee 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -447,6 +447,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Propaganda", 730, Rarity.UNCOMMON, mage.cards.p.Propaganda.class)); cards.add(new SetCardInfo("Prophetic Prism", 335, Rarity.COMMON, mage.cards.p.PropheticPrism.class)); cards.add(new SetCardInfo("Pseudodragon Familiar", 88, Rarity.COMMON, mage.cards.p.PseudodragonFamiliar.class)); + cards.add(new SetCardInfo("Psionic Ritual", 668, Rarity.RARE, mage.cards.p.PsionicRitual.class)); cards.add(new SetCardInfo("Psychic Impetus", 89, Rarity.COMMON, mage.cards.p.PsychicImpetus.class)); cards.add(new SetCardInfo("Psychosis Crawler", 869, Rarity.RARE, mage.cards.p.PsychosisCrawler.class)); cards.add(new SetCardInfo("Pull from Tomorrow", 731, Rarity.RARE, mage.cards.p.PullFromTomorrow.class)); diff --git a/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java b/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java index fc57cccc528..838048a2917 100644 --- a/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/ReplicateAbility.java @@ -31,9 +31,12 @@ public class ReplicateAbility extends StaticAbility implements OptionalAdditiona protected OptionalAdditionalCost additionalCost; public ReplicateAbility(String manaString) { + this(new ManaCostsImpl<>(manaString)); + } + + public ReplicateAbility(Cost cost) { super(Zone.STACK, null); - this.additionalCost = new OptionalAdditionalCostImpl(keywordText, - reminderTextMana, new ManaCostsImpl(manaString)); + this.additionalCost = new OptionalAdditionalCostImpl(keywordText, reminderTextMana, cost); this.additionalCost.setRepeatable(true); setRuleAtTheTop(true); addSubAbility(new ReplicateTriggeredAbility());