mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Merge branch 'angel' into 'master'
Fix paying negative life See merge request core-developers/forge!4716
This commit is contained in:
@@ -1551,7 +1551,7 @@ public class AbilityUtils {
|
|||||||
boolean alreadyPaid = false;
|
boolean alreadyPaid = false;
|
||||||
for (Player payer : allPayers) {
|
for (Player payer : allPayers) {
|
||||||
if (unlessCost.equals("LifeTotalHalfUp")) {
|
if (unlessCost.equals("LifeTotalHalfUp")) {
|
||||||
String halfup = Integer.toString((int) Math.ceil(payer.getLife() / 2.0));
|
String halfup = Integer.toString(Math.max(0,(int) Math.ceil(payer.getLife() / 2.0)));
|
||||||
cost = new Cost("PayLife<" + halfup + ">", true);
|
cost = new Cost("PayLife<" + halfup + ">", true);
|
||||||
}
|
}
|
||||||
alreadyPaid |= payer.getController().payCostToPreventEffect(cost, sa, alreadyPaid, allPayers);
|
alreadyPaid |= payer.getController().payCostToPreventEffect(cost, sa, alreadyPaid, allPayers);
|
||||||
|
|||||||
@@ -76,9 +76,13 @@ public class CostPayLife extends CostPart {
|
|||||||
Integer amount = this.convertAmount();
|
Integer amount = this.convertAmount();
|
||||||
if (amount == null) { // try to calculate when it's defined.
|
if (amount == null) { // try to calculate when it's defined.
|
||||||
amount = AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
|
amount = AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
|
||||||
|
// CR 107.1b
|
||||||
|
if (getAmount().contains("/Half")) {
|
||||||
|
amount = Math.max(amount, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((amount != null) && !payer.canPayLife(amount)) {
|
if (amount != null && !payer.canPayLife(amount)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean canPayLife(final int lifePayment) {
|
public final boolean canPayLife(final int lifePayment) {
|
||||||
if (life < lifePayment) {
|
if (lifePayment > 0 && life < lifePayment) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (lifePayment <= 0) || !hasKeyword("Your life total can't change.");
|
return (lifePayment <= 0) || !hasKeyword("Your life total can't change.");
|
||||||
|
|||||||
@@ -198,8 +198,6 @@ public class HumanPlay {
|
|||||||
req.playAbility(!useOldTargets, false, true);
|
req.playAbility(!useOldTargets, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
private static int getAmountFromPart(CostPart part, Card source, SpellAbility sourceAbility) {
|
private static int getAmountFromPart(CostPart part, Card source, SpellAbility sourceAbility) {
|
||||||
String amountString = part.getAmount();
|
String amountString = part.getAmount();
|
||||||
return StringUtils.isNumeric(amountString) ? Integer.parseInt(amountString) : AbilityUtils.calculateAmount(source, amountString, sourceAbility);
|
return StringUtils.isNumeric(amountString) ? Integer.parseInt(amountString) : AbilityUtils.calculateAmount(source, amountString, sourceAbility);
|
||||||
|
|||||||
Reference in New Issue
Block a user