diff --git a/Mage.Sets/src/mage/cards/k/KayaOrzhovUsurper.java b/Mage.Sets/src/mage/cards/k/KayaOrzhovUsurper.java new file mode 100644 index 0000000000..edf600b750 --- /dev/null +++ b/Mage.Sets/src/mage/cards/k/KayaOrzhovUsurper.java @@ -0,0 +1,145 @@ +package mage.cards.k; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.cards.*; +import mage.constants.*; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterNonlandPermanent; +import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.Target; +import mage.target.TargetPermanent; +import mage.target.TargetPlayer; +import mage.target.common.TargetCardInASingleGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class KayaOrzhovUsurper extends CardImpl { + + private static final FilterPermanent filter + = new FilterNonlandPermanent("permanent with converted mana cost 1 or less"); + + static { + filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 2)); + } + + public KayaOrzhovUsurper(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{1}{W}{B}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.KAYA); + this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(3)); + + // +1: Exile up to two target cards from a single graveyard. You gain 2 life if at least one creature card was exiled this way. + Ability ability = new LoyaltyAbility(new KayaOrzhovUsurperExileEffect(), 1); + ability.addTarget(new TargetCardInASingleGraveyard(0, 2, StaticFilters.FILTER_CARD)); + this.addAbility(ability); + + // -1: Exile target nonland permanent with converted mana cost 1 or less. + ability = new LoyaltyAbility(new ExileTargetEffect(), -1); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + + // -5: Kaya, Orzhov Usurper deals damage to target player equal to the number of cards that player owns in exile and you gain that much life. + ability = new LoyaltyAbility(new KayaOrzhovUsurperDamageEffect(), -5); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + } + + private KayaOrzhovUsurper(final KayaOrzhovUsurper card) { + super(card); + } + + @Override + public KayaOrzhovUsurper copy() { + return new KayaOrzhovUsurper(this); + } +} + +class KayaOrzhovUsurperExileEffect extends OneShotEffect { + + KayaOrzhovUsurperExileEffect() { + super(Outcome.Benefit); + staticText = "Exile up to two target cards from a single graveyard. " + + "You gain 2 life if at least one creature card was exiled this way."; + } + + private KayaOrzhovUsurperExileEffect(final KayaOrzhovUsurperExileEffect effect) { + super(effect); + } + + @Override + public KayaOrzhovUsurperExileEffect copy() { + return new KayaOrzhovUsurperExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Cards cards = new CardsImpl(); + for (Target target : source.getTargets()) { + for (UUID targetId : target.getTargets()) { + Card card = game.getCard(targetId); + if (card != null) { + cards.add(card); + } + } + } + player.moveCards(cards, Zone.EXILED, source, game); + for (Card card : cards.getCards(game)) { + if (card != null && card.isCreature()) { + player.gainLife(2, game, source); + break; + } + } + return false; + } +} + +class KayaOrzhovUsurperDamageEffect extends OneShotEffect { + + KayaOrzhovUsurperDamageEffect() { + super(Outcome.Benefit); + staticText = "{this} deals damage to target player equal to the number of cards " + + "that player owns in exile and you gain that much life."; + } + + private KayaOrzhovUsurperDamageEffect(final KayaOrzhovUsurperDamageEffect effect) { + super(effect); + } + + @Override + public KayaOrzhovUsurperDamageEffect copy() { + return new KayaOrzhovUsurperDamageEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Player player = game.getPlayer(source.getFirstTarget()); + if (controller == null || player == null) { + return false; + } + int count = 0; + for (Card card : game.getExile().getAllCards(game)) { + if (card != null && card.getOwnerId().equals(player.getId())) { + count += 1; + } + } + player.damage(count, source.getSourceId(), game, false, true); + controller.gainLife(count, game, source); + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java index 0452be0742..928ed2be91 100644 --- a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java +++ b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java @@ -56,6 +56,7 @@ public final class RavnicaAllegiance extends ExpansionSet { cards.add(new SetCardInfo("Imperious Oligarch", 184, Rarity.COMMON, mage.cards.i.ImperiousOligarch.class)); cards.add(new SetCardInfo("Incubation // Incongruity", 226, Rarity.UNCOMMON, mage.cards.i.IncubationIncongruity.class)); cards.add(new SetCardInfo("Judith, the Scourge Diva", 185, Rarity.RARE, mage.cards.j.JudithTheScourgeDiva.class)); + cards.add(new SetCardInfo("Kaya, Orzhov Usurper", 186, Rarity.MYTHIC, mage.cards.k.KayaOrzhovUsurper.class)); cards.add(new SetCardInfo("Light Up the Stage", 107, Rarity.UNCOMMON, mage.cards.l.LightUpTheStage.class)); cards.add(new SetCardInfo("Mortify", 192, Rarity.UNCOMMON, mage.cards.m.Mortify.class)); cards.add(new SetCardInfo("Orzhov Guildgate", 252, Rarity.COMMON, mage.cards.o.OrzhovGuildgate.class, NON_FULL_USE_VARIOUS)); diff --git a/Utils/cardClass.tmpl b/Utils/cardClass.tmpl index a0368c0472..9d165a4cd2 100644 --- a/Utils/cardClass.tmpl +++ b/Utils/cardClass.tmpl @@ -3,7 +3,7 @@ package mage.cards.[=$cardNameFirstLetter=]; import java.util.UUID;[= if ($power || $power eq 0) { if ($planeswalker eq 'true') { - $OUT .= "\nimport mage.abilities.common.PlaneswalkerEntersWithLoyalityCountersAbility;" + $OUT .= "\nimport mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;" }else { $OUT .= "\nimport mage.MageInt;" }