Don't add/subtract time when they're jailed forever

This fixes an issue brought up in #69
This commit is contained in:
graywolf336 2015-05-21 15:03:46 -05:00
parent 307a096acc
commit 2dfa34c05c

View File

@ -131,26 +131,32 @@ public class Prisoner {
} }
/** /**
* Adds the given time to the remaining time the prisoner has left. * Adds the given time to the remaining time the prisoner has left, unless they're jailed forever.
* *
* @param time to add to the prisoner's remaining time. * @param time to add to the prisoner's remaining time.
* @return the new remaining time the prisoner has * @return the new remaining time the prisoner has
*/ */
public long addTime(long time) { public long addTime(long time) {
if(this.time != -1L) {
this.time += time; this.time += time;
this.changed = true; this.changed = true;
}
return this.time; return this.time;
} }
/** /**
* Subtracts the given time from the remaining time the prisoner has left. * Subtracts the given time from the remaining time the prisoner has left, unless they're jailed forever.
* *
* @param time to subtract from the prisoner's remaining time. * @param time to subtract from the prisoner's remaining time.
* @return the new remaining time the prisoner has * @return the new remaining time the prisoner has
*/ */
public long subtractTime(long time) { public long subtractTime(long time) {
if(this.time != -1L) {
this.time -= time; this.time -= time;
this.changed = true; this.changed = true;
}
return this.time; return this.time;
} }