diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index be32fb7..70d0b10 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,6 +7,8 @@
+
+
@@ -21,24 +23,37 @@
+
+
+ {
+ "selectedUrlAndAccountId": {
+ "url": "git@github.com:2OOP/pism_ttt.git",
+ "accountId": "7694f583-f911-4763-8185-8ea3ed608804"
}
-}]]>
-
-
+}
+ {
+ "customColor": "",
+ "associatedIndex": 1
+}
@@ -51,7 +66,7 @@
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager": "true",
"RunOnceActivity.git.unshallow": "true",
- "git-widget-placeholder": "ServerManager",
+ "git-widget-placeholder": "Ticho",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
diff --git a/src/main/java/org/toop/Main.java b/src/main/java/org/toop/Main.java
index 9e23bda..8d784fe 100644
--- a/src/main/java/org/toop/Main.java
+++ b/src/main/java/org/toop/Main.java
@@ -1,8 +1,7 @@
package org.toop;
-import org.toop.core.*;
+import org.toop.UI.GameSelectorWindow;
import org.toop.eventbus.*;
-import org.toop.graphics.*;
import org.toop.server.backend.ServerManager;
import org.toop.server.frontend.ConnectionManager;
@@ -12,39 +11,40 @@ import org.apache.logging.log4j.LogManager;
import java.util.concurrent.ExecutionException;
public class Main {
+
+ private static final Logger logger = LogManager.getLogger(Main.class);
private static boolean running = false;
public static void main(String[] args) throws ExecutionException, InterruptedException {
+ initSystems();
registerEvents();
- Window window = Window.setup(Window.API.GLFW, "Test", new Window.Size(1280, 720));
- Renderer renderer = Renderer.setup(Renderer.API.OPENGL);
- initSystems();
- Logging.disableLogs();
+// Window window = Window.setup(Window.API.GLFW, "Test", new Window.Size(1280, 720));
+// Renderer renderer = Renderer.setup(Renderer.API.OPENGL);
+// initSystems();
+// Logging.disableLogs();
+//
+// Shader shader = Shader.create(
+// "src/main/resources/shaders/gui_vertex.glsl",
+// "src/main/resources/shaders/gui_fragment.glsl");
+//
+// running = window != null && renderer != null && shader != null;
+// ConsoleGui console = new ConsoleGui();
+//
+// while (running) {
+// window.update();
+// renderer.clear();
+//
+// shader.start();
+// renderer.render();
+// }
+// console.print();
+//
+// if (shader != null) shader.cleanup();
+// if (renderer != null) renderer.cleanup();
+// if (window != null) window.cleanup();
- Shader shader = Shader.create(
- "src/main/resources/shaders/gui_vertex.glsl",
- "src/main/resources/shaders/gui_fragment.glsl");
-
- running = window != null && renderer != null && shader != null;
- ConsoleGui console = new ConsoleGui();
-
- while (running) {
- window.update();
- renderer.clear();
-
- shader.start();
- renderer.render();
- }
- console.print();
- }
-
- if (shader != null) shader.cleanup();
- if (renderer != null) renderer.cleanup();
- if (window != null) window.cleanup();
-
- */
- //JFrameWindow window = new JFrameWindow();
+// JFrameWindow window = new JFrameWindow();
GameSelectorWindow gameSelectorWindow = new GameSelectorWindow();
}
@@ -74,3 +74,4 @@ public class Main {
Main.running = running;
}
}
+
diff --git a/src/main/java/org/toop/eventbus/Events.java b/src/main/java/org/toop/eventbus/Events.java
index 5e3d70b..0809ed8 100644
--- a/src/main/java/org/toop/eventbus/Events.java
+++ b/src/main/java/org/toop/eventbus/Events.java
@@ -2,11 +2,11 @@ package org.toop.eventbus;
import org.toop.server.backend.tictactoe.TicTacToeServer;
import org.toop.server.backend.tictactoe.TicTacToeServerCommand;
-import org.toop.server.Server;
import org.toop.core.*;
import java.lang.reflect.Constructor;
import java.util.Arrays;
+import java.util.concurrent.CompletableFuture;
/**
* Events that are used in the GlobalEventBus class.
@@ -184,7 +184,6 @@ public class Events implements IEvents {
*
* @param ip The IP address of the server to connect to.
* @param port The port of the server to connect to.
- * @param future The CompletableFuture that will complete when the connection is established.
*/
public record ConnectionEstablished(Object connectionId, String ip, String port) {}
@@ -262,9 +261,6 @@ public class Events implements IEvents {
* Triggers when a cell is clicked in one of the game boards.
*/
public record CellClicked(int cell) {}
- }
-
- public static class EventBusEvents {
}
diff --git a/src/main/java/org/toop/game/TTT.java b/src/main/java/org/toop/game/TTT.java
deleted file mode 100644
index 972f4e3..0000000
--- a/src/main/java/org/toop/game/TTT.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.toop.game;
-
-public class TTT extends GameBase {
- private int moveCount;
-
- public TTT(String player1, String player2) {
- super(9);
- players = new Player[2];
- players[0] = new Player(player1, 'X');
- players[1] = new Player(player2, 'O');
-
- moveCount = 0;
- }
-
- @Override
- public boolean ValidateMove(int index) {
- if (index < 0 || index > (size * size - 1)) {
- return false;
- }
-
- return grid[index] == ' ';
- }
-
- @Override
- public State PlayMove(int index) {
- if (!ValidateMove(index)) {
- return State.INVALID;
- }
-
- grid[index] = players[currentPlayer].Move();
- moveCount += 1;
-
- if (CheckWin()) {
- return State.WIN;
- }
-
- if (moveCount >= grid.length) {
- return State.DRAW;
- }
-
- currentPlayer = (currentPlayer + 1) % players.length;
- return State.NORMAL;
- }
-
- private boolean CheckWin() {
- // Horizontal
- for (int i = 0; i < 3; i++) {
- int index = i * 3;
-
- if (grid[index] == grid[index + 1] && grid[index] == grid[index + 2]) {
- return true;
- }
- }
-
- // Vertical
- for (int i = 0; i < 3; i++) {
- int index = i;
-
- if (grid[index] == grid[index + 3] && grid[index] == grid[index + 6]) {
- return true;
- }
- }
-
- // F-Slash
- if (grid[2] == grid[4] && grid[2] == grid[6]) {
- return true;
- }
-
- // B-Slash
- if (grid[0] == grid[4] && grid[0] == grid[8]) {
- return true;
- }
-
- return false;
- }
-}