Don't add/subtract time when they're jailed forever
This fixes an issue brought up in #69
This commit is contained in:
parent
307a096acc
commit
2dfa34c05c
@ -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) {
|
||||||
this.time += time;
|
if(this.time != -1L) {
|
||||||
this.changed = true;
|
this.time += time;
|
||||||
|
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) {
|
||||||
this.time -= time;
|
if(this.time != -1L) {
|
||||||
this.changed = true;
|
this.time -= time;
|
||||||
|
this.changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
return this.time;
|
return this.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user