mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Making Energy actually a counter instead of it's own Player attribute. This should enable it to be displayed when hovering over the Player image.
This commit is contained in:
@@ -19,6 +19,7 @@ package forge.game.cost;
|
|||||||
|
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
|
import forge.game.card.CounterType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ public class CostPayEnergy extends CostPart {
|
|||||||
amount = AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
|
amount = AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return activator.getEnergy() >= amount;
|
return activator.getCounters(CounterType.ENERGY) >= amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
|
|
||||||
private int life = 20;
|
private int life = 20;
|
||||||
private int startingLife = 20;
|
private int startingLife = 20;
|
||||||
private int energy = 0;
|
|
||||||
private final Map<Card, Integer> assignedDamage = new HashMap<Card, Integer>();
|
private final Map<Card, Integer> assignedDamage = new HashMap<Card, Integer>();
|
||||||
private int spellsCastThisTurn = 0;
|
private int spellsCastThisTurn = 0;
|
||||||
private int landsPlayedThisTurn = 0;
|
private int landsPlayedThisTurn = 0;
|
||||||
@@ -493,32 +492,27 @@ public class Player extends GameEntity implements Comparable<Player> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getEnergy() {
|
|
||||||
return energy;
|
|
||||||
}
|
|
||||||
public final void setEnergy(int newEnergy) { energy = newEnergy; }
|
|
||||||
|
|
||||||
public final boolean canPayEnergy(final int energyPayment) {
|
public final boolean canPayEnergy(final int energyPayment) {
|
||||||
return energy >= energyPayment;
|
int cnt = getCounters(CounterType.ENERGY);
|
||||||
|
return cnt >= energyPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int loseEnergy(int lostEnergy) {
|
public final int loseEnergy(int lostEnergy) {
|
||||||
if (lostEnergy > energy) {
|
int cnt = getCounters(CounterType.ENERGY);
|
||||||
return 0;
|
if (lostEnergy > cnt) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
energy -= lostEnergy;
|
cnt -= lostEnergy;
|
||||||
return lostEnergy;
|
counters.put(CounterType.ENERGY, cnt);
|
||||||
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean payEnergy(final int energyPayment, final Card source) {
|
public final boolean payEnergy(final int energyPayment, final Card source) {
|
||||||
if (energyPayment <= 0)
|
if (energyPayment <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// rule 118.8
|
|
||||||
if (energy >= energyPayment) {
|
return canPayEnergy(energyPayment) && loseEnergy(energyPayment) > -1;
|
||||||
return (loseEnergy(energyPayment) > 0);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function handles damage after replacement and prevention effects are applied
|
// This function handles damage after replacement and prevention effects are applied
|
||||||
|
|||||||
@@ -566,15 +566,15 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
|||||||
@Override
|
@Override
|
||||||
public PaymentDecision visit(final CostPayEnergy cost) {
|
public PaymentDecision visit(final CostPayEnergy cost) {
|
||||||
final String amount = cost.getAmount();
|
final String amount = cost.getAmount();
|
||||||
final int life = player.getLife();
|
final int energy = player.getCounters(CounterType.ENERGY);
|
||||||
|
|
||||||
Integer c = cost.convertAmount();
|
Integer c = cost.convertAmount();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
final String sVar = ability.getSVar(amount);
|
final String sVar = ability.getSVar(amount);
|
||||||
// Generalize this
|
// Generalize this
|
||||||
if (sVar.startsWith("XChoice")) {
|
if (sVar.startsWith("XChoice")) {
|
||||||
int limit = life;
|
int limit = energy;
|
||||||
final int maxLifePayment = limit < life ? limit : life;
|
final int maxLifePayment = limit < energy ? limit : energy;
|
||||||
c = chooseXValue(maxLifePayment);
|
c = chooseXValue(maxLifePayment);
|
||||||
} else {
|
} else {
|
||||||
c = AbilityUtils.calculateAmount(source, amount, ability);
|
c = AbilityUtils.calculateAmount(source, amount, ability);
|
||||||
|
|||||||
Reference in New Issue
Block a user