Skip to content

Commit

Permalink
fixes time counting bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lubeskih committed Dec 8, 2020
1 parent 0cfa04d commit 88a5dbf
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/com/company/server/GameCoordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ public void run() {
this.p2totalTime = Duration.between(starts, end);
payload = "Player 2 took: " + this.p2totalTime.getSeconds() + " seconds (" + this.p2totalTime.toMinutes() + " minutes).";

this.totalTeamTime = this.totalTeamTime.plus(Duration.between(starts, end));
if (this.totalTeamTime != null) {
this.totalTeamTime = this.totalTeamTime.plus(Duration.between(starts, end));
} else {
this.totalTeamTime = Duration.between(starts, end);
}

notify = new Message(false, 100, false, payload);
sendMessage(notify, p1);
Expand All @@ -217,9 +221,14 @@ public void run() {
this.p1totalTime = null;
}

payload = "Total time for the team " + team.teamname +
" is " + this.totalTeamTime.toSeconds() +
" seconds (" + this.totalTeamTime.toMinutes() + ") minutes.";
if (this.totalTeamTime != null) {
payload = "Total time for the team " + team.teamname +
" is " + this.totalTeamTime.toSeconds() +
" seconds (" + this.totalTeamTime.toMinutes() + ") minutes.";
} else {
payload = "You both failed to submit valid text. :(";
}

notify = new Message(false, 100, false, payload);
sendMessage(notify, p1);
sendMessage(notify, p2);
Expand Down

0 comments on commit 88a5dbf

Please sign in to comment.