[ZNR] Implemented Inscription of Abundance

This commit is contained in:
Evan Kranzler 2020-09-07 16:29:18 -04:00
parent 9cf96bd391
commit d4ca287f0f
3 changed files with 120 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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));

View file

@ -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<UUID, Mode> {
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<UUID, Mode> {
}
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<UUID, Mode> {
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<UUID, Mode> {
this.isRandom = isRandom;
}
public void setAllWhenKicked(boolean allWhenKicked) {
this.allWhenKicked = allWhenKicked;
}
public void setChooseText(String chooseText) {
this.chooseText = chooseText;
}