From 84e70c4041d5cac506f6e2e2be09f8e1481317b9 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 3 Apr 2020 08:13:40 -0400 Subject: [PATCH] Implemented Primal Empathy --- Mage.Sets/src/mage/cards/p/PrimalEmpathy.java | 96 +++++++++++++++++++ .../src/mage/sets/IkoriaLairOfBehemoths.java | 1 + 2 files changed, 97 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/p/PrimalEmpathy.java diff --git a/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java b/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java new file mode 100644 index 0000000000..025e70d1a7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/p/PrimalEmpathy.java @@ -0,0 +1,96 @@ +package mage.cards.p; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.Target; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class PrimalEmpathy extends CardImpl { + + public PrimalEmpathy(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}{U}"); + + // At the beginning of your upkeep, draw a card if you control a creature with the greatest power among creatures on the battlefield. Otherwise, put a +1/+1 counter on a creature you control. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new PrimalEmpathyEffect(), TargetController.YOU, false + )); + } + + private PrimalEmpathy(final PrimalEmpathy card) { + super(card); + } + + @Override + public PrimalEmpathy copy() { + return new PrimalEmpathy(this); + } +} + +class PrimalEmpathyEffect extends OneShotEffect { + + PrimalEmpathyEffect() { + super(Outcome.Benefit); + staticText = "draw a card if you control a creature " + + "with the greatest power among creatures on the battlefield. " + + "Otherwise, put a +1/+1 counter on a creature you control"; + } + + private PrimalEmpathyEffect(final PrimalEmpathyEffect effect) { + super(effect); + } + + @Override + public PrimalEmpathyEffect copy() { + return new PrimalEmpathyEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + int highestPower = game + .getBattlefield() + .getActivePermanents(source.getControllerId(), game) + .stream() + .filter(Permanent::isCreature) + .map(Permanent::getPower) + .mapToInt(MageInt::getValue) + .max() + .orElse(0); + boolean flag = game.getBattlefield() + .getAllActivePermanents(source.getControllerId()) + .stream() + .filter(Permanent::isCreature) + .map(Permanent::getPower) + .mapToInt(MageInt::getValue) + .anyMatch(i -> i >= highestPower); + if (flag) { + return player.drawCards(1, game) > 0; + } + Target target = new TargetControlledCreaturePermanent(); + target.setNotTarget(true); + if (!player.choose(outcome, target, source.getSourceId(), game)) { + return false; + } + Permanent permanent = game.getPermanent(target.getFirstTarget()); + return permanent != null && permanent.addCounters(CounterType.P1P1.createInstance(), source, game); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 0846d7daa6..fda9186117 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -36,6 +36,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Kogla, the Titan Ape", 328, Rarity.RARE, mage.cards.k.KoglaTheTitanApe.class)); cards.add(new SetCardInfo("Mosscoat Goriak", 167, Rarity.COMMON, mage.cards.m.MosscoatGoriak.class)); cards.add(new SetCardInfo("Pacifism", 25, Rarity.COMMON, mage.cards.p.Pacifism.class)); + cards.add(new SetCardInfo("Primal Empathy", 200, Rarity.UNCOMMON, mage.cards.p.PrimalEmpathy.class)); cards.add(new SetCardInfo("Snapdax, Apex of the Hunt", 209, Rarity.MYTHIC, mage.cards.s.SnapdaxApexOfTheHunt.class)); cards.add(new SetCardInfo("Sprite Dragon", 211, Rarity.UNCOMMON, mage.cards.s.SpriteDragon.class)); cards.add(new SetCardInfo("Titanoth Rex", 174, Rarity.UNCOMMON, mage.cards.t.TitanothRex.class));