From 210c4ab5768028a1e1de71a6420976d77cbdd784 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 23 Jan 2021 19:18:38 -0500 Subject: [PATCH] [KHM] Implemented Glorious Protector --- .../src/mage/cards/g/GloriousProtector.java | 110 ++++++++++++++++++ Mage.Sets/src/mage/sets/Kaldheim.java | 1 + 2 files changed, 111 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GloriousProtector.java diff --git a/Mage.Sets/src/mage/cards/g/GloriousProtector.java b/Mage.Sets/src/mage/cards/g/GloriousProtector.java new file mode 100644 index 0000000000..6dce19bb5d --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GloriousProtector.java @@ -0,0 +1,110 @@ +package mage.cards.g; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.delayed.OnLeaveReturnExiledToBattlefieldAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; +import mage.abilities.keyword.FlashAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.ForetellAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GloriousProtector extends CardImpl { + + public GloriousProtector(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); + + this.subtype.add(SubType.ANGEL); + this.subtype.add(SubType.CLERIC); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Flash + this.addAbility(FlashAbility.getInstance()); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // When Glorious Protector enters the battlefield, you may exile any number of non-Angel creatures you control until Glorious Protector leaves the battlefield. + Ability ability = new EntersBattlefieldTriggeredAbility(new GloriousProtectorEffect(),true); + ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new OnLeaveReturnExiledToBattlefieldAbility())); + this.addAbility(ability); + + // Foretell {2}{W} + this.addAbility(new ForetellAbility(this, "{2}{W}")); + } + + private GloriousProtector(final GloriousProtector card) { + super(card); + } + + @Override + public GloriousProtector copy() { + return new GloriousProtector(this); + } +} + +class GloriousProtectorEffect extends OneShotEffect { + + private static final FilterPermanent filter + = new FilterControlledCreaturePermanent("non-Angel creatures you control"); + + static { + filter.add(Predicates.not(SubType.ANGEL.getPredicate())); + } + + GloriousProtectorEffect() { + super(Outcome.Benefit); + staticText = "exile any number of non-Angel creatures you control until {this} leaves the battlefield"; + } + + private GloriousProtectorEffect(final GloriousProtectorEffect effect) { + super(effect); + } + + @Override + public GloriousProtectorEffect copy() { + return new GloriousProtectorEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + MageObject sourceObject = source.getSourceObject(game); + if (player == null || sourceObject == null) { + return false; + } + TargetPermanent target = new TargetPermanent(0, Integer.MAX_VALUE, filter, true); + player.choose(outcome, target, source.getSourceId(), game); + if (target.getTargets().isEmpty()) { + return false; + } + player.moveCardsToExile( + new CardsImpl(target.getTargets()).getCards(game), + source, game, true, CardUtil.getExileZoneId( + game, source.getSourceId(), source.getSourceObjectZoneChangeCounter() + ), sourceObject.getIdName() + ); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/Kaldheim.java b/Mage.Sets/src/mage/sets/Kaldheim.java index a281af7209..cb071e6b1a 100644 --- a/Mage.Sets/src/mage/sets/Kaldheim.java +++ b/Mage.Sets/src/mage/sets/Kaldheim.java @@ -139,6 +139,7 @@ public final class Kaldheim extends ExpansionSet { cards.add(new SetCardInfo("Glacial Floodplain", 257, Rarity.COMMON, mage.cards.g.GlacialFloodplain.class)); cards.add(new SetCardInfo("Gladewalker Ritualist", 392, Rarity.UNCOMMON, mage.cards.g.GladewalkerRitualist.class)); cards.add(new SetCardInfo("Glittering Frost", 171, Rarity.COMMON, mage.cards.g.GlitteringFrost.class)); + cards.add(new SetCardInfo("Glorious Protector", 12, Rarity.RARE, mage.cards.g.GloriousProtector.class)); cards.add(new SetCardInfo("Gnottvold Recluse", 172, Rarity.COMMON, mage.cards.g.GnottvoldRecluse.class)); cards.add(new SetCardInfo("Gnottvold Slumbermound", 258, Rarity.UNCOMMON, mage.cards.g.GnottvoldSlumbermound.class)); cards.add(new SetCardInfo("Gods' Hall Guardian", 13, Rarity.COMMON, mage.cards.g.GodsHallGuardian.class));