Move case done

This commit is contained in:
Bas de Jong
2025-09-16 12:01:39 +02:00
parent 9d7b387dec
commit 82f4f0c2ac

View File

@@ -50,6 +50,7 @@ public class TicTacToeServer extends TcpServer {
this.command = null; this.command = null;
this.arguments = null; this.arguments = null;
this.isValidCommand = false; this.isValidCommand = false;
this.returnMessage = TicTacToeServerMessage.ERR;
this.errorMessage = "The received command is empty"; this.errorMessage = "The received command is empty";
this.originalCommand = receivedCommand; this.originalCommand = receivedCommand;
return; return;
@@ -60,6 +61,7 @@ public class TicTacToeServer extends TcpServer {
this.command = null; this.command = null;
this.arguments = null; this.arguments = null;
this.isValidCommand = false; this.isValidCommand = false;
this.returnMessage = TicTacToeServerMessage.ERR;
this.errorMessage = "The received command is empty or couldn't be split"; this.errorMessage = "The received command is empty or couldn't be split";
this.originalCommand = receivedCommand; this.originalCommand = receivedCommand;
return; return;
@@ -69,8 +71,14 @@ public class TicTacToeServer extends TcpServer {
switch (commandEnum) { switch (commandEnum) {
case MOVE -> { case MOVE -> {
if (segments.length == 2 && !segments[1].isEmpty()) { if (segments.length == 2 && !segments[1].isEmpty()) {
ParsedCommand toReturn = new ParsedCommand(commandEnum, new ArrayList<Object>(1)); this.command = commandEnum;
toReturn.arguments.add(segments[1]); this.arguments = new ArrayList<Object>();
this.arguments.add(segments[1]);
this.returnMessage = TicTacToeServerMessage.OK;
this.isValidCommand = true;
this.errorMessage = null;
this.originalCommand = receivedCommand;
return;
} }
} }
case case