mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
Implemented Kaya's Guile
This commit is contained in:
parent
d4c633dd70
commit
a18c3e1d88
3 changed files with 89 additions and 25 deletions
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue