Online-TicTacToe

Log | Files | Refs | README | LICENSE

commit 300b51b6608b51a93f425ccbb01bacf5b02a96c4
parent 3c0c7f83a26a6dd552d711b06ddb4fffd4671704
Author: adglas21 <adamglasheen99@gmail.com>
Date:   Wed, 27 Nov 2024 18:56:38 +0000

Timer - nearly finalised

Diffstat:
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java | 20++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java @@ -136,7 +136,7 @@ public class MainContentPanel extends CustomPanel { client.openGames += "\n" + newGameData; //seperates each new game } } - + startTimer(); refresh(); // refresh the list to show if there is a new game added }); @@ -147,7 +147,6 @@ public class MainContentPanel extends CustomPanel { client.UID2 = client.proxy.joinGame(Integer.parseInt(client.UID), Integer.parseInt(client.GID_Temp)); client.GID = client.GID_Temp; client.HOST_UID = ""; - startTimer(); } else { System.out.println("no game selected."); } @@ -241,7 +240,10 @@ public class MainContentPanel extends CustomPanel { private void startTimer() { // Remaining time is 15 minutes - remainingTime = 15 * 60; + remainingTime = 1 * 15; + + //commented out as longer duration + //remainingTime =15*60; // Create a timer that updates every second timer = new Timer(1000, e -> { @@ -257,7 +259,17 @@ public class MainContentPanel extends CustomPanel { if (remainingTime <= 0) { timer.stop(); - gameTimerLabel.setText("Finished"); + gameTimerLabel.setText("No opponent, please try again"); + + //currently the game deletes when noone joins, however when the user makes a move and waits the game does not delete and is + //still present in the list of games + String deleteGame = client.proxy.deleteGame(Integer.parseInt(client.GID), Integer.parseInt(client.UID)); + + System.out.println(deleteGame); + client.resetGame(); + client.showPanel(new MainContentPanel(client)); + refresh(); + } }); timer.start();