diff --git a/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java b/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java new file mode 100644 index 0000000000..131e36d9e6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ExtinctionEvent.java @@ -0,0 +1,81 @@ +package mage.cards.e; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.ConvertedManaCostParityPredicate; +import mage.game.Game; +import mage.players.Player; + +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class ExtinctionEvent extends CardImpl { + + public ExtinctionEvent(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}"); + + // Choose odd or even. Exile each creature with a converted mana cost of the chosen value. + this.getSpellAbility().addEffect(new ExtinctionEventEffect()); + } + + private ExtinctionEvent(final ExtinctionEvent card) { + super(card); + } + + @Override + public ExtinctionEvent copy() { + return new ExtinctionEvent(this); + } +} + +class ExtinctionEventEffect extends OneShotEffect { + + private static final FilterPermanent evenFilter = new FilterCreaturePermanent(); + private static final FilterPermanent oddFilter = new FilterCreaturePermanent(); + + static { + evenFilter.add(ConvertedManaCostParityPredicate.EVEN); + oddFilter.add(ConvertedManaCostParityPredicate.ODD); + } + + ExtinctionEventEffect() { + super(Outcome.Benefit); + staticText = "Choose odd or even. Exile each creature with a converted mana cost of the chosen value."; + } + + private ExtinctionEventEffect(final ExtinctionEventEffect effect) { + super(effect); + } + + @Override + public ExtinctionEventEffect copy() { + return new ExtinctionEventEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + FilterPermanent filter = player.chooseUse( + outcome, "Odd or even?", null, + "Odd", "Even", source, game + ) ? oddFilter : evenFilter; + return player.moveCards( + game.getBattlefield().getActivePermanents( + filter, source.getSourceId(), game + ).stream().collect(Collectors.toSet()), Zone.EXILED, source, game + ); + } +} diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 5c99e2054d..44e6935624 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -86,6 +86,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Dreamtail Heron", 47, Rarity.COMMON, mage.cards.d.DreamtailHeron.class)); cards.add(new SetCardInfo("Essence Scatter", 49, Rarity.COMMON, mage.cards.e.EssenceScatter.class)); cards.add(new SetCardInfo("Everquill Phoenix", 114, Rarity.RARE, mage.cards.e.EverquillPhoenix.class)); + cards.add(new SetCardInfo("Extinction Event", 88, Rarity.RARE, mage.cards.e.ExtinctionEvent.class)); cards.add(new SetCardInfo("Exuberant Wolfbear", 151, Rarity.UNCOMMON, mage.cards.e.ExuberantWolfbear.class)); cards.add(new SetCardInfo("Farfinder", 2, Rarity.COMMON, mage.cards.f.Farfinder.class)); cards.add(new SetCardInfo("Fertilid", 152, Rarity.COMMON, mage.cards.f.Fertilid.class)); diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/ConvertedManaCostParityPredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/ConvertedManaCostParityPredicate.java new file mode 100644 index 0000000000..273f01e087 --- /dev/null +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/ConvertedManaCostParityPredicate.java @@ -0,0 +1,27 @@ +package mage.filter.predicate.mageobject; + +import mage.MageObject; +import mage.filter.predicate.Predicate; +import mage.game.Game; + +/** + * @author TheElk801 + */ +public enum ConvertedManaCostParityPredicate implements Predicate { + EVEN(0), + ODD(1); + private final int parity; + + ConvertedManaCostParityPredicate(int parity) { + this.parity = parity; + } + + @Override + public boolean apply(MageObject input, Game game) { + return input.getConvertedManaCost() % 2 == parity; + } + + @Override + public String toString() { + return "ConvertedManaCostParity" + super.toString(); + }}