forked from External/mage
implement [MH3] Jolted Away
This commit is contained in:
parent
8e3b8f0368
commit
6efdce1e4e
4 changed files with 71 additions and 9 deletions
51
Mage.Sets/src/mage/cards/j/JoltedAwake.java
Normal file
51
Mage.Sets/src/mage/cards/j/JoltedAwake.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package mage.cards.j;
|
||||
|
||||
import mage.abilities.costs.common.PayEnergyCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.common.TargetManaValue;
|
||||
import mage.abilities.effects.common.DoIfCostPaid;
|
||||
import mage.abilities.effects.common.InfoEffect;
|
||||
import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffect;
|
||||
import mage.abilities.effects.common.counter.GetEnergyCountersControllerEffect;
|
||||
import mage.abilities.keyword.CyclingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public final class JoltedAwake extends CardImpl {
|
||||
|
||||
public JoltedAwake(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{W}");
|
||||
|
||||
// Choose up to one target artifact or creature card in your graveyard. You get {E}{E}. Then you may pay an amount of {E} equal to that card's mana value. If you do, return it from your graveyard to the battlefield.
|
||||
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_ARTIFACT_OR_CREATURE));
|
||||
this.getSpellAbility().addEffect(new InfoEffect("Choose up to one target artifact or creature card in your graveyard."));
|
||||
this.getSpellAbility().addEffect(new GetEnergyCountersControllerEffect(2));
|
||||
this.getSpellAbility().addEffect(new DoIfCostPaid(
|
||||
new ReturnFromGraveyardToBattlefieldTargetEffect()
|
||||
.setText("return it from your graveyard to the battlefield"),
|
||||
new PayEnergyCost(TargetManaValue.instance, "pay an amount of {E} equal to that card's mana value"),
|
||||
"pay an amount of {E} equal to that card's mana value?",
|
||||
true
|
||||
).concatBy("Then"));
|
||||
|
||||
// Cycling {2}
|
||||
this.addAbility(new CyclingAbility(new ManaCostsImpl<>("{2}")));
|
||||
}
|
||||
|
||||
private JoltedAwake(final JoltedAwake card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JoltedAwake copy() {
|
||||
return new JoltedAwake(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -142,6 +142,7 @@ public final class ModernHorizons3 extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("It That Heralds the End", 9, Rarity.UNCOMMON, mage.cards.i.ItThatHeraldsTheEnd.class));
|
||||
cards.add(new SetCardInfo("Izzet Generatorium", 191, Rarity.UNCOMMON, mage.cards.i.IzzetGeneratorium.class));
|
||||
cards.add(new SetCardInfo("Jet Medallion", 292, Rarity.RARE, mage.cards.j.JetMedallion.class));
|
||||
cards.add(new SetCardInfo("Jolted Awake", 33, Rarity.COMMON, mage.cards.j.JoltedAwake.class));
|
||||
cards.add(new SetCardInfo("Junk Diver", 293, Rarity.UNCOMMON, mage.cards.j.JunkDiver.class));
|
||||
cards.add(new SetCardInfo("K'rrik, Son of Yawgmoth", 274, Rarity.RARE, mage.cards.k.KrrikSonOfYawgmoth.class));
|
||||
cards.add(new SetCardInfo("Kaalia of the Vast", 290, Rarity.MYTHIC, mage.cards.k.KaaliaOfTheVast.class));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ package mage.abilities.costs.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
|
@ -11,18 +13,20 @@ import mage.util.CardUtil;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author emerald000
|
||||
*/
|
||||
public class PayEnergyCost extends CostImpl {
|
||||
|
||||
private final int amount;
|
||||
private final DynamicValue amount;
|
||||
|
||||
public PayEnergyCost(int amount) {
|
||||
this(StaticValue.get(amount), makeText(amount));
|
||||
}
|
||||
|
||||
public PayEnergyCost(DynamicValue amount, String text) {
|
||||
this.amount = amount;
|
||||
this.text = makeText(amount);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public PayEnergyCost(PayEnergyCost cost) {
|
||||
|
|
@ -33,14 +37,16 @@ public class PayEnergyCost extends CostImpl {
|
|||
@Override
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
return player != null && player.getCountersCount(CounterType.ENERGY) >= amount;
|
||||
int energyToPayAmount = amount.calculate(game, ability, null);
|
||||
return player != null && player.getCountersCount(CounterType.ENERGY) >= energyToPayAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null && player.getCountersCount(CounterType.ENERGY) >= amount) {
|
||||
player.loseCounters(CounterType.ENERGY.getName(), amount, source, game);
|
||||
int energyToPayAmount = amount.calculate(game, ability, null);
|
||||
if (player != null && player.getCountersCount(CounterType.ENERGY) >= energyToPayAmount) {
|
||||
player.loseCounters(CounterType.ENERGY.getName(), energyToPayAmount, source, game);
|
||||
paid = true;
|
||||
}
|
||||
return paid;
|
||||
|
|
|
|||
|
|
@ -35,16 +35,20 @@ public class PayLifeCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
//118.4. If a cost or effect allows a player to pay an amount of life greater than 0,
|
||||
//the player may do so only if their life total is greater than or equal to the
|
||||
//amount of the payment. If a player pays life, the payment is subtracted from their
|
||||
//life total; in other words, the player loses that much life. (Players can always pay 0 life.)
|
||||
int lifeToPayAmount = amount.calculate(game, ability, null);
|
||||
// Paying 0 life is not considered paying any life.
|
||||
if (lifeToPayAmount > 0 && !game.getPlayer(controllerId).canPayLifeCost(ability)) {
|
||||
if (lifeToPayAmount > 0 && !player.canPayLifeCost(ability)) {
|
||||
return false;
|
||||
}
|
||||
return game.getPlayer(controllerId).getLife() >= lifeToPayAmount || lifeToPayAmount == 0;
|
||||
return player.getLife() >= lifeToPayAmount || lifeToPayAmount == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue