From ce5e61e612bf65fd5cec6c4c75b63435fe5f087a Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 9 Sep 2019 12:54:48 -0400 Subject: [PATCH] Implemented Mystical Dispute --- .../src/mage/cards/m/MysticalDispute.java | 73 +++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + 2 files changed, 74 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MysticalDispute.java diff --git a/Mage.Sets/src/mage/cards/m/MysticalDispute.java b/Mage.Sets/src/mage/cards/m/MysticalDispute.java new file mode 100644 index 0000000000..f2c290d95e --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MysticalDispute.java @@ -0,0 +1,73 @@ +package mage.cards.m; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.common.CounterUnlessPaysEffect; +import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.stack.StackObject; +import mage.target.Target; +import mage.target.TargetSpell; + +import java.util.Collection; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MysticalDispute extends CardImpl { + + public MysticalDispute(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); + + // This spell costs {2} less to cast if it targets a blue spell. + this.addAbility(new SimpleStaticAbility( + Zone.STACK, new SpellCostReductionSourceEffect(2, MysticalDisputeCondition.instance) + ).setRuleAtTheTop(true)); + + // Counter target spell unless its controller pays {3}. + this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(new GenericManaCost(3))); + this.getSpellAbility().addTarget(new TargetSpell()); + } + + private MysticalDispute(final MysticalDispute card) { + super(card); + } + + @Override + public MysticalDispute copy() { + return new MysticalDispute(this); + } +} + +enum MysticalDisputeCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + StackObject sourceSpell = game.getStack().getStackObject(source.getSourceId()); + if (sourceSpell == null) { + return false; + } + return sourceSpell + .getStackAbility() + .getTargets() + .stream() + .map(Target::getTargets) + .flatMap(Collection::stream) + .map(game::getSpell) + .anyMatch(spell -> spell != null && spell.getColor(game).isBlue()); + } + + @Override + public String toString() { + return "it targets a blue spell"; + } + +} diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 0d5c6226df..7696dbf967 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -67,6 +67,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Mace of the Valiant", 314, Rarity.RARE, mage.cards.m.MaceOfTheValiant.class)); cards.add(new SetCardInfo("Maraleaf Pixie", 196, Rarity.UNCOMMON, mage.cards.m.MaraleafPixie.class)); cards.add(new SetCardInfo("Midnight Clock", 54, Rarity.RARE, mage.cards.m.MidnightClock.class)); + cards.add(new SetCardInfo("Mystical Dispute", 58, Rarity.UNCOMMON, mage.cards.m.MysticalDispute.class)); cards.add(new SetCardInfo("Oko's Accomplices", 310, Rarity.COMMON, mage.cards.o.OkosAccomplices.class)); cards.add(new SetCardInfo("Oko, Thief of Crowns", 197, Rarity.MYTHIC, mage.cards.o.OkoThiefOfCrowns.class)); cards.add(new SetCardInfo("Order of Midnight", 99, Rarity.UNCOMMON, mage.cards.o.OrderOfMidnight.class));