Online-TicTacToe

Log | Files | Refs | README | LICENSE

commit a2dd639b26e6066183b45cad1a27de3edb95b69b
parent 9fa0fa620a7867737a2ce84d568c9c9656dc6d42
Author: lukeeeeeee334 <lukeosullivan123@gmail.com>
Date:   Thu, 28 Nov 2024 14:57:12 +0000

final bug fixes - luke

fixed the open games display bug
fixed the 2nd game no win bug
fixed the timer so that it stops and resets when a player joins

Diffstat:
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/ContentPanes/MainContentPanel.java | 12++++++++++--
MTicTacToeClient/src/main/java/com/groupproject/tictactoeclient/PollingThread.java | 12+++++++++---
2 files changed, 19 insertions(+), 5 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 @@ -254,14 +254,15 @@ public class MainContentPanel extends CustomPanel { private void startTimer() { // Remaining time is 15 minutes - remainingTime = 1 * 15; + //remainingTime = 1 * 15; //commented out as longer duration - //remainingTime =15*60; + remainingTime =15*60; // Create a timer that updates every second timer = new Timer(1000, e -> { // Countdown time + timer.start(); remainingTime--; int minutes = remainingTime / 60; @@ -270,6 +271,13 @@ public class MainContentPanel extends CustomPanel { String time = String.format("%02d:%02d", minutes, seconds); gameTimerLabel.setText(time); + + if (client.NUM_OF_MOVES >= 2) { + timer.restart(); + timer.stop(); + + + } if (remainingTime <= 0) { timer.stop(); diff --git a/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/PollingThread.java b/TicTacToeClient/src/main/java/com/groupproject/tictactoeclient/PollingThread.java @@ -40,23 +40,29 @@ public class PollingThread implements Runnable { client.openGames = client.proxy.showOpenGames(); client.refreshCurrentPanel(); + System.out.println("open games panel resetting\n"); // if there is no game id, dont run code below if (client.GID.isBlank() || client.GID.isEmpty()) { continue; } + // if there are no moves, dont run code below if (client.NUM_OF_MOVES < 2) { continue; } + //call the web server to check if the game has been won or not yet String result = client.proxy.checkWin(Integer.parseInt(client.GID)); - + System.out.println("checkWin: " + result); //if the game is not over check the result of the game - if (!gameOver) { + //if (!gameOver) { + System.out.println("gameOver not working"); switch (result) { + + case "1": // Player 1 wins JOptionPane.showMessageDialog(client.frame, "Player 1 wins!"); @@ -85,7 +91,7 @@ public class PollingThread implements Runnable { JOptionPane.showMessageDialog(client.frame, "Error checking the game status."); } - } + //} } catch (Exception e) { e.printStackTrace();