Implemented GUI side of resetting the board

This commit is contained in:
2021-03-19 11:15:22 +01:00
parent b72e03711a
commit fa7bda4230
4 changed files with 14 additions and 11 deletions

View File

@@ -82,6 +82,11 @@ public class TicTacToe_Client {
} }
//this.drawWinningLine(winCoordinates); //this.drawWinningLine(winCoordinates);
//client.exitProcess(); //client.exitProcess();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
client.resetBoard(); client.resetBoard();
} }
} else { } else {

View File

@@ -152,6 +152,10 @@ public class Client {
} }
} }
public void printLog(String message, boolean success){
clientLogger.printLog(message, success, LogType.Log);
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@@ -23,7 +23,6 @@ public class Engine extends Application {
private boolean mouseClicked = false; private boolean mouseClicked = false;
private Point coordinates = new Point(); private Point coordinates = new Point();
private Stage primaryStage; private Stage primaryStage;
private MouseEvent mouseEvent;
public Engine() { public Engine() {
setEngine(this); setEngine(this);
@@ -91,6 +90,9 @@ public class Engine extends Application {
System.err.println("Wrong length of gameState string"); System.err.println("Wrong length of gameState string");
return; return;
} }
if (gameState.equals("---------")){
grid.getChildren().clear();
}
for (int i = 0; i < gameState.length(); i++) { for (int i = 0; i < gameState.length(); i++) {
int column = i / 3; int column = i / 3;
int row = i % 3; int row = i % 3;

View File

@@ -208,8 +208,6 @@ public class SinglePlayerServer {
case "exit": case "exit":
try { try {
outstreams.get(client).writeInt(200);
outstreams.get(client).flush();
outstreams.get(client).close(); outstreams.get(client).close();
instreams.get(client).close(); instreams.get(client).close();
client.close(); client.close();
@@ -220,14 +218,8 @@ public class SinglePlayerServer {
break; break;
case "reset": case "reset":
try {
outstreams.get(client).writeInt(200);
outstreams.get(client).flush();
ticTacToe_server.resetGameState(); ticTacToe_server.resetGameState();
this.gameFlow("gameState", client); this.sendGameState(client);
} catch (IOException e) {
e.printStackTrace();
}
break; break;
} }
} }