diff --git a/Mage.Sets/src/mage/cards/g/GlenElendrasAnswer.java b/Mage.Sets/src/mage/cards/g/GlenElendrasAnswer.java new file mode 100644 index 00000000000..52fc0dfbf90 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GlenElendrasAnswer.java @@ -0,0 +1,78 @@ +package mage.cards.g; + +import mage.MageItem; +import mage.abilities.Ability; +import mage.abilities.common.CantBeCounteredSourceAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.token.FaerieBlueBlackToken; + +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class GlenElendrasAnswer extends CardImpl { + + public GlenElendrasAnswer(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}{U}"); + + // This spell can't be countered. + this.addAbility(new CantBeCounteredSourceAbility()); + + // Counter all spells your opponents control and all abilities your opponents control. Create a 1/1 blue and black Faerie creature token with flying for each spell and ability countered this way. + this.getSpellAbility().addEffect(new GlenElendrasAnswerEffect()); + } + + private GlenElendrasAnswer(final GlenElendrasAnswer card) { + super(card); + } + + @Override + public GlenElendrasAnswer copy() { + return new GlenElendrasAnswer(this); + } +} + +class GlenElendrasAnswerEffect extends OneShotEffect { + + GlenElendrasAnswerEffect() { + super(Outcome.Benefit); + staticText = "counter all spells your opponents control and all abilities your opponents control. " + + "Create a 1/1 blue and black Faerie creature token with flying for each spell and ability countered this way"; + } + + private GlenElendrasAnswerEffect(final GlenElendrasAnswerEffect effect) { + super(effect); + } + + @Override + public GlenElendrasAnswerEffect copy() { + return new GlenElendrasAnswerEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Set opponents = game.getOpponents(source.getControllerId()); + int count = game + .getStack() + .stream() + .filter(stackObject -> opponents.contains(stackObject.getControllerId())) + .collect(Collectors.toList()) + .stream() + .map(MageItem::getId) + .mapToInt(uuid -> game.getStack().counter(uuid, source, game) ? 1 : 0) + .sum(); + if (count < 1) { + return false; + } + new FaerieBlueBlackToken().putOntoBattlefield(count, game, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/LorwynEclipsed.java b/Mage.Sets/src/mage/sets/LorwynEclipsed.java index e4816cf6c76..25b189f7feb 100644 --- a/Mage.Sets/src/mage/sets/LorwynEclipsed.java +++ b/Mage.Sets/src/mage/sets/LorwynEclipsed.java @@ -178,6 +178,8 @@ public final class LorwynEclipsed extends ExpansionSet { cards.add(new SetCardInfo("Glen Elendra Guardian", 383, Rarity.MYTHIC, mage.cards.g.GlenElendraGuardian.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Glen Elendra Guardian", 393, Rarity.MYTHIC, mage.cards.g.GlenElendraGuardian.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Glen Elendra Guardian", 51, Rarity.RARE, mage.cards.g.GlenElendraGuardian.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Glen Elendra's Answer", 306, Rarity.MYTHIC, mage.cards.g.GlenElendrasAnswer.class, NON_FULL_USE_VARIOUS)); + cards.add(new SetCardInfo("Glen Elendra's Answer", 52, Rarity.MYTHIC, mage.cards.g.GlenElendrasAnswer.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Glister Bairn", 227, Rarity.UNCOMMON, mage.cards.g.GlisterBairn.class)); cards.add(new SetCardInfo("Gloom Ripper", 102, Rarity.RARE, mage.cards.g.GloomRipper.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Gloom Ripper", 312, Rarity.RARE, mage.cards.g.GloomRipper.class, NON_FULL_USE_VARIOUS));