"Total life can't change" support

This commit is contained in:
magenoxx 2011-07-31 16:48:15 +04:00
parent 962f91d3da
commit 3387b4b741
4 changed files with 24 additions and 1 deletions

View file

@ -53,6 +53,9 @@ public class PayLifeCost extends CostImpl<PayLifeCost> {
@Override
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
if (amount > 0 && !game.getPlayer(controllerId).isLifeTotalCanChange()) {
return false;
}
return game.getPlayer(controllerId).getLife() > amount;
}

View file

@ -66,6 +66,9 @@ public class PhyrexianManaCost extends ColoredManaCost {
@Override
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
if (!game.getPlayer(controllerId).isLifeTotalCanChange()) {
return false;
}
return game.getPlayer(controllerId).getLife() > 2;
}

View file

@ -83,6 +83,8 @@ public interface Player extends MageItem, Copyable<Player> {
public void setLife(int life, Game game);
public int loseLife(int amount, Game game);
public void gainLife(int amount, Game game);
public boolean isLifeTotalCanChange();
public void setLifeTotalCanChange(boolean lifeTotalCanChange);
public int damage(int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
public Cards getHand();
public int getLandsPlayed();

View file

@ -98,6 +98,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
protected RangeOfInfluence range;
protected Set<UUID> inRange = new HashSet<UUID>();
protected boolean isTestMode = false;
protected boolean lifeTotalCanChange = true;
@Override
public abstract T copy();
@ -139,6 +140,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
this.passedTurn = player.passedTurn;
this.left = player.left;
this.range = player.range;
this.lifeTotalCanChange = player.lifeTotalCanChange;
for (UUID id: player.inRange) {
this.inRange.add(id);
}
@ -176,6 +178,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
this.abilities.clear();
this.landsPerTurn = 1;
this.maxHandSize = 7;
this.lifeTotalCanChange = true;
}
@Override
@ -614,11 +617,22 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
@Override
public void setLife(int life, Game game) {
this.life = life;
if (this.lifeTotalCanChange) this.life = life;
}
@Override
public void setLifeTotalCanChange(boolean lifeTotalCanChange) {
this.lifeTotalCanChange = lifeTotalCanChange;
}
@Override
public boolean isLifeTotalCanChange() {
return this.lifeTotalCanChange;
}
@Override
public int loseLife(int amount, Game game) {
if (!lifeTotalCanChange) return 0;
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, false);
if (!game.replaceEvent(event)) {
setLife(this.life - amount, game);
@ -630,6 +644,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
@Override
public void gainLife(int amount, Game game) {
if (!lifeTotalCanChange) return;
GameEvent event = new GameEvent(GameEvent.EventType.GAIN_LIFE, playerId, playerId, playerId, amount, false);
if (!game.replaceEvent(event)) {
setLife(this.life + amount, game);