diff --git a/Mage.Sets/src/mage/cards/p/PinnacleStarcage.java b/Mage.Sets/src/mage/cards/p/PinnacleStarcage.java new file mode 100644 index 00000000000..32f9326474f --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PinnacleStarcage.java @@ -0,0 +1,140 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.delayed.OnLeaveReturnExiledAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.SacrificeSourceEffect; +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.predicate.Predicates; +import mage.filter.predicate.mageobject.ManaValuePredicate; +import mage.game.Game; +import mage.game.permanent.token.RobotToken; +import mage.players.Player; +import mage.util.CardUtil; + +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PinnacleStarcage extends CardImpl { + + public PinnacleStarcage(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{W}{W}"); + + // When this artifact enters, exile all artifacts and creatures with mana value 2 or less until this artifact leaves the battlefield. + this.addAbility(new EntersBattlefieldTriggeredAbility(new PinnacleStarcageExileEffect())); + + // {6}{W}{W}: Put each card exiled with this artifact into its owner's graveyard, then create a 2/2 colorless Robot artifact token for each card put into a graveyard this way. Sacrifice this artifact. + Ability ability = new SimpleActivatedAbility(new PinnacleStarcageTokenEffect(), new ManaCostsImpl<>("{6}{W}{W}")); + ability.addEffect(new SacrificeSourceEffect()); + this.addAbility(ability); + } + + private PinnacleStarcage(final PinnacleStarcage card) { + super(card); + } + + @Override + public PinnacleStarcage copy() { + return new PinnacleStarcage(this); + } +} + +class PinnacleStarcageExileEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterPermanent(); + + static { + filter.add(Predicates.or( + CardType.ARTIFACT.getPredicate(), + CardType.CREATURE.getPredicate() + )); + filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 3)); + } + + PinnacleStarcageExileEffect() { + super(Outcome.Benefit); + staticText = "exile all artifacts and creatures with mana value 2 or less until {this} leaves the battlefield"; + } + + private PinnacleStarcageExileEffect(final PinnacleStarcageExileEffect effect) { + super(effect); + } + + @Override + public PinnacleStarcageExileEffect copy() { + return new PinnacleStarcageExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null || source.getSourcePermanentIfItStillExists(game) == null) { + return false; + } + Cards cards = new CardsImpl(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)); + if (cards.isEmpty()) { + return false; + } + player.moveCardsToExile( + cards.getCards(game), source, game, true, + CardUtil.getExileZoneId(game, source), + CardUtil.getSourceName(game, source) + ); + game.addDelayedTriggeredAbility(new OnLeaveReturnExiledAbility(), source); + return true; + } +} + +class PinnacleStarcageTokenEffect extends OneShotEffect { + + PinnacleStarcageTokenEffect() { + super(Outcome.Benefit); + staticText = "put each card exiled with this artifact into its owner's graveyard, " + + "then create a 2/2 colorless Robot artifact token for each card put into a graveyard this way"; + } + + private PinnacleStarcageTokenEffect(final PinnacleStarcageTokenEffect effect) { + super(effect); + } + + @Override + public PinnacleStarcageTokenEffect copy() { + return new PinnacleStarcageTokenEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(); + Optional.ofNullable(CardUtil.getExileZoneId(game, source)) + .map(game.getExile()::getExileZone) + .map(e -> e.getCards(game)) + .ifPresent(cards::addAllCards); + if (cards.isEmpty()) { + return false; + } + player.moveCards(cards, Zone.GRAVEYARD, source, game); + cards.retainZone(Zone.GRAVEYARD, game); + if (cards.size() > 0) { + new RobotToken().putOntoBattlefield(cards.size(), game, source); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/EdgeOfEternities.java b/Mage.Sets/src/mage/sets/EdgeOfEternities.java index 55b87b48046..2f0d06c19ba 100644 --- a/Mage.Sets/src/mage/sets/EdgeOfEternities.java +++ b/Mage.Sets/src/mage/sets/EdgeOfEternities.java @@ -181,6 +181,7 @@ public final class EdgeOfEternities extends ExpansionSet { cards.add(new SetCardInfo("Pain for All", 151, Rarity.RARE, mage.cards.p.PainForAll.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Pain for All", 337, Rarity.RARE, mage.cards.p.PainForAll.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Pinnacle Emissary", 223, Rarity.RARE, mage.cards.p.PinnacleEmissary.class)); + cards.add(new SetCardInfo("Pinnacle Starcage", 27, Rarity.RARE, mage.cards.p.PinnacleStarcage.class)); cards.add(new SetCardInfo("Plains", 262, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Plains", 267, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Plains", 268, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS)); diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index 57fac86c5c0..56b90ef3936 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -59125,6 +59125,7 @@ Honor|Edge of Eternities|21|U|{W}|Sorcery|||Put a +1/+1 counter on target creatu Honored Knight-Captain|Edge of Eternities|22|U|{1}{W}|Creature - Human Advisor Knight|1|1|When this creature enters, create a 1/1 white Human Soldier creature token.${4}{W}{W}, Sacrifice this creature: Search your library for an Equipment card, put it onto the battlefield, then shuffle.| Lumen-Class Frigate|Edge of Eternities|25|R|{1}{W}|Artifact - Spacecraft|||Station$STATION 2+$Other creatures you control get +1/+1.$STATION 12+$Flying, lifelink$3/5| Luxknight Breacher|Edge of Eternities|26|C|{3}{W}|Creature - Human Knight|2|2|This creature enters with a +1/+1 counter on it for each other creature and/or artifact you control.| +Pinnacle Starcage|Edge of Eternities|27|R|{1}{W}{W}|Artifact|||When this artifact enters, exile all artifacts and creatures with mana value 2 or less until this artifact leaves the battlefield.${6}{W}{W}: Put each card exiled with this artifact into its owner's graveyard, then create a 2/2 colorless Robot artifact token for each card put into a graveyard this way. Sacrifice this artifact.| Pulsar Squadron Ace|Edge of Eternities|28|U|{1}{W}|Creature - Human Pilot|1|2|When this creature enters, look at the top five cards of your library. You may reveal a Spacecraft card from among them and put it into your hand. Put the rest on the bottom of your library in a random order. If you didn't put a card into your hand this way, put a +1/+1 counter on this creature.| Radiant Strike|Edge of Eternities|29|C|{3}{W}|Instant|||Destroy target artifact or tapped creature. You gain 3 life.| Rayblade Trooper|Edge of Eternities|30|U|{2}{W}|Creature - Human Soldier|2|2|When this creature enters, put a +1/+1 counter on target creature you control.$Whenever a nontoken creature you control with a +1/+1 counter on it dies, create a 1/1 white Human Soldier creature token.$Warp {1}{W}|