mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 10:54:51 +00:00
IDK
This commit is contained in:
@@ -14,7 +14,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||||||
*/
|
*/
|
||||||
public class EventRegistry {
|
public class EventRegistry {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(Main.class);
|
private static final Logger logger = LogManager.getLogger(EventRegistry.class);
|
||||||
|
|
||||||
private static final Map<Class<?>, CopyOnWriteArrayList<EventEntry<?>>> eventHistory =
|
private static final Map<Class<?>, CopyOnWriteArrayList<EventEntry<?>>> eventHistory =
|
||||||
new ConcurrentHashMap<>();
|
new ConcurrentHashMap<>();
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class TicTacToeServer extends TcpServer {
|
|||||||
case MOVE -> {
|
case MOVE -> {
|
||||||
if (segments.length == 2 && !segments[1].isEmpty()) {
|
if (segments.length == 2 && !segments[1].isEmpty()) {
|
||||||
this.command = commandEnum;
|
this.command = commandEnum;
|
||||||
this.arguments = new ArrayList<Object>();
|
this.arguments = new ArrayList<Object>(1);
|
||||||
this.arguments.add(segments[1]);
|
this.arguments.add(segments[1]);
|
||||||
this.returnMessage = TicTacToeServerMessage.OK;
|
this.returnMessage = TicTacToeServerMessage.OK;
|
||||||
this.isValidCommand = true;
|
this.isValidCommand = true;
|
||||||
@@ -81,17 +81,44 @@ public class TicTacToeServer extends TcpServer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case
|
case FORFEIT -> {
|
||||||
|
this.command = commandEnum;
|
||||||
|
this.arguments = null;
|
||||||
|
this.returnMessage = TicTacToeServerMessage.OK;
|
||||||
|
this.isValidCommand = true;
|
||||||
|
this.errorMessage = null;
|
||||||
|
this.originalCommand = receivedCommand;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case MESSAGE -> {
|
||||||
|
if (segments.length == 3 && !segments[2].isEmpty()) {
|
||||||
|
this.command = commandEnum;
|
||||||
|
this.arguments = new ArrayList<Object>(2);
|
||||||
|
this.arguments.add(segments[2]);
|
||||||
|
this.returnMessage = TicTacToeServerMessage.OK;
|
||||||
|
this.isValidCommand = true;
|
||||||
|
this.errorMessage = null;
|
||||||
|
this.originalCommand = receivedCommand;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case BYE, DISCONNECT, LOGOUT, QUIT, EXIT -> {
|
||||||
|
this.command = commandEnum;
|
||||||
|
this.arguments = null;
|
||||||
|
this.returnMessage = TicTacToeServerMessage.OK;
|
||||||
|
this.isValidCommand = true;
|
||||||
|
this.errorMessage = null;
|
||||||
|
this.originalCommand = receivedCommand;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParsedCommand parseCommand(String command) {
|
private ParsedCommand parseCommand(String command) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gameThread() {
|
private void gameThread() {
|
||||||
@@ -99,11 +126,9 @@ public class TicTacToeServer extends TcpServer {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
String command = getNewestCommand();
|
String command = getNewestCommand();
|
||||||
command = this.parseCommand(command);
|
command = this.parseCommand(command).toString();
|
||||||
if (command == null) { continue; }
|
if (command == null) { continue; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Game
|
// TODO: Game
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.toop.Main;
|
|||||||
|
|
||||||
public class MinMaxTicTacToe {
|
public class MinMaxTicTacToe {
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger(Main.class);
|
private static final Logger logger = LogManager.getLogger(MinMaxTicTacToe.class);
|
||||||
|
|
||||||
public int findBestMove(TicTacToe game) {
|
public int findBestMove(TicTacToe game) {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.toop.Main;
|
|||||||
|
|
||||||
public class TicTacToe extends GameBase {
|
public class TicTacToe extends GameBase {
|
||||||
public int moveCount;
|
public int moveCount;
|
||||||
private static final Logger logger = LogManager.getLogger(Main.class);
|
private static final Logger logger = LogManager.getLogger(TicTacToe.class);
|
||||||
|
|
||||||
public TicTacToe(String player1, String player2) {
|
public TicTacToe(String player1, String player2) {
|
||||||
super(3); // 3x3 Grid
|
super(3); // 3x3 Grid
|
||||||
|
|||||||
Reference in New Issue
Block a user