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
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -12,9 +10,9 @@ import mage.constants.Outcome;
|
|||
import mage.game.Game;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
import mage.util.ManaUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CounterUnlessPaysEffect extends OneShotEffect {
|
||||
|
|
@ -54,23 +52,27 @@ public class CounterUnlessPaysEffect extends OneShotEffect {
|
|||
Player player = game.getPlayer(spell.getControllerId());
|
||||
if (player != null) {
|
||||
Cost costToPay;
|
||||
String costValueMessage;
|
||||
if (cost != null) {
|
||||
costToPay = cost.copy();
|
||||
costValueMessage = costToPay.getText();
|
||||
} else {
|
||||
costToPay = new GenericManaCost(genericMana.calculate(game, source, this));
|
||||
costValueMessage = "{" + genericMana.calculate(game, source, this) + "}";
|
||||
costToPay = ManaUtil.createManaCost(genericMana, game, source, this);
|
||||
}
|
||||
String message;
|
||||
if (costToPay instanceof ManaCost) {
|
||||
message = "Would you like to pay " + costToPay.getText() + " to prevent counter effect?";
|
||||
message = "Would you like to pay " + costValueMessage + " to prevent counter effect?";
|
||||
} else {
|
||||
message = costToPay.getText() + " to prevent counter effect?";
|
||||
message = costValueMessage + " to prevent counter effect?";
|
||||
}
|
||||
|
||||
costToPay.clearPaid();
|
||||
if (!(player.chooseUse(Outcome.Benefit, message, source, game) && costToPay.pay(source, game, spell.getSourceId(), spell.getControllerId(), false, null))) {
|
||||
game.informPlayers(player.getLogName() + " chooses not to pay " + costToPay.getText() + " to prevent the counter effect");
|
||||
game.informPlayers(player.getLogName() + " chooses not to pay " + costValueMessage + " to prevent the counter effect");
|
||||
return game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
||||
}
|
||||
game.informPlayers(player.getLogName() + " chooses to pay " + costToPay.getText() + " to prevent the counter effect");
|
||||
game.informPlayers(player.getLogName() + " chooses to pay " + costValueMessage + " to prevent the counter effect");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue