mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Fixed a problem with variable life costs (e.g. Toxic Deluge) and prevent pay life effects (e.g. Angel of Jubilation) that did not work for those spells.
This commit is contained in:
parent
5b3bc1f96d
commit
4365449be3
2 changed files with 10 additions and 12 deletions
|
@ -1,16 +1,13 @@
|
|||
|
||||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import java.util.UUID;
|
||||
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.game.Game;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -36,11 +33,12 @@ public class PayLifeCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
//118.4. If a cost or effect allows a player to pay an amount of life greater than 0,
|
||||
//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 his or
|
||||
//amount of the payment. If a player pays life, the payment is subtracted from his or
|
||||
//her 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()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
@ -12,7 +10,6 @@ import mage.players.Player;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class PayVariableLifeCost extends VariableCostImpl {
|
||||
|
||||
public PayVariableLifeCost() {
|
||||
|
@ -21,7 +18,7 @@ public class PayVariableLifeCost extends VariableCostImpl {
|
|||
|
||||
public PayVariableLifeCost(boolean additionalCostText) {
|
||||
super("life to pay");
|
||||
this.text = new StringBuilder(additionalCostText ? "as an additional cost to cast this spell, pay ":"Pay ")
|
||||
this.text = new StringBuilder(additionalCostText ? "as an additional cost to cast this spell, pay " : "Pay ")
|
||||
.append(xText).append(' ').append("life").toString();
|
||||
}
|
||||
|
||||
|
@ -44,7 +41,10 @@ public class PayVariableLifeCost extends VariableCostImpl {
|
|||
int maxValue = 0;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
maxValue = controller.getLife();
|
||||
// Paying 0 life is not considered paying any life, so paying 0 is still allowed
|
||||
if (game.getPlayer(source.getControllerId()).canPayLifeCost()) {
|
||||
maxValue = controller.getLife();
|
||||
}
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue