From d0a0061915fe0b13cad33ad4d898e149c4a2d608 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sat, 23 Jan 2021 19:51:43 -0500 Subject: [PATCH] [KHC] Implemented Pact of the Serpent --- .../src/mage/cards/p/PactOfTheSerpent.java | 79 +++++++++++++++++++ .../src/mage/sets/KaldheimCommander.java | 1 + 2 files changed, 80 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java diff --git a/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java b/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java new file mode 100644 index 0000000000..2429e17fe6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PactOfTheSerpent.java @@ -0,0 +1,79 @@ +package mage.cards.p; + +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; +import mage.filter.predicate.mageobject.ChosenSubtypePredicate; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPlayer; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PactOfTheSerpent extends CardImpl { + + public PactOfTheSerpent(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}{B}"); + + // Choose a creature type. Target player draws X cards and loses X life, where X is the number of creature they control of the chosen type. + this.getSpellAbility().addEffect(new ChooseCreatureTypeEffect(Outcome.Neutral)); + this.getSpellAbility().addEffect(new PactOfTheSerpentEffect()); + this.getSpellAbility().addTarget(new TargetPlayer()); + } + + private PactOfTheSerpent(final PactOfTheSerpent card) { + super(card); + } + + @Override + public PactOfTheSerpent copy() { + return new PactOfTheSerpent(this); + } +} + +class PactOfTheSerpentEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterControlledCreaturePermanent(); + + static { + filter.add(ChosenSubtypePredicate.TRUE); + } + + PactOfTheSerpentEffect() { + super(Outcome.Benefit); + staticText = "Target player draws X cards and loses X life, " + + "where X is the number of creature they control of the chosen type"; + } + + private PactOfTheSerpentEffect(final PactOfTheSerpentEffect effect) { + super(effect); + } + + @Override + public PactOfTheSerpentEffect copy() { + return new PactOfTheSerpentEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player == null) { + return false; + } + int permCount = game.getBattlefield().count(filter, source.getSourceId(), player.getId(), game); + if (permCount > 0) { + player.drawCards(permCount, source, game); + player.loseLife(permCount, game, source, false); + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/KaldheimCommander.java b/Mage.Sets/src/mage/sets/KaldheimCommander.java index 9dce81d77a..51f945ec40 100644 --- a/Mage.Sets/src/mage/sets/KaldheimCommander.java +++ b/Mage.Sets/src/mage/sets/KaldheimCommander.java @@ -23,6 +23,7 @@ public final class KaldheimCommander extends ExpansionSet { cards.add(new SetCardInfo("Elderfang Venom", 15, Rarity.RARE, mage.cards.e.ElderfangVenom.class)); cards.add(new SetCardInfo("Inspired Sphinx", 40, Rarity.MYTHIC, mage.cards.i.InspiredSphinx.class)); cards.add(new SetCardInfo("Lathril, Blade of the Elves", 1, Rarity.MYTHIC, mage.cards.l.LathrilBladeOfTheElves.class)); + cards.add(new SetCardInfo("Pact of the Serpent", 9, Rarity.RARE, mage.cards.p.PactOfTheSerpent.class)); cards.add(new SetCardInfo("Ruthless Winnower", 10, Rarity.RARE, mage.cards.r.RuthlessWinnower.class)); cards.add(new SetCardInfo("Sage of the Beyond", 6, Rarity.RARE, mage.cards.s.SageOfTheBeyond.class)); cards.add(new SetCardInfo("Spectral Deluge", 7, Rarity.RARE, mage.cards.s.SpectralDeluge.class));