reworked/simplified/consolidated effects which exchange life totals, added test (fixes #7668)

This commit is contained in:
Evan Kranzler 2021-03-14 15:56:48 -04:00
parent 1abeec9595
commit d4792e3665
16 changed files with 284 additions and 274 deletions

View file

@ -2063,6 +2063,18 @@ public abstract class PlayerImpl implements Player, Serializable {
return 0;
}
@Override
public void exchangeLife(Player player, Ability source, Game game) {
int lifePlayer1 = getLife();
int lifePlayer2 = player.getLife();
if ((lifePlayer1 != lifePlayer2 && this.isLifeTotalCanChange() && player.isLifeTotalCanChange())
&& (lifePlayer1 >= lifePlayer2 || (this.isCanGainLife() && player.isCanLoseLife()))
&& (lifePlayer1 <= lifePlayer2 || (this.isCanLoseLife() && player.isCanGainLife()))) {
this.setLife(lifePlayer2, game, source);
player.setLife(lifePlayer1, game, source);
}
}
@Override
public int damage(int damage, UUID attackerId, Ability source, Game game) {
return doDamage(damage, attackerId, source, game, false, true, null);