CardUtil overflow

This commit is contained in:
Zzooouhh 2017-12-23 23:17:53 +01:00 committed by GitHub
parent ab3128975a
commit 2bb4f07df2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1760,7 +1760,7 @@ public abstract class PlayerImpl implements Player, Serializable {
GameEvent event = new GameEvent(GameEvent.EventType.LOSE_LIFE, playerId, playerId, playerId, amount, atCombat);
if (!game.replaceEvent(event)) {
// this.life -= event.getAmount();
this.life = game.subtractWithOverflowCheck(this.life, event.getAmount());
this.life = CardUtil.subtractWithOverflowCheck(this.life, event.getAmount());
if (!game.isSimulation()) {
game.informPlayers(this.getLogName() + " loses " + event.getAmount() + " life");
}
@ -1792,7 +1792,7 @@ public abstract class PlayerImpl implements Player, Serializable {
// TODO: lock life at Integer.MAX_VALUE if reached, until it's set to a different amount
// (https://magic.wizards.com/en/articles/archive/news/unstable-faqawaslfaqpaftidawabiajtbt-2017-12-06 - "infinite" life total stays infinite no matter how much is gained or lost)
// this.life += event.getAmount();
this.life = game.addWithOverflowCheck(this.life, event.getAmount());
this.life = CardUtil.addWithOverflowCheck(this.life, event.getAmount());
if (!game.isSimulation()) {
game.informPlayers(this.getLogName() + " gains " + event.getAmount() + " life");
}