Implemented Kaya's Guile

This commit is contained in:
Evan Kranzler 2019-05-27 21:00:15 -04:00
parent d4c633dd70
commit a18c3e1d88
3 changed files with 89 additions and 25 deletions

View file

@ -0,0 +1,59 @@
package mage.cards.k;
import mage.abilities.Mode;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.ExileGraveyardAllPlayersEffect;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.SacrificeOpponentsEffect;
import mage.abilities.keyword.EntwineAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.TargetController;
import mage.filter.StaticFilters;
import mage.game.permanent.token.WhiteBlackSpiritToken;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class KayasGuile extends CardImpl {
public KayasGuile(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}{B}");
// Choose two
this.getSpellAbility().getModes().setMinModes(2);
this.getSpellAbility().getModes().setMaxModes(2);
// Each opponent sacrifices a creature.
this.getSpellAbility().addEffect(new SacrificeOpponentsEffect(
StaticFilters.FILTER_CONTROLLED_CREATURE_SHORT_TEXT
));
// Exile all cards from each opponent's graveyard.
this.getSpellAbility().addMode(new Mode(new ExileGraveyardAllPlayersEffect(
StaticFilters.FILTER_CARD_CARDS, TargetController.OPPONENT
)));
// Create a 1/1 white and black Spirit creature token with flying.
this.getSpellAbility().addMode(new Mode(new CreateTokenEffect(new WhiteBlackSpiritToken())));
// You gain 4 life.
this.getSpellAbility().addMode(new Mode(new GainLifeEffect(4)));
// Entwine {3}
this.addAbility(new EntwineAbility(new ManaCostsImpl("{3}"), "Choose all if you pay the entwine cost."));
}
private KayasGuile(final KayasGuile card) {
super(card);
}
@Override
public KayasGuile copy() {
return new KayasGuile(this);
}
}

View file

@ -84,6 +84,7 @@ public final class ModernHorizons extends ExpansionSet {
cards.add(new SetCardInfo("Ice-Fang Coatl", 203, Rarity.RARE, mage.cards.i.IceFangCoatl.class));
cards.add(new SetCardInfo("Impostor of the Sixth Pride", 14, Rarity.COMMON, mage.cards.i.ImpostorOfTheSixthPride.class));
cards.add(new SetCardInfo("Ingenious Infiltrator", 204, Rarity.UNCOMMON, mage.cards.i.IngeniousInfiltrator.class));
cards.add(new SetCardInfo("Kaya's Guile", 205, Rarity.RARE, mage.cards.k.KayasGuile.class));
cards.add(new SetCardInfo("Kess, Dissident Mage", 206, Rarity.MYTHIC, mage.cards.k.KessDissidentMage.class));
cards.add(new SetCardInfo("King of the Pride", 16, Rarity.UNCOMMON, mage.cards.k.KingOfThePride.class));
cards.add(new SetCardInfo("Lava Dart", 134, Rarity.COMMON, mage.cards.l.LavaDart.class));

View file

@ -1,30 +1,27 @@
package mage.abilities.keyword;
import java.util.Iterator;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs;
import mage.abilities.costs.OptionalAdditionalCost;
import mage.abilities.costs.OptionalAdditionalCostImpl;
import mage.abilities.costs.OptionalAdditionalModeSourceCosts;
import mage.abilities.costs.*;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.Iterator;
/**
* 702.40. Entwine
*
* <p>
* 702.40a Entwine is a static ability of modal spells (see rule 700.2) that
* functions while the spell is on the stack. "Entwine [cost]" means "You may
* choose all modes of this spell instead of just one. If you do, you pay an
* additional [cost]." Using the entwine ability follows the rules for choosing
* modes and paying additional costs in rules 601.2b and 601.2e-g.
*
* <p>
* 702.40b If the entwine cost was paid, follow the text of each of the modes in
* the order written on the card when the spell resolves.
*
@ -33,15 +30,18 @@ import mage.players.Player;
public class EntwineAbility extends StaticAbility implements OptionalAdditionalModeSourceCosts {
private static final String keywordText = "Entwine";
private static final String reminderText = "Choose both if you pay the entwine cost.";
protected OptionalAdditionalCost additionalCost;
public EntwineAbility(String manaString) {
super(Zone.STACK, null);
this.additionalCost = new OptionalAdditionalCostImpl(keywordText, reminderText, new ManaCostsImpl(manaString));
this.additionalCost = new OptionalAdditionalCostImpl(keywordText, "Choose both if you pay the entwine cost.", new ManaCostsImpl(manaString));
}
public EntwineAbility(Cost cost) {
this(cost, "Choose both if you pay the entwine cost.");
}
public EntwineAbility(Cost cost, String reminderText) {
super(Zone.STACK, null);
this.additionalCost = new OptionalAdditionalCostImpl(keywordText, "-", reminderText, cost);
setRuleAtTheTop(true);
@ -80,28 +80,32 @@ public class EntwineAbility extends StaticAbility implements OptionalAdditionalM
@Override
public void changeModes(Ability ability, Game game) {
if (ability instanceof SpellAbility) {
Player player = game.getPlayer(controllerId);
if (player != null) {
this.resetCosts();
if (additionalCost != null) {
if (additionalCost.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
&& player.chooseUse(Outcome.Benefit, "Pay " + additionalCost.getText(false) + " ?", ability, game)) {
if (!(ability instanceof SpellAbility)) {
return;
}
Player player = game.getPlayer(controllerId);
if (player == null) {
return;
}
this.resetCosts();
if (additionalCost == null) {
return;
}
if (additionalCost.canPay(ability, ability.getSourceId(), ability.getControllerId(), game)
&& player.chooseUse(Outcome.Benefit, "Pay " + additionalCost.getText(false) + " ?", ability, game)) {
additionalCost.activate();
ability.getModes().setAdditionalCost(this);
ability.getModes().setMinModes(2);
ability.getModes().setMaxModes(2);
}
}
}
additionalCost.activate();
int modeCount = ability.getModes().size();
ability.getModes().setAdditionalCost(this);
ability.getModes().setMinModes(modeCount);
ability.getModes().setMaxModes(modeCount);
}
}
@Override
public void addOptionalAdditionalModeCosts(Ability ability, Game game) {
if (additionalCost.isActivated()) {
for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext();) {
for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext(); ) {
Cost cost = (Cost) it.next();
if (cost instanceof ManaCostsImpl) {
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());