Skip to content

Commit

Permalink
timer fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xfredeq committed Feb 6, 2022
1 parent 1c0849e commit 8c80685
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Client/find-all-words/resources/config.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#saved
#Sun Feb 06 01:51:54 CET 2022
#Sun Feb 06 16:11:35 CET 2022
defaultPort=1313
about=TODO
serverAddress=127.0.0.1
Expand Down
14 changes: 8 additions & 6 deletions Client/find-all-words/src/put/poznan/GUI/VoteView.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public void onShowAction() {
this.updatePlayersList.execute();
this.updateTimer = new UpdateTimer();
this.updateTimer.execute();
this.vote.setEnabled(true);
this.timer = new GameTimer();
System.out.println("List of nicks updater started");
}

Expand Down Expand Up @@ -158,7 +160,7 @@ protected Void doInBackground() {
lock.wait();
publish(ConnectionHandler.responseTable.get("timerStart").response);
} catch (InterruptedException e) {
e.printStackTrace();
//e.printStackTrace();
return null;
}
}
Expand All @@ -168,7 +170,7 @@ protected Void doInBackground() {
lock.wait();
publish(ConnectionHandler.responseTable.get("gameStart").response);
} catch (InterruptedException e) {
e.printStackTrace();
//e.printStackTrace();
return null;
}
}
Expand All @@ -181,14 +183,14 @@ protected void process(List<String> chunks) {
String response = chunks.get(chunks.size() - 1);
List<String> split;
split = new ArrayList<>(List.of(response.split("_")));

if ("NOTIFICATION_START_COUNTDOWN_10".equals(response)) {
System.out.println(split);
if (response.matches("NOTIFICATION_START_COUNTDOWN_[0-9]+")) {
vote.setEnabled(false);
timerLabel.setText("Game starts in...");
timer.setTime(Integer.parseInt(split.get(3)) * 1000);
timer.start();
}
if ("NOTIFICATION_START_GAME".equals(response)) {
if (response.matches("NOTIFICATION_START_GAME_[0-9]+")) {
timer.stop();
fakeButton.doClick();

Expand All @@ -210,7 +212,7 @@ protected Void doInBackground() {
lock.wait();
publish(ConnectionHandler.responseTable.get("playersVotes").response);
} catch (InterruptedException e) {
e.printStackTrace();
//e.printStackTrace();
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void initializeTable() {
responseTable.put("playersVotes", new Triplet("NOTIFICATION_LOBBY_PLAYERS_[0-9]_.{4,}_[0-1]_.*"));
responseTable.put("selfVote", new Triplet("RESPONSE_LOBBY_VOTE_.{7}_[0-1]"));
responseTable.put("timerStart", new Triplet("NOTIFICATION_START_COUNTDOWN_10"));
responseTable.put("gameStart", new Triplet("NOTIFICATION_START_GAME"));
responseTable.put("gameStart", new Triplet("NOTIFICATION_START_GAME_[0-9]+"));
}
@SuppressWarnings("unused")
public static String getMessage() {
Expand Down

0 comments on commit 8c80685

Please sign in to comment.