forked from External/mage
Improved and fixed X mana cost and pays, mana pool:
* Pay X abilities - fixed that it spends all available mana pool instead only needed; * Pay X abilities - added support of interactions with other X effects like Rosheen Meanderer's mana usage for "pay X to prevent"; * Rosheen Meanderer - fixed that it can't use mana for "you may pay X" like Flameblast Dragon's effect (#5206); * Devs: added support to use VariableManaCost to pay X in code (without generic's workaround, use ManaUtil.createManaCost to generate cost to pay);
This commit is contained in:
parent
500fc935e4
commit
437861ec20
20 changed files with 675 additions and 192 deletions
|
|
@ -4,9 +4,10 @@ import mage.MageObject;
|
|||
import mage.Mana;
|
||||
import mage.ManaSymbol;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaSymbols;
|
||||
import mage.abilities.costs.mana.*;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.mana.*;
|
||||
import mage.cards.Card;
|
||||
import mage.choices.Choice;
|
||||
|
|
@ -494,4 +495,21 @@ public final class ManaUtil {
|
|||
destColors.setGreen(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static ManaCost createManaCost(int manaValue) {
|
||||
return new GenericManaCost(manaValue);
|
||||
}
|
||||
|
||||
public static ManaCost createManaCost(DynamicValue manaValue, Game game, Ability sourceAbility, Effect effect) {
|
||||
int costValue = manaValue.calculate(game, sourceAbility, effect);
|
||||
if (manaValue instanceof ManacostVariableValue) {
|
||||
// variable (X must be final value after all events and effects)
|
||||
VariableManaCost xCost = new VariableManaCost();
|
||||
xCost.setAmount(costValue, costValue, false);
|
||||
return xCost;
|
||||
} else {
|
||||
// static/generic
|
||||
return new GenericManaCost(costValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue