Skip to content

Commit

Permalink
Implemented schedule check system to GameStateTimer (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKaVu committed May 24, 2023
1 parent b2ae3ae commit 990f667
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/dev/kavu/gameapi/GameStateTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public GameState getCurrentState() {
return currentState;
}

public GameTimerSchedule getSchedule() {
return schedule;
}

public long getStateTime() {
return stateTime;
}
Expand Down Expand Up @@ -108,14 +112,21 @@ private boolean shouldCancel(){

if (timerOvercount || currentState.shouldEnd()) {
currentState.onEnd();
if(schedule != null){
initialize(schedule.next());
}
return true;
}

return false;
}

public void terminate(){
initialize(GameState.EMPTY);
public void terminate(boolean runNext){
if(runNext && schedule != null) {
initialize(schedule.next());
} else {
initialize(GameState.EMPTY);
}
pause();
}

Expand Down

0 comments on commit 990f667

Please sign in to comment.