From d4ca287f0f8f2fb9407330bd4beea1bc8fea8cec Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 7 Sep 2020 16:29:18 -0400 Subject: [PATCH] [ZNR] Implemented Inscription of Abundance --- .../mage/cards/i/InscriptionOfAbundance.java | 105 ++++++++++++++++++ Mage.Sets/src/mage/sets/ZendikarRising.java | 1 + Mage/src/main/java/mage/abilities/Modes.java | 15 ++- 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java diff --git a/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java b/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java new file mode 100644 index 0000000000..84eb6e1c1a --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/InscriptionOfAbundance.java @@ -0,0 +1,105 @@ +package mage.cards.i; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.FightTargetsEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.abilities.keyword.KickerAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetPlayer; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class InscriptionOfAbundance extends CardImpl { + + public InscriptionOfAbundance(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); + + // Kicker {2}{G} + this.addAbility(new KickerAbility(new ManaCostsImpl<>("{2}{G}"))); + + // Choose one. If this spell was kicked, choose any number instead. + this.getSpellAbility().getModes().setAllWhenKicked(true); + + // • Put two +1/+1 counters on target creature. + this.getSpellAbility().addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(2))); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + + // • Target player gains X life, where X is the greatest power among creatures they control. + Mode mode = new Mode(new InscriptionOfAbundanceEffect()); + mode.addTarget(new TargetPlayer()); + this.getSpellAbility().addMode(mode); + + // • Target creature you control fights target creature you don't control. + mode = new Mode(new FightTargetsEffect()); + mode.addTarget(new TargetControlledCreaturePermanent()); + mode.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); + this.getSpellAbility().addMode(mode); + } + + private InscriptionOfAbundance(final InscriptionOfAbundance card) { + super(card); + } + + @Override + public InscriptionOfAbundance copy() { + return new InscriptionOfAbundance(this); + } +} + +class InscriptionOfAbundanceEffect extends OneShotEffect { + + InscriptionOfAbundanceEffect() { + super(Outcome.Benefit); + staticText = "target player gains X life, where X is the greatest power among creatures they control"; + } + + private InscriptionOfAbundanceEffect(final InscriptionOfAbundanceEffect effect) { + super(effect); + } + + @Override + public InscriptionOfAbundanceEffect copy() { + return new InscriptionOfAbundanceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getFirstTarget()); + if (player == null) { + return false; + } + int maxPower = game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + source.getFirstTarget(), source.getSourceId(), game + ).stream() + .filter(Objects::nonNull) + .map(MageObject::getPower) + .mapToInt(MageInt::getValue) + .max().orElse(0); + if (maxPower > 0) { + player.gainLife(maxPower, game, source); + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/ZendikarRising.java b/Mage.Sets/src/mage/sets/ZendikarRising.java index 145733ea4e..f17c9e370b 100644 --- a/Mage.Sets/src/mage/sets/ZendikarRising.java +++ b/Mage.Sets/src/mage/sets/ZendikarRising.java @@ -149,6 +149,7 @@ public final class ZendikarRising extends ExpansionSet { cards.add(new SetCardInfo("Hagra Constrictor", 105, Rarity.COMMON, mage.cards.h.HagraConstrictor.class)); cards.add(new SetCardInfo("Highborn Vampire", 107, Rarity.COMMON, mage.cards.h.HighbornVampire.class)); cards.add(new SetCardInfo("Inordinate Rage", 144, Rarity.COMMON, mage.cards.i.InordinateRage.class)); + cards.add(new SetCardInfo("Inscription of Abundance", 186, Rarity.RARE, mage.cards.i.InscriptionOfAbundance.class)); cards.add(new SetCardInfo("Into the Roil", 62, Rarity.COMMON, mage.cards.i.IntoTheRoil.class)); cards.add(new SetCardInfo("Iridescent Hornbeetle", 187, Rarity.UNCOMMON, mage.cards.i.IridescentHornbeetle.class)); cards.add(new SetCardInfo("Island", 269, Rarity.LAND, mage.cards.basiclands.Island.class, FULL_ART_BFZ_VARIOUS)); diff --git a/Mage/src/main/java/mage/abilities/Modes.java b/Mage/src/main/java/mage/abilities/Modes.java index 1d43c9b3a2..0aea5a49ff 100644 --- a/Mage/src/main/java/mage/abilities/Modes.java +++ b/Mage/src/main/java/mage/abilities/Modes.java @@ -1,6 +1,6 @@ package mage.abilities; -import java.util.*; +import mage.abilities.condition.common.KickedCondition; import mage.abilities.costs.OptionalAdditionalModeSourceCosts; import mage.cards.Card; import mage.constants.Outcome; @@ -12,6 +12,8 @@ import mage.players.Player; import mage.target.common.TargetOpponent; import mage.util.RandomUtil; +import java.util.*; + /** * @author BetaSteward_at_googlemail.com */ @@ -35,6 +37,7 @@ public class Modes extends LinkedHashMap { private Filter maxModesFilter = null; // calculates the max number of available modes private boolean isRandom = false; private String chooseText = null; + private boolean allWhenKicked = false; public Modes() { this.currentMode = new Mode(); @@ -214,6 +217,10 @@ public class Modes extends LinkedHashMap { } public boolean choose(Game game, Ability source) { + if (this.allWhenKicked && KickedCondition.instance.apply(game, source)) { + this.setMinModes(0); + this.setMaxModes(3); + } if (this.size() > 1) { this.clearSelectedModes(); if (this.isRandom) { @@ -404,6 +411,8 @@ public class Modes extends LinkedHashMap { StringBuilder sb = new StringBuilder(); if (this.chooseText != null) { sb.append(chooseText); + } else if (this.allWhenKicked) { + sb.append("choose one. If this spell was kicked, choose any number instead."); } else if (this.getMaxModesFilter() != null) { sb.append("choose one or more. Each mode must target ").append(getMaxModesFilter().getMessage()); } else if (this.getMinModes() == 0 && this.getMaxModes() == 1) { @@ -476,6 +485,10 @@ public class Modes extends LinkedHashMap { this.isRandom = isRandom; } + public void setAllWhenKicked(boolean allWhenKicked) { + this.allWhenKicked = allWhenKicked; + } + public void setChooseText(String chooseText) { this.chooseText = chooseText; }