Implemented Extinction Event

This commit is contained in:
Evan Kranzler 2020-04-08 18:24:40 -04:00
parent 10ec7035fd
commit affbb93b3e
3 changed files with 109 additions and 0 deletions

View file

@ -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
);
}
}

View file

@ -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));

View file

@ -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<MageObject> {
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();
}}