Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ public boolean accepts(InkColor color) {

@Override
public long addEnergy(InkColor color, long amount) {
if (color == storedColor) {
long resultingAmount = this.storedEnergy + amount;
this.storedEnergy = resultingAmount;
if (resultingAmount > this.maxEnergy) {
long overflow = this.storedEnergy - this.maxEnergy;
this.storedEnergy = this.maxEnergy;
return overflow;
}
return 0;
} else if (this.storedEnergy == 0) {
if (color != storedColor && this.storedEnergy != 0)
return amount;
if (this.storedEnergy == 0)
this.storedColor = color;
this.storedEnergy = amount;
long resultingAmount = this.storedEnergy + amount;
this.storedEnergy = resultingAmount;
if (resultingAmount > this.maxEnergy) {
long overflow = this.storedEnergy - this.maxEnergy;
this.storedEnergy = this.maxEnergy;
return overflow;
}
return amount;
return 0;
}

@Override
Expand Down
Loading