Fixed minor problem of Volrath's Laboratory. Added combat flag to LIFE_LOST event.

This commit is contained in:
LevelX2 2016-09-28 08:00:32 +02:00
parent 9676f24752
commit 9cf9d69c55
134 changed files with 163 additions and 146 deletions

View file

@ -76,7 +76,7 @@ public class PayLifeCost extends CostImpl {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
int lifeToPayAmount = amount.calculate(game, ability, null);
this.paid = game.getPlayer(controllerId).loseLife(lifeToPayAmount, game) == lifeToPayAmount;
this.paid = game.getPlayer(controllerId).loseLife(lifeToPayAmount, game, false) == lifeToPayAmount;
return paid;
}

View file

@ -75,7 +75,7 @@ public class PhyrexianManaCost extends ColoredManaCost {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
this.paid = game.getPlayer(controllerId).loseLife(2, game) == 2;
this.paid = game.getPlayer(controllerId).loseLife(2, game, false) == 2;
return paid;
}

View file

@ -31,7 +31,7 @@ public class LoseHalfLifeEffect extends OneShotEffect {
if (player != null) {
int amount = (player.getLife() + 1) / 2;
if (amount > 0) {
player.loseLife(amount, game);
player.loseLife(amount, game, false);
return true;
}
}

View file

@ -71,7 +71,7 @@ public class LoseLifeAllPlayersEffect extends OneShotEffect {
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game);
player.loseLife(amount.calculate(game, source, this), game, false);
}
}
return true;

View file

@ -76,7 +76,7 @@ public class LoseLifeControllerAttachedEffect extends OneShotEffect {
if (creature != null) {
Player player = game.getPlayer(creature.getControllerId());
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game);
player.loseLife(amount.calculate(game, source, this), game, false);
return true;
}
}

View file

@ -80,7 +80,7 @@ public class LoseLifeDefendingPlayerEffect extends OneShotEffect {
defender = game.getPlayer(getTargetPointer().getFirst(game, source));
}
if (defender != null) {
defender.loseLife(amount.calculate(game, source, this), game);
defender.loseLife(amount.calculate(game, source, this), game, false);
}
return true;
}

View file

@ -66,7 +66,7 @@ public class LoseLifeOpponentsEffect extends OneShotEffect {
for (UUID opponentId: game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(opponentId);
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game);
player.loseLife(amount.calculate(game, source, this), game, false);
}
}
return true;

View file

@ -68,7 +68,7 @@ public class LoseLifeSourceControllerEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game);
player.loseLife(amount.calculate(game, source, this), game, false);
return true;
}
return false;

View file

@ -91,7 +91,7 @@ public class LoseLifeTargetControllerEffect extends OneShotEffect {
}
if ( controller != null ) {
controller.loseLife(amount, game);
controller.loseLife(amount, game, false);
return true;
}
}

View file

@ -67,7 +67,7 @@ public class LoseLifeTargetEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
player.loseLife(amount.calculate(game, source, this), game);
player.loseLife(amount.calculate(game, source, this), game, false);
return true;
}
return false;

View file

@ -106,7 +106,7 @@ class ExtortEffect extends OneShotEffect {
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
int loseLife = 0;
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
loseLife += game.getPlayer(opponentId).loseLife(1, game);
loseLife += game.getPlayer(opponentId).loseLife(1, game, false);
}
if (loseLife > 0) {
game.getPlayer(source.getControllerId()).gainLife(loseLife, game);

View file

@ -109,6 +109,13 @@ public class GameEvent implements Serializable {
PLAYER_LIFE_CHANGE,
GAIN_LIFE, GAINED_LIFE,
LOSE_LIFE, LOST_LIFE,
/* LOSE_LIFE + LOST_LIFE
targetId the id of the player loosing life
sourceId the id of the player loosing life
playerId the id of the player loosing life
amount amount of life loss
flag true = from comabat damage - other from non combat damage
*/
PLAY_LAND, LAND_PLAYED,
CREW_VEHICLE,
/* CREW_VEHICLE

View file

@ -111,7 +111,14 @@ public interface Player extends MageItem, Copyable<Player> {
void setLife(int life, Game game);
int loseLife(int amount, Game game);
/**
*
* @param amount amount of life loss
* @param game
* @param atCombat was the source combat damage
* @return
*/
int loseLife(int amount, Game game, boolean atCombat);
int gainLife(int amount, Game game);

View file

@ -1699,7 +1699,7 @@ public abstract class PlayerImpl implements Player, Serializable {
if (life > this.life) {
gainLife(life - this.life, game);
} else if (life < this.life) {
loseLife(this.life - life, game);
loseLife(this.life - life, game, false);
}
}
@ -1730,17 +1730,17 @@ public abstract class PlayerImpl implements Player, Serializable {
}
@Override
public int loseLife(int amount, Game game) {
public int loseLife(int amount, Game game, boolean atCombat) {
if (!canLoseLife) {
return 0;
}
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, false);
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, atCombat);
if (!game.replaceEvent(event)) {
this.life -= event.getAmount();
if (!game.isSimulation()) {
game.informPlayers(this.getLogName() + " loses " + event.getAmount() + " life");
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LOST_LIFE, playerId, playerId, playerId, amount));
game.fireEvent(new GameEvent(GameEvent.EventType.LOST_LIFE, playerId, playerId, playerId, amount, atCombat));
return amount;
}
return 0;
@ -1820,7 +1820,7 @@ public abstract class PlayerImpl implements Player, Serializable {
} else {
GameEvent damageToLifeLossEvent = new GameEvent(EventType.DAMAGE_CAUSES_LIFE_LOSS, playerId, sourceId, playerId, actualDamage, combatDamage);
if (!game.replaceEvent(damageToLifeLossEvent)) {
this.loseLife(damageToLifeLossEvent.getAmount(), game);
this.loseLife(damageToLifeLossEvent.getAmount(), game, combatDamage);
}
}
if (sourceAbilities != null && sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) {