diff --git a/Mage.Sets/src/mage/cards/l/LegionsEnd.java b/Mage.Sets/src/mage/cards/l/LegionsEnd.java new file mode 100644 index 0000000000..f88f8bf8d0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LegionsEnd.java @@ -0,0 +1,112 @@ +package mage.cards.l; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.ComparisonType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterOpponentsCreaturePermanent; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class LegionsEnd extends CardImpl { + + private static final FilterPermanent filter + = new FilterOpponentsCreaturePermanent("creature an opponent controls with converted mana cost 2 or less"); + + static { + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 3)); + } + + public LegionsEnd(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}"); + + // Exile target creature an opponent controls with converted mana cost 2 or less and all other creatures that player controls with the same name as that creature. Then that player reveals their hand and exiles all cards with that name from their hand and graveyard. + this.getSpellAbility().addEffect(new LegionsEndEffect()); + this.getSpellAbility().addTarget(new TargetPermanent(filter)); + } + + private LegionsEnd(final LegionsEnd card) { + super(card); + } + + @Override + public LegionsEnd copy() { + return new LegionsEnd(this); + } +} + +class LegionsEndEffect extends OneShotEffect { + + LegionsEndEffect() { + super(Outcome.Benefit); + staticText = "Exile target creature an opponent controls with converted mana cost 2 or less " + + "and all other creatures that player controls with the same name as that creature. " + + "Then that player reveals their hand and exiles all cards with that name from their hand and graveyard."; + } + + private LegionsEndEffect(final LegionsEndEffect effect) { + super(effect); + } + + @Override + public LegionsEndEffect copy() { + return new LegionsEndEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { + return false; + } + Player player = game.getPlayer(permanent.getControllerId()); + if (player == null) { + return false; + } + String name = permanent.getName(); + if (name == null || name.equals("")) { + player.revealCards(source, player.getHand(), game); + return player.moveCards(permanent, Zone.EXILED, source, game); + } + Cards cards = new CardsImpl(); + game + .getBattlefield() + .getAllActivePermanents(player.getId()) + .stream() + .filter(perm -> name.equals(perm.getName())) + .forEach(perm -> cards.add(perm)); + + player.revealCards(source, player.getHand(), game); + + player + .getHand() + .getCards(game) + .stream() + .filter(card -> name.equals(card.getName())) + .forEach(card -> cards.add(card)); + + player + .getGraveyard() + .getCards(game) + .stream() + .filter(card -> name.equals(card.getName())) + .forEach(card -> cards.add(card)); + + return player.moveCards(cards, Zone.EXILED, source, game); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/CoreSet2020.java b/Mage.Sets/src/mage/sets/CoreSet2020.java index 3a65430df6..71f96301ff 100644 --- a/Mage.Sets/src/mage/sets/CoreSet2020.java +++ b/Mage.Sets/src/mage/sets/CoreSet2020.java @@ -87,6 +87,7 @@ public final class CoreSet2020 extends ExpansionSet { cards.add(new SetCardInfo("Kaalia, Zenith Seeker", 210, Rarity.MYTHIC, mage.cards.k.KaaliaZenithSeeker.class)); cards.add(new SetCardInfo("Kykar, Wind's Fury", 212, Rarity.MYTHIC, mage.cards.k.KykarWindsFury.class)); cards.add(new SetCardInfo("Lavakin Brawler", 147, Rarity.COMMON, mage.cards.l.LavakinBrawler.class)); + cards.add(new SetCardInfo("Legion's End", 106, Rarity.RARE, mage.cards.l.LegionsEnd.class)); cards.add(new SetCardInfo("Leyline of Abundance", 179, Rarity.RARE, mage.cards.l.LeylineOfAbundance.class)); cards.add(new SetCardInfo("Leyline of Anticipation", 64, Rarity.RARE, mage.cards.l.LeylineOfAnticipation.class)); cards.add(new SetCardInfo("Leyline of Sanctity", 26, Rarity.RARE, mage.cards.l.LeylineOfSanctity.class));