Skip to content
Merged
Show file tree
Hide file tree
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 @@ -17,14 +17,5 @@ public FixedSingleInkStorage(long maxEnergy, InkColor color, long amount) {
public boolean accepts(InkColor color) {
return this.storedColor == color;
}

@Override
public long getRoom(InkColor color) {
if (this.storedColor == color) {
return this.maxEnergy - this.storedEnergy;
} else {
return 0;
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ public boolean accepts(InkColor color) {

@Override
public long addEnergy(InkColor color, long amount) {
if (color != storedColor && this.storedEnergy != 0)
if (color != storedColor && this.storedEnergy != 0 || !this.accepts(color))
return amount;
if (this.storedEnergy == 0)
if (this.storedEnergy == 0) {
this.storedColor = color;
}
long resultingAmount = this.storedEnergy + amount;
this.storedEnergy = resultingAmount;
if (resultingAmount > this.maxEnergy) {
Expand Down Expand Up @@ -138,7 +139,7 @@ public void addTooltip(List<Component> tooltip) {

@Override
public long getRoom(InkColor color) {
if (this.storedEnergy == 0 || this.storedColor == color) {
if (this.accepts(color)) {
return this.maxEnergy - this.storedEnergy;
} else {
return 0;
Expand Down
Loading