implement [MH3] Aether Spike

This commit is contained in:
Susucre 2024-05-31 23:50:47 +02:00
parent a2a6361748
commit b7324010ba
2 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,81 @@
package mage.cards.a;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.PayEnergyCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetSpell;
import java.util.UUID;
/**
* @author Susucr
*/
public final class AetherSpike extends CardImpl {
public AetherSpike(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Choose target spell. You get {E}{E}, then you may pay any amount of {E}. Counter that spell unless its controller pays {1} for each {E} paid this way.
this.getSpellAbility().addTarget(new TargetSpell());
this.getSpellAbility().addEffect(new GetEnergyCountersControllerEffect(2));
this.getSpellAbility().addEffect(new AetherSpikeEffect());
}
private AetherSpike(final AetherSpike card) {
super(card);
}
@Override
public AetherSpike copy() {
return new AetherSpike(this);
}
}
class AetherSpikeEffect extends OneShotEffect {
AetherSpikeEffect() {
super(Outcome.Detriment);
staticText = ", then you may pay any amount of {E}. Counter that spell unless its controller pays {1} for each {E} paid this way";
}
private AetherSpikeEffect(final AetherSpikeEffect effect) {
super(effect);
}
@Override
public AetherSpikeEffect copy() {
return new AetherSpikeEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int numberToPay = controller.getAmount(
0, controller.getCountersCount(CounterType.ENERGY),
"How many {E} do you want to pay?", game
);
Cost cost = new PayEnergyCost(numberToPay);
int numberPaid = 0;
if (cost.pay(source, game, source, source.getControllerId(), true)) {
numberPaid = numberToPay;
}
new CounterUnlessPaysEffect(new GenericManaCost(numberPaid))
.setTargetPointer(getTargetPointer().copy())
.apply(game, source);
return true;
}
}

View file

@ -23,6 +23,7 @@ public final class ModernHorizons3 extends ExpansionSet {
cards.add(new SetCardInfo("Accursed Marauder", 80, Rarity.COMMON, mage.cards.a.AccursedMarauder.class));
cards.add(new SetCardInfo("Aerie Auxiliary", 18, Rarity.COMMON, mage.cards.a.AerieAuxiliary.class));
cards.add(new SetCardInfo("Aether Spike", 50, Rarity.COMMON, mage.cards.a.AetherSpike.class));
cards.add(new SetCardInfo("Ajani, Nacatl Avenger", 237, Rarity.MYTHIC, mage.cards.a.AjaniNacatlAvenger.class));
cards.add(new SetCardInfo("Ajani, Nacatl Pariah", 237, Rarity.MYTHIC, mage.cards.a.AjaniNacatlPariah.class));
cards.add(new SetCardInfo("Amphibian Downpour", 51, Rarity.RARE, mage.cards.a.AmphibianDownpour.class));