From 03dfa50f23e5dca4d8487b5dc465d62862b3dc25 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 9 Sep 2021 20:00:38 -0400 Subject: [PATCH] [MID] Implemented Geistflame Reservoir --- .../src/mage/cards/g/GeistflameReservoir.java | 64 +++++++++++++++++++ .../src/mage/sets/InnistradMidnightHunt.java | 1 + .../RemoveVariableCountersSourceCost.java | 7 +- .../dynamicvalue/common/GetXValue.java | 12 ++-- 4 files changed, 72 insertions(+), 12 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/g/GeistflameReservoir.java diff --git a/Mage.Sets/src/mage/cards/g/GeistflameReservoir.java b/Mage.Sets/src/mage/cards/g/GeistflameReservoir.java new file mode 100644 index 0000000000..1abccdba20 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GeistflameReservoir.java @@ -0,0 +1,64 @@ +package mage.cards.g; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SpellCastControllerTriggeredAbility; +import mage.abilities.costs.common.RemoveVariableCountersSourceCost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.GetXValue; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.effects.common.ExileTopXMayPlayUntilEndOfTurnEffect; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.target.common.TargetAnyTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GeistflameReservoir extends CardImpl { + + public GeistflameReservoir(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}{R}"); + + // Whenever you cast an instant or sorcery spell, put a charge counter on Geistflame Reservoir. + this.addAbility(new SpellCastControllerTriggeredAbility( + new AddCountersSourceEffect(CounterType.CHARGE.createInstance()), + StaticFilters.FILTER_SPELL_AN_INSTANT_OR_SORCERY, false + )); + + // {1}{R}, {T}, Remove any number of charge counters from Geistflame Reservoir: It deals that much damage to any target. + Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(GetXValue.instance) + .setText("it deals that much damage to any target"), new ManaCostsImpl<>("{1}{R}")); + ability.addCost(new TapSourceCost()); + ability.addCost(new RemoveVariableCountersSourceCost( + CounterType.CHARGE.createInstance(), "Remove any number of charge counters from {this}" + )); + ability.addTarget(new TargetAnyTarget()); + this.addAbility(ability); + + // {1}{R}, {T}: Exile the top card of your library. You may play that card this turn. + ability = new SimpleActivatedAbility( + new ExileTopXMayPlayUntilEndOfTurnEffect(1) + .setText("exile the top card of your library. You may play that card this turn"), + new ManaCostsImpl<>("{1}{R}") + ); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + private GeistflameReservoir(final GeistflameReservoir card) { + super(card); + } + + @Override + public GeistflameReservoir copy() { + return new GeistflameReservoir(this); + } +} diff --git a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java index 5eac004ab6..ebed2111f5 100644 --- a/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java +++ b/Mage.Sets/src/mage/sets/InnistradMidnightHunt.java @@ -80,6 +80,7 @@ public final class InnistradMidnightHunt extends ExpansionSet { cards.add(new SetCardInfo("Forest", 276, Rarity.LAND, mage.cards.basiclands.Forest.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Foul Play", 101, Rarity.UNCOMMON, mage.cards.f.FoulPlay.class)); cards.add(new SetCardInfo("Galvanic Iteration", 224, Rarity.RARE, mage.cards.g.GalvanicIteration.class)); + cards.add(new SetCardInfo("Geistflame Reservoir", 142, Rarity.RARE, mage.cards.g.GeistflameReservoir.class)); cards.add(new SetCardInfo("Ghoulcaller's Harvest", 225, Rarity.RARE, mage.cards.g.GhoulcallersHarvest.class)); cards.add(new SetCardInfo("Grafted Identity", 57, Rarity.RARE, mage.cards.g.GraftedIdentity.class)); cards.add(new SetCardInfo("Graveyard Glutton", 104, Rarity.RARE, mage.cards.g.GraveyardGlutton.class)); diff --git a/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersSourceCost.java b/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersSourceCost.java index b2b122a756..6459913ac7 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersSourceCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RemoveVariableCountersSourceCost.java @@ -62,12 +62,7 @@ public class RemoveVariableCountersSourceCost extends VariableCostImpl { @Override public int getMaxValue(Ability source, Game game) { - int maxValue = 0; Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - maxValue = permanent.getCounters(game).getCount(counterName); - } - return maxValue; + return permanent != null ? permanent.getCounters(game).getCount(counterName) : 0; } - } diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/GetXValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/GetXValue.java index 84a0302bb4..72d19416cd 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/GetXValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/GetXValue.java @@ -1,4 +1,3 @@ - package mage.abilities.dynamicvalue.common; import mage.abilities.Ability; @@ -15,11 +14,12 @@ public enum GetXValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - int amount = 0; - for (VariableCost cost : sourceAbility.getCosts().getVariableCosts()) { - amount += cost.getAmount(); - } - return amount; + return sourceAbility + .getCosts() + .getVariableCosts() + .stream() + .mapToInt(VariableCost::getAmount) + .sum(); } @Override