From 406ad713f460748c9382fa24efe26c73ff2d80dd Mon Sep 17 00:00:00 2001
From: michiel301b
Date: Wed, 3 Dec 2025 22:47:17 +0100
Subject: [PATCH 01/24] turn updates
---
.../gameControllers/ReversiController.java | 2 +-
.../gameControllers/TicTacToeController.java | 2 +-
.../org/toop/app/widget/view/GameView.java | 131 ++++++++++++++----
.../localization/localization_ar.properties | 2 +
.../localization/localization_de.properties | 1 +
.../localization/localization_en.properties | 2 +-
.../localization/localization_es.properties | 1 +
.../localization/localization_fr.properties | 1 +
.../localization/localization_hi.properties | 1 +
.../localization/localization_it.properties | 1 +
.../localization/localization_ja.properties | 1 +
.../localization/localization_ko.properties | 1 +
.../localization/localization_nl.properties | 1 +
.../localization/localization_ru.properties | 1 +
.../localization/localization_zh.properties | 1 +
15 files changed, 118 insertions(+), 31 deletions(-)
diff --git a/app/src/main/java/org/toop/app/gameControllers/ReversiController.java b/app/src/main/java/org/toop/app/gameControllers/ReversiController.java
index 3c46306..1f6842f 100644
--- a/app/src/main/java/org/toop/app/gameControllers/ReversiController.java
+++ b/app/src/main/java/org/toop/app/gameControllers/ReversiController.java
@@ -99,7 +99,7 @@ public class ReversiController extends AbstractGameController {
});
animation.play();
- primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName());
+ primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName(), 'R');
}
@Override
diff --git a/app/src/main/java/org/toop/app/gameControllers/TicTacToeController.java b/app/src/main/java/org/toop/app/gameControllers/TicTacToeController.java
index 6bd6fb0..eb8d8c9 100644
--- a/app/src/main/java/org/toop/app/gameControllers/TicTacToeController.java
+++ b/app/src/main/java/org/toop/app/gameControllers/TicTacToeController.java
@@ -39,7 +39,7 @@ public class TicTacToeController extends AbstractGameController {
public void updateUI() {
canvas.clearAll();
// TODO: wtf is even this pile of poop temp fix
- primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName());
+ primary.nextPlayer(true, getCurrentPlayer().getName(), game.getCurrentTurn() == 0 ? "X" : "O", getPlayer((game.getCurrentTurn() + 1) % 2).getName(), 'T');
drawMoves();
}
diff --git a/app/src/main/java/org/toop/app/widget/view/GameView.java b/app/src/main/java/org/toop/app/widget/view/GameView.java
index b866ef4..bf1d2f0 100644
--- a/app/src/main/java/org/toop/app/widget/view/GameView.java
+++ b/app/src/main/java/org/toop/app/widget/view/GameView.java
@@ -1,34 +1,44 @@
package org.toop.app.widget.view;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
+import javafx.scene.text.Font;
import org.toop.app.widget.Primitive;
import org.toop.app.widget.complex.ViewWidget;
import org.toop.app.widget.popup.GameOverPopup;
-
import java.util.function.Consumer;
-
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.text.Text;
-import org.toop.app.widget.tutorial.BaseTutorialWidget;
import org.toop.app.widget.tutorial.Connect4TutorialWidget;
import org.toop.app.widget.tutorial.ReversiTutorialWidget;
import org.toop.app.widget.tutorial.TicTacToeTutorialWidget;
+import org.toop.local.AppContext;
public final class GameView extends ViewWidget {
- private final Text currentPlayerHeader;
- private final Text currentMoveHeader;
- private final Text nextPlayerHeader;
+ private final Text playerHeader;
+ private final Text turnHeader;
+ private final Text player1Header;
+ private final Text player2Header;
+ private Circle player1Icon;
+ private Circle player2Icon;
private final Button forfeitButton;
private final Button exitButton;
private final Button tutorialButton;
private final TextField chatInput;
+ private final Text keyThingy;
+ private boolean hasSet = false;
public GameView(Runnable onForfeit, Runnable onExit, Consumer onMessage, String gameType) {
- currentPlayerHeader = Primitive.header("");
- currentMoveHeader = Primitive.header("");
- nextPlayerHeader = Primitive.header("");
+ playerHeader = Primitive.header("");
+ turnHeader = Primitive.header("");
+ keyThingy = Primitive.text("turnof");
+ player1Header = Primitive.header("");
+ player2Header = Primitive.header("");
+ player1Icon = new Circle();
+ player2Icon = new Circle();
if (onForfeit != null) {
forfeitButton = Primitive.button("forfeit", () -> onForfeit.run());
@@ -66,17 +76,11 @@ public final class GameView extends ViewWidget {
}
private void setupLayout() {
- var playerInfo = Primitive.vbox(
- currentPlayerHeader,
- Primitive.hbox(
- Primitive.separator(),
- currentMoveHeader,
- Primitive.separator()
- ),
- nextPlayerHeader
- );
+ var turnInfo = Primitive.vbox(
+ turnHeader
+ );
- add(Pos.TOP_RIGHT, playerInfo);
+ add(Pos.TOP_CENTER, turnInfo);
var buttons = Primitive.vbox(
forfeitButton,
@@ -94,21 +98,92 @@ public final class GameView extends ViewWidget {
}
}
- public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer) {
+ public void nextPlayer(boolean isMe, String currentPlayer, String currentMove, String nextPlayer, char GameType) {
Platform.runLater(() -> {
- currentPlayerHeader.setText(currentPlayer);
- currentMoveHeader.setText(currentMove);
- nextPlayerHeader.setText(nextPlayer);
+ if (!(hasSet)) {
+ playerHeader.setText(currentPlayer + " vs. " + nextPlayer);
+ hasSet = true;
+ setPlayerHeaders(isMe, currentPlayer, nextPlayer, GameType);
+ }
+ //TODO idk if theres any way to check this? only EN uses 's and the rest doesnt. if theres a better way to do this pls let me know
+ if (AppContext.getLocale().toLanguageTag().equals("en")) {
+ turnHeader.setText(currentPlayer + keyThingy.getText());
+ }
+ else {
+ turnHeader.setText(currentPlayer + " " + keyThingy.getText());
+ }
- if (isMe) {
- currentPlayerHeader.getStyleClass().add("my-turn");
- } else {
- currentPlayerHeader.getStyleClass().remove("my-turn");
- }
+ if (isMe) {
+ turnHeader.getStyleClass().add("my-turn");
+ }
+ else {
+ turnHeader.getStyleClass().remove("my-turn");
+ }
});
}
public void gameOver(boolean iWon, String winner) {
new GameOverPopup(iWon, winner).show(Pos.CENTER);
}
+
+ private void setPlayerHeaders(boolean isMe, String currentPlayer, String nextPlayer, char GameType) {
+ if (GameType == 'T') {
+ if (isMe) {
+ player1Header.setText("X: " + currentPlayer);
+ player2Header.setText("O: " + nextPlayer);
+ }
+ else {
+ player1Header.setText("X: " + nextPlayer);
+ player2Header.setText("O: " + currentPlayer);
+ }
+ setPlayerInfoTTT();
+ }
+ else if (GameType == 'R') {
+ if (isMe) {
+ player1Header.setText(currentPlayer);
+ player2Header.setText(nextPlayer);
+ }
+ else {
+ player1Header.setText(nextPlayer);
+ player2Header.setText(currentPlayer);
+ }
+ setPlayerInfoReversi();
+ }
+ }
+
+ private void setPlayerInfoTTT() {
+ var playerInfo = Primitive.vbox(
+ playerHeader,
+ Primitive.separator(),
+ player1Header,
+ player2Header
+ );
+
+ add(Pos.TOP_RIGHT, playerInfo);
+ }
+
+ private void setPlayerInfoReversi() {
+ var player1box = Primitive.hbox(
+ player1Icon,
+ player1Header
+ );
+
+ var player2box = Primitive.hbox(
+ player2Icon,
+ player2Header
+ );
+
+ var playerInfo = Primitive.vbox(
+ playerHeader,
+ Primitive.separator(),
+ player1box,
+ player2box
+ );
+
+ player1Icon.setRadius(player1Header.fontProperty().map(Font::getSize).getValue());
+ player2Icon.setRadius(player2Header.fontProperty().map(Font::getSize).getValue());
+ player1Icon.setFill(Color.BLACK);
+ player2Icon.setFill(Color.WHITE);
+ add(Pos.TOP_RIGHT, playerInfo);
+ }
}
\ No newline at end of file
diff --git a/app/src/main/resources/localization/localization_ar.properties b/app/src/main/resources/localization/localization_ar.properties
index 703994b..215ee4c 100644
--- a/app/src/main/resources/localization/localization_ar.properties
+++ b/app/src/main/resources/localization/localization_ar.properties
@@ -85,6 +85,8 @@ reversi4=\u0627\u0644\u0644\u0627\u0639\u0628 \u0627\u0644\u0630\u064a \u064a\u0
tutorialstring=\u0627\u0644\u062f\u0631\u0633 \u0627\u0644\u062a\u0648\u0636\u064a\u062d\u064a
startgame=\u0627\u0628\u062f\u0623 \u0627\u0644\u0644\u0639\u0628\u0629!
goback=\u0627\u0631\u062c\u0639
+turnof=\u062F\u0648\u0631\u0647
+
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
chinese=\u4e2d\u6587 (\u0627\u0644\u0635\u064a\u0646\u064a\u0629)
diff --git a/app/src/main/resources/localization/localization_de.properties b/app/src/main/resources/localization/localization_de.properties
index c8babb4..3a64fdc 100644
--- a/app/src/main/resources/localization/localization_de.properties
+++ b/app/src/main/resources/localization/localization_de.properties
@@ -87,6 +87,7 @@ reversi4=Der Spieler, der am Ende die meisten Steine auf dem Brett hat, gewinnt.
tutorialstring=Tutorial
startgame=Spiel starten!
goback=Zurück
+turnof=ist dran
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
chinese=\u4e2d\u6587 (Chinesisch)
diff --git a/app/src/main/resources/localization/localization_en.properties b/app/src/main/resources/localization/localization_en.properties
index 0d70ace..72c8c2d 100644
--- a/app/src/main/resources/localization/localization_en.properties
+++ b/app/src/main/resources/localization/localization_en.properties
@@ -88,7 +88,7 @@ reversi4=The player who wins at the end of the game is the one who has the most
tutorialstring=Tutorial
startgame=Start game!
goback=Go back
-
+turnof='s turn
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
chinese=\u4e2d\u6587 (Chinese)
diff --git a/app/src/main/resources/localization/localization_es.properties b/app/src/main/resources/localization/localization_es.properties
index dd4cdf7..dee7fd8 100644
--- a/app/src/main/resources/localization/localization_es.properties
+++ b/app/src/main/resources/localization/localization_es.properties
@@ -86,6 +86,7 @@ reversi4=El jugador que gane al final del juego es quien tenga m
tutorialstring=Tutorial
startgame=\u00a1Iniciar juego!
goback=Volver
+turnof=le toca
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
diff --git a/app/src/main/resources/localization/localization_fr.properties b/app/src/main/resources/localization/localization_fr.properties
index 4a06650..8653a49 100644
--- a/app/src/main/resources/localization/localization_fr.properties
+++ b/app/src/main/resources/localization/localization_fr.properties
@@ -86,6 +86,7 @@ reversi4=Le joueur qui a le plus de pions
tutorialstring=Tutoriel
startgame=D\u00e9marrer le jeu!
goback=Retour
+turnof=\u00E0 son tour
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabe)
chinese=\u4e2d\u6587 (Chinois)
diff --git a/app/src/main/resources/localization/localization_hi.properties b/app/src/main/resources/localization/localization_hi.properties
index 668378a..36d733f 100644
--- a/app/src/main/resources/localization/localization_hi.properties
+++ b/app/src/main/resources/localization/localization_hi.properties
@@ -86,6 +86,7 @@ reversi4=\u0916\u0941\u092f \u0915\u093f \u0915\u0940 \u0928\u093f\u092e\u0940 \
tutorialstring=\u0924\u0942\u091f\u0949\u0930\u093f\u092f\u0932
startgame=\u0916\u0947\u0932 \u0936\u0941\u0930\u0942 \u0915\u0930\u0947\u0902!
goback=\u0935\u093e\u092a\u0938 \u091c\u093e\u090f\u0901
+turnof=\u0915\u0940 \u092C\u093E\u0930\u0940
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0905\u0930\u092c\u0940)
chinese=\u4e2d\u6587 (\u091a\u0940\u0928\u0940)
diff --git a/app/src/main/resources/localization/localization_it.properties b/app/src/main/resources/localization/localization_it.properties
index 63b27ba..34b691e 100644
--- a/app/src/main/resources/localization/localization_it.properties
+++ b/app/src/main/resources/localization/localization_it.properties
@@ -85,6 +85,7 @@ reversi4=Il giocatore che alla fine del gioco ha pi
tutorialstring=Tutorial
startgame=Avvia il gioco!
goback=Indietro
+turnof=\u00E8 il suo turno
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabo)
chinese=\u4e2d\u6587 (Cinese)
diff --git a/app/src/main/resources/localization/localization_ja.properties b/app/src/main/resources/localization/localization_ja.properties
index d2360ea..8bd3e37 100644
--- a/app/src/main/resources/localization/localization_ja.properties
+++ b/app/src/main/resources/localization/localization_ja.properties
@@ -85,6 +85,7 @@ reversi4=\u672c\u6b21\u306b\u30dc\u30fc\u30c9\u4e0a\u3067\u6700\u591a\u306e\u8ca
tutorialstring=\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb
startgame=\u30b2\u30fc\u30e0\u3092\u958b\u59cb\uff01
goback=\u623b\u308b
+turnof=\u306E\u756A
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u30a2\u30e9\u30d3\u30a2\u8a9e)
chinese=\u4e2d\u6587 (\u4e2d\u6587)
diff --git a/app/src/main/resources/localization/localization_ko.properties b/app/src/main/resources/localization/localization_ko.properties
index 571e24a..7284b6a 100644
--- a/app/src/main/resources/localization/localization_ko.properties
+++ b/app/src/main/resources/localization/localization_ko.properties
@@ -85,6 +85,7 @@ reversi4=\uacbd\uc6b0 \uc5d0\uc11c \ucd5c\ub300 \ud648\uc744 \uac00\uc838\ub294
tutorialstring=\ud14c\ud2b8\ub9ad
startgame=\uac8c\uc784 \uc2dc\uc791!
goback=\ub4a4\ub85c \uac00\uae30
+turnof=\uC758 \uCC28\uB840
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0631\u0628\u064a\u0629)
chinese=\u4e2d\u6587 (\u4e2d\u6587)
diff --git a/app/src/main/resources/localization/localization_nl.properties b/app/src/main/resources/localization/localization_nl.properties
index a025cf4..451e8cd 100644
--- a/app/src/main/resources/localization/localization_nl.properties
+++ b/app/src/main/resources/localization/localization_nl.properties
@@ -85,6 +85,7 @@ reversi4=De speler die aan het einde van het spel de meeste stukken op het bord
tutorialstring=Tutorial
startgame=Spel starten!
goback=Ga terug
+turnof=is aan de beurt
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
chinese=\u4e2d\u6587 (Chinees)
diff --git a/app/src/main/resources/localization/localization_ru.properties b/app/src/main/resources/localization/localization_ru.properties
index 48093fd..437742f 100644
--- a/app/src/main/resources/localization/localization_ru.properties
+++ b/app/src/main/resources/localization/localization_ru.properties
@@ -85,6 +85,7 @@ reversi4=\u0418043 \u0433043 \u0440043 \u043e043 \u043a043 \u043e043 \u0442043 \
tutorialstring=\u0423\u0447\u0435\u0431\u043d\u0438\u043a
startgame=\u041d\u0430\u0447\u0430\u0442\u044c \u0438\u0433\u0440\u0443!
goback=\u041d\u0430\u0437\u0430\u0434
+turnof=\u0445\u043E\u0434\u0438\u0442
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0410\u0440\u0430\u0431\u0441\u043a\u0438\u0439)
chinese=\u4e2d\u6587 (\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439)
diff --git a/app/src/main/resources/localization/localization_zh.properties b/app/src/main/resources/localization/localization_zh.properties
index 865380d..96d97c6 100644
--- a/app/src/main/resources/localization/localization_zh.properties
+++ b/app/src/main/resources/localization/localization_zh.properties
@@ -85,6 +85,7 @@ reversi4=\u672c\u6e38\u620f\u7ed3\u675f\u65f6\u8d62\u5f97\u6ee1\u8fc7\u76d8\u976
tutorialstring=\u6559\u7a0b
startgame=\u5f00\u59cb\u6e38\u620f\uff01
goback=\u8fd4\u56de
+turnof=\u7684\u56DE\u5408
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u963f\u62c9\u4f2f\u8bed)
chinese=\u4e2d\u6587
From a00d25f24a7e1e33fe12ccc23cb700120a302af7 Mon Sep 17 00:00:00 2001
From: michiel301b
Date: Wed, 3 Dec 2025 23:16:03 +0100
Subject: [PATCH 02/24] smalle fixes aan turn updates
---
app/src/main/java/org/toop/app/Server.java | 2 --
.../java/org/toop/app/widget/view/GameView.java | 14 ++++----------
app/src/main/resources/style/dark.css | 2 +-
app/src/main/resources/style/high-contrast.css | 2 +-
app/src/main/resources/style/large.css | 5 +++++
app/src/main/resources/style/light.css | 2 +-
app/src/main/resources/style/medium.css | 5 +++++
app/src/main/resources/style/small.css | 5 +++++
8 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/app/src/main/java/org/toop/app/Server.java b/app/src/main/java/org/toop/app/Server.java
index 4b149d2..7681da0 100644
--- a/app/src/main/java/org/toop/app/Server.java
+++ b/app/src/main/java/org/toop/app/Server.java
@@ -151,8 +151,6 @@ public final class Server {
.listen(NetworkEvents.GameResultResponse.class, this::handleGameResult, false)
.listen(NetworkEvents.GameMoveResponse.class, this::handleReceivedMove, false)
.listen(NetworkEvents.YourTurnResponse.class, this::handleYourTurn, false);
- startPopulateScheduler();
- populateGameList();
}
private void sendChallenge(String opponent) {
diff --git a/app/src/main/java/org/toop/app/widget/view/GameView.java b/app/src/main/java/org/toop/app/widget/view/GameView.java
index bf1d2f0..84cdf14 100644
--- a/app/src/main/java/org/toop/app/widget/view/GameView.java
+++ b/app/src/main/java/org/toop/app/widget/view/GameView.java
@@ -108,16 +108,6 @@ public final class GameView extends ViewWidget {
//TODO idk if theres any way to check this? only EN uses 's and the rest doesnt. if theres a better way to do this pls let me know
if (AppContext.getLocale().toLanguageTag().equals("en")) {
turnHeader.setText(currentPlayer + keyThingy.getText());
- }
- else {
- turnHeader.setText(currentPlayer + " " + keyThingy.getText());
- }
-
- if (isMe) {
- turnHeader.getStyleClass().add("my-turn");
- }
- else {
- turnHeader.getStyleClass().remove("my-turn");
}
});
}
@@ -168,11 +158,15 @@ public final class GameView extends ViewWidget {
player1Header
);
+ player1box.getStyleClass().add("hboxspacing");
+
var player2box = Primitive.hbox(
player2Icon,
player2Header
);
+ player2box.getStyleClass().add("hboxspacing");
+
var playerInfo = Primitive.vbox(
playerHeader,
Primitive.separator(),
diff --git a/app/src/main/resources/style/dark.css b/app/src/main/resources/style/dark.css
index da30eb0..a9f77f4 100644
--- a/app/src/main/resources/style/dark.css
+++ b/app/src/main/resources/style/dark.css
@@ -155,7 +155,7 @@
-fx-effect: dropshadow(gaussian, #88cc8899, 5, 0, 0, 1);
}
-.my-turn {
+.text.my-turn {
-fx-fill: #e05656;
-fx-font-weight: bold;
}
diff --git a/app/src/main/resources/style/high-contrast.css b/app/src/main/resources/style/high-contrast.css
index 111449d..085f1d2 100644
--- a/app/src/main/resources/style/high-contrast.css
+++ b/app/src/main/resources/style/high-contrast.css
@@ -155,7 +155,7 @@
-fx-effect: dropshadow(gaussian, #70e070cc, 6, 0, 0, 2);
}
-.my-turn {
+.text.my-turn {
-fx-fill: #ff4b4b;
-fx-font-weight: bold;
}
diff --git a/app/src/main/resources/style/large.css b/app/src/main/resources/style/large.css
index ef89cfa..863bbb1 100644
--- a/app/src/main/resources/style/large.css
+++ b/app/src/main/resources/style/large.css
@@ -23,6 +23,11 @@
-fx-spacing: 14;
}
+.hboxspacing {
+ -fx-padding: 2;
+ -fx-spacing: 10;
+}
+
.current-player {
-fx-font-size: 32px;
}
diff --git a/app/src/main/resources/style/light.css b/app/src/main/resources/style/light.css
index 0428f04..abbaafc 100644
--- a/app/src/main/resources/style/light.css
+++ b/app/src/main/resources/style/light.css
@@ -156,7 +156,7 @@
-fx-effect: dropshadow(gaussian, #aad3aa99, 4, 0, 0, 1);
}
-.my-turn {
+.text.my-turn {
-fx-fill: #d14b4b;
-fx-font-weight: bold;
}
diff --git a/app/src/main/resources/style/medium.css b/app/src/main/resources/style/medium.css
index dfbc668..b6b1576 100644
--- a/app/src/main/resources/style/medium.css
+++ b/app/src/main/resources/style/medium.css
@@ -23,6 +23,11 @@
-fx-spacing: 10;
}
+.hboxspacing {
+ -fx-padding: 2;
+ -fx-spacing: 10;
+}
+
.current-player {
-fx-font-size: 24px;
}
diff --git a/app/src/main/resources/style/small.css b/app/src/main/resources/style/small.css
index 6b0e3cc..0fcedcc 100644
--- a/app/src/main/resources/style/small.css
+++ b/app/src/main/resources/style/small.css
@@ -23,6 +23,11 @@
-fx-spacing: 6;
}
+.hboxspacing {
+ -fx-padding: 2;
+ -fx-spacing: 10;
+}
+
.current-player {
-fx-font-size: 16px;
}
From 134c9a2fd84a5602046f8749f40595ac1bde711c Mon Sep 17 00:00:00 2001
From: michiel
Date: Thu, 4 Dec 2025 14:31:04 +0100
Subject: [PATCH 03/24] better human/ai selector with bot selection and depth
on TicTacToeAIR
---
app/src/main/java/org/toop/app/Server.java | 2 +-
.../app/widget/complex/PlayerInfoWidget.java | 96 ++++++++++++-------
.../app/widget/view/LocalMultiplayerView.java | 4 +-
.../localization/localization_ar.properties | 3 +
.../localization/localization_de.properties | 3 +
.../localization/localization_en.properties | 3 +
.../localization/localization_es.properties | 4 +-
.../localization/localization_fr.properties | 3 +
.../localization/localization_hi.properties | 3 +
.../localization/localization_it.properties | 3 +
.../localization/localization_ja.properties | 3 +
.../localization/localization_ko.properties | 3 +
.../localization/localization_nl.properties | 3 +
.../localization/localization_ru.properties | 3 +
.../localization/localization_zh.properties | 3 +
.../org/toop/game/games/reversi/ReversiR.java | 14 +--
.../game/games/tictactoe/TicTacToeAIR.java | 8 +-
.../toop/game/tictactoe/TicTacToeAIRTest.java | 2 +-
18 files changed, 113 insertions(+), 50 deletions(-)
diff --git a/app/src/main/java/org/toop/app/Server.java b/app/src/main/java/org/toop/app/Server.java
index 7681da0..74cebae 100644
--- a/app/src/main/java/org/toop/app/Server.java
+++ b/app/src/main/java/org/toop/app/Server.java
@@ -199,7 +199,7 @@ public final class Server {
switch (type){
case TICTACTOE ->{
- players[myTurn] = new ArtificialPlayer<>(new TicTacToeAIR(), user);
+ players[myTurn] = new ArtificialPlayer<>(new TicTacToeAIR(9), user);
}
case REVERSI ->{
players[myTurn] = new ArtificialPlayer<>(new ReversiAIR(), user);
diff --git a/app/src/main/java/org/toop/app/widget/complex/PlayerInfoWidget.java b/app/src/main/java/org/toop/app/widget/complex/PlayerInfoWidget.java
index 90ec2a5..c69edf4 100644
--- a/app/src/main/java/org/toop/app/widget/complex/PlayerInfoWidget.java
+++ b/app/src/main/java/org/toop/app/widget/complex/PlayerInfoWidget.java
@@ -5,10 +5,13 @@ import org.toop.app.widget.Primitive;
import javafx.scene.Node;
import javafx.scene.layout.VBox;
+import javafx.scene.text.Text;
public class PlayerInfoWidget {
private final GameInformation.Player information;
private final VBox container;
+ private Text playerName;
+ private boolean hasSet;
public PlayerInfoWidget(GameInformation.Player information) {
this.information = information;
@@ -16,6 +19,7 @@ public class PlayerInfoWidget {
buildToggle().getNode(),
buildContent()
);
+ this.playerName = null;
}
private ToggleWidget buildToggle() {
@@ -33,51 +37,69 @@ public class PlayerInfoWidget {
}
private Node buildContent() {
- if (information.isHuman) {
- var nameInput = new LabeledInputWidget(
- "name",
- "enter-your-name",
- information.name,
- newName -> information.name = newName
- );
+ if (information.isHuman) {
+ var nameInput = new LabeledInputWidget(
+ "name",
+ "enter-your-name",
+ information.name,
+ newName -> information.name = newName
+ );
- return nameInput.getNode();
- } else {
- if (information.name == null || information.name.isEmpty()) {
- information.name = "Pism Bot";
- }
+ return nameInput.getNode();
+ } else {
+ var AIBox = Primitive.vbox(
+ makeAIButton(0, 1, "zwartepiet"),
+ makeAIButton(2, 1, "sinterklaas"),
+ makeAIButton(9, 1, "santa")
+ );
- var playerName = Primitive.text("");
- playerName.setText(information.name);
+ this.playerName = Primitive.text("");
+ playerName.setText(information.name);
- var nameDisplay = Primitive.vbox(
- Primitive.text("name"),
- playerName
- );
+ var nameDisplay = Primitive.vbox(
+ Primitive.text("name"),
+ playerName
+ );
- var difficultySlider = new LabeledSliderWidget(
- "computer-difficulty",
- 0, 5,
- information.computerDifficulty,
- newVal -> information.computerDifficulty = newVal
- );
+ if (!hasSet) {
+ doDefault();
+ hasSet = true;
+ }
- var thinkTimeSlider = new LabeledSliderWidget(
- "computer-think-time",
- 0, 5,
- information.computerThinkTime,
- newVal -> information.computerThinkTime = newVal
- );
+ return Primitive.vbox(
+ AIBox,
+ nameDisplay
+ );
- return Primitive.vbox(
- nameDisplay,
- difficultySlider.getNode(),
- thinkTimeSlider.getNode()
- );
- }
- }
+ }
+ }
public Node getNode() {
return container;
}
+
+ private Node makeAIButton(int depth, int thinktime, String name) {
+ return Primitive.button(name, () -> {
+ information.name = getName(name);
+ information.computerDifficulty = depth;
+ information.computerThinkTime = thinktime;
+ this.playerName.setText(getName(name));
+ });
+ }
+
+ private String getName(String name) {
+ return switch (name) {
+ case "sinterklaas" -> "Sint. R. Klaas";
+ case "zwartepiet" -> "Zwarte Piet";
+ case "santa" -> "Santa";
+ default -> "Default";
+ };
+ }
+
+ private void doDefault() {
+ information.name = getName("zwartepiet");
+ information.computerDifficulty = 0;
+ information.computerThinkTime = 1;
+ this.playerName.setText(getName("zwartepiet"));
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java b/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java
index cbbf702..4e5cc3a 100644
--- a/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java
+++ b/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java
@@ -52,12 +52,12 @@ public class LocalMultiplayerView extends ViewWidget {
if (information.players[0].isHuman) {
players[0] = new LocalPlayer<>(information.players[0].name);
} else {
- players[0] = new ArtificialPlayer<>(new TicTacToeAIR(), information.players[0].name);
+ players[0] = new ArtificialPlayer<>(new TicTacToeAIR(information.players[0].computerDifficulty), information.players[0].name);
}
if (information.players[1].isHuman) {
players[1] = new LocalPlayer<>(information.players[1].name);
} else {
- players[1] = new ArtificialPlayer<>(new TicTacToeAIR(), information.players[1].name);
+ players[1] = new ArtificialPlayer<>(new TicTacToeAIR(information.players[1].computerDifficulty), information.players[1].name);
}
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstTTT()) {
new ShowEnableTutorialWidget(
diff --git a/app/src/main/resources/localization/localization_ar.properties b/app/src/main/resources/localization/localization_ar.properties
index 215ee4c..42c4a80 100644
--- a/app/src/main/resources/localization/localization_ar.properties
+++ b/app/src/main/resources/localization/localization_ar.properties
@@ -86,6 +86,9 @@ tutorialstring=\u0627\u0644\u062f\u0631\u0633 \u0627\u0644\u062a\u0648\u0636\u06
startgame=\u0627\u0628\u062f\u0623 \u0627\u0644\u0644\u0639\u0628\u0629!
goback=\u0627\u0631\u062c\u0639
turnof=\u062F\u0648\u0631\u0647
+zwartepiet=\u0633\u0647\u0644: Zwarte Piet
+sinterklaas=\u0645\u062a\u0648\u0633\u0637: Sint R. Klaas
+santa=\u0635\u0639\u0628: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629
diff --git a/app/src/main/resources/localization/localization_de.properties b/app/src/main/resources/localization/localization_de.properties
index 3a64fdc..20a0afa 100644
--- a/app/src/main/resources/localization/localization_de.properties
+++ b/app/src/main/resources/localization/localization_de.properties
@@ -88,6 +88,9 @@ tutorialstring=Tutorial
startgame=Spiel starten!
goback=Zurück
turnof=ist dran
+zwartepiet=Leicht: Zwarte Piet
+sinterklaas=Mittel: Sint R. Klaas
+santa=Schwer: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
chinese=\u4e2d\u6587 (Chinesisch)
diff --git a/app/src/main/resources/localization/localization_en.properties b/app/src/main/resources/localization/localization_en.properties
index 72c8c2d..2fa4442 100644
--- a/app/src/main/resources/localization/localization_en.properties
+++ b/app/src/main/resources/localization/localization_en.properties
@@ -89,6 +89,9 @@ tutorialstring=Tutorial
startgame=Start game!
goback=Go back
turnof='s turn
+zwartepiet=Easy: Zwarte Piet
+sinterklaas=Medium: Sint R. Klaas
+santa=Hard:Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabic)
chinese=\u4e2d\u6587 (Chinese)
diff --git a/app/src/main/resources/localization/localization_es.properties b/app/src/main/resources/localization/localization_es.properties
index dee7fd8..0096339 100644
--- a/app/src/main/resources/localization/localization_es.properties
+++ b/app/src/main/resources/localization/localization_es.properties
@@ -87,7 +87,9 @@ tutorialstring=Tutorial
startgame=\u00a1Iniciar juego!
goback=Volver
turnof=le toca
-
+zwartepiet=F\u00e1cil: Zwarte Piet
+sinterklaas=Medio: Sint R. Klaas
+santa=Dif\u00edcil: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Ar\u00e1bigo)
chinese=\u4e2d\u6587 (Chino)
diff --git a/app/src/main/resources/localization/localization_fr.properties b/app/src/main/resources/localization/localization_fr.properties
index 8653a49..96337b0 100644
--- a/app/src/main/resources/localization/localization_fr.properties
+++ b/app/src/main/resources/localization/localization_fr.properties
@@ -87,6 +87,9 @@ tutorialstring=Tutoriel
startgame=D\u00e9marrer le jeu!
goback=Retour
turnof=\u00E0 son tour
+zwartepiet=Facile: Zwarte Piet
+sinterklaas=Moyen : Sint R. Klaas
+santa=Difficile: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabe)
chinese=\u4e2d\u6587 (Chinois)
diff --git a/app/src/main/resources/localization/localization_hi.properties b/app/src/main/resources/localization/localization_hi.properties
index 36d733f..4a11271 100644
--- a/app/src/main/resources/localization/localization_hi.properties
+++ b/app/src/main/resources/localization/localization_hi.properties
@@ -87,6 +87,9 @@ tutorialstring=\u0924\u0942\u091f\u0949\u0930\u093f\u092f\u0932
startgame=\u0916\u0947\u0932 \u0936\u0941\u0930\u0942 \u0915\u0930\u0947\u0902!
goback=\u0935\u093e\u092a\u0938 \u091c\u093e\u090f\u0901
turnof=\u0915\u0940 \u092C\u093E\u0930\u0940
+zwartepiet=\u0905\u0938\u093e\u0928: Zwarte Piet
+sinterklaas=\u092e\u0927\u094d\u092f\u092e: Sint R. Klaas
+santa=\u0915\u0924\u093f\u0928: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0905\u0930\u092c\u0940)
chinese=\u4e2d\u6587 (\u091a\u0940\u0928\u0940)
diff --git a/app/src/main/resources/localization/localization_it.properties b/app/src/main/resources/localization/localization_it.properties
index 34b691e..d83b12f 100644
--- a/app/src/main/resources/localization/localization_it.properties
+++ b/app/src/main/resources/localization/localization_it.properties
@@ -86,6 +86,9 @@ tutorialstring=Tutorial
startgame=Avvia il gioco!
goback=Indietro
turnof=\u00E8 il suo turno
+zwartepiet=Facile: Zwarte Piet
+sinterklaas=Medio: Sint R. Klaas
+santa=Difficile: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabo)
chinese=\u4e2d\u6587 (Cinese)
diff --git a/app/src/main/resources/localization/localization_ja.properties b/app/src/main/resources/localization/localization_ja.properties
index 8bd3e37..769f939 100644
--- a/app/src/main/resources/localization/localization_ja.properties
+++ b/app/src/main/resources/localization/localization_ja.properties
@@ -86,6 +86,9 @@ tutorialstring=\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb
startgame=\u30b2\u30fc\u30e0\u3092\u958b\u59cb\uff01
goback=\u623b\u308b
turnof=\u306E\u756A
+zwartepiet=\u7c21\u5358: Zwarte Piet
+sinterklaas=\u4e2d\u7d1a: Sint R. Klaas
+santa=\u96e3\u3057\u3044: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u30a2\u30e9\u30d3\u30a2\u8a9e)
chinese=\u4e2d\u6587 (\u4e2d\u6587)
diff --git a/app/src/main/resources/localization/localization_ko.properties b/app/src/main/resources/localization/localization_ko.properties
index 7284b6a..aa1c0da 100644
--- a/app/src/main/resources/localization/localization_ko.properties
+++ b/app/src/main/resources/localization/localization_ko.properties
@@ -86,6 +86,9 @@ tutorialstring=\ud14c\ud2b8\ub9ad
startgame=\uac8c\uc784 \uc2dc\uc791!
goback=\ub4a4\ub85c \uac00\uae30
turnof=\uC758 \uCC28\uB840
+zwartepiet=\uc218\uc601: Zwarte Piet
+sinterklaas=\ubcf4\ud1b5: Sint R. Klaas
+santa=\uc5d0\uc18c: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0639\u0631\u0628\u064a\u0629)
chinese=\u4e2d\u6587 (\u4e2d\u6587)
diff --git a/app/src/main/resources/localization/localization_nl.properties b/app/src/main/resources/localization/localization_nl.properties
index 451e8cd..1be45ea 100644
--- a/app/src/main/resources/localization/localization_nl.properties
+++ b/app/src/main/resources/localization/localization_nl.properties
@@ -86,6 +86,9 @@ tutorialstring=Tutorial
startgame=Spel starten!
goback=Ga terug
turnof=is aan de beurt
+zwartepiet=Makkelijk: Zwarte Piet
+sinterklaas=Gemiddeld: Sint R. Klaas
+santa=Moeilijk: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (Arabisch)
chinese=\u4e2d\u6587 (Chinees)
diff --git a/app/src/main/resources/localization/localization_ru.properties b/app/src/main/resources/localization/localization_ru.properties
index 437742f..cc0ab81 100644
--- a/app/src/main/resources/localization/localization_ru.properties
+++ b/app/src/main/resources/localization/localization_ru.properties
@@ -86,6 +86,9 @@ tutorialstring=\u0423\u0447\u0435\u0431\u043d\u0438\u043a
startgame=\u041d\u0430\u0447\u0430\u0442\u044c \u0438\u0433\u0440\u0443!
goback=\u041d\u0430\u0437\u0430\u0434
turnof=\u0445\u043E\u0434\u0438\u0442
+zwartepiet=\u041b\u0435\u0433\u043a\u043e: Zwarte Piet
+sinterklaas=\u0421\u0440\u0435\u0434\u043d\u0438\u0439: Sint R. Klaas
+santa=\u0421\u043b\u043e\u0436\u043d\u043e: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u0410\u0440\u0430\u0431\u0441\u043a\u0438\u0439)
chinese=\u4e2d\u6587 (\u041a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u0439)
diff --git a/app/src/main/resources/localization/localization_zh.properties b/app/src/main/resources/localization/localization_zh.properties
index 96d97c6..33dce40 100644
--- a/app/src/main/resources/localization/localization_zh.properties
+++ b/app/src/main/resources/localization/localization_zh.properties
@@ -86,6 +86,9 @@ tutorialstring=\u6559\u7a0b
startgame=\u5f00\u59cb\u6e38\u620f\uff01
goback=\u8fd4\u56de
turnof=\u7684\u56DE\u5408
+zwartepiet=\u7b80\u5355: Zwarte Piet
+sinterklaas=\u4e2d\u7b49: Sint R. Klaas
+santa=\u56f0\u96be: Santa
arabic=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 (\u963f\u62c9\u4f2f\u8bed)
chinese=\u4e2d\u6587
diff --git a/game/src/main/java/org/toop/game/games/reversi/ReversiR.java b/game/src/main/java/org/toop/game/games/reversi/ReversiR.java
index 56f5e28..85d6334 100644
--- a/game/src/main/java/org/toop/game/games/reversi/ReversiR.java
+++ b/game/src/main/java/org/toop/game/games/reversi/ReversiR.java
@@ -25,10 +25,10 @@ public final class ReversiR extends AbstractGame {
// TODO: Don't hardcore for two players :)
public record Score(int player1Score, int player2Score) {}
- public ReversiR(Player[] players) {
- super(8, 8, 2, players);
+ public ReversiR(Player[] players) {
+ super(8, 8, 2, players);
addStartPieces();
- }
+ }
public ReversiR(ReversiR other) {
super(other);
@@ -53,8 +53,8 @@ public final class ReversiR extends AbstractGame {
}
}
- @Override
- public int[] getLegalMoves() {
+ @Override
+ public int[] getLegalMoves() {
final ArrayList legalMoves = new ArrayList<>();
int[][] boardGrid = makeBoardAGrid();
int currentPlayer = this.getCurrentTurn();
@@ -67,7 +67,7 @@ public final class ReversiR extends AbstractGame {
}
}
return legalMoves.stream().mapToInt(Integer::intValue).toArray();
- }
+ }
private Set getAdjacentCells(int[][] boardGrid) {
Set possibleCells = new HashSet<>();
@@ -76,7 +76,7 @@ public final class ReversiR extends AbstractGame {
for (int deltaRow = -1; deltaRow <= 1; deltaRow++){ //orthogonally and diagonally
int newX = point.x + deltaColumn, newY = point.y + deltaRow;
if (deltaColumn == 0 && deltaRow == 0 //continue if out of bounds
- || !isOnBoard(newX, newY)) {
+ || !isOnBoard(newX, newY)) {
continue;
}
if (boardGrid[newY][newX] == EMPTY) { //check if the cell is empty
diff --git a/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java b/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java
index 07271b1..faeba18 100644
--- a/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java
+++ b/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java
@@ -26,9 +26,15 @@ public final class TicTacToeAIR extends AbstractAI {
* @param game the current Tic-Tac-Toe game state
* @param depth the depth of lookahead for evaluating moves (non-negative)
* @return the index of the best move, or -1 if no moves are available
+ *
*/
+
+ private int depth;
+
+ public TicTacToeAIR(int depth) {
+ this.depth = depth;
+ }
public int getMove(TicTacToeR game) {
- int depth = 9;
assert game != null;
final int[] legalMoves = game.getLegalMoves();
diff --git a/game/src/test/java/org/toop/game/tictactoe/TicTacToeAIRTest.java b/game/src/test/java/org/toop/game/tictactoe/TicTacToeAIRTest.java
index 72277cb..7809712 100644
--- a/game/src/test/java/org/toop/game/tictactoe/TicTacToeAIRTest.java
+++ b/game/src/test/java/org/toop/game/tictactoe/TicTacToeAIRTest.java
@@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.*;
final class TicTacToeAIRTest {
- private final TicTacToeAIR ai = new TicTacToeAIR();
+ private final TicTacToeAIR ai = new TicTacToeAIR(9);
// Helper: play multiple moves in sequence on a fresh board
private TicTacToeR playSequence(int... moves) {
From 4ea458c92ee18471fe42d1af18010efd1703ee35 Mon Sep 17 00:00:00 2001
From: michiel
Date: Thu, 4 Dec 2025 15:11:41 +0100
Subject: [PATCH 04/24] depth + thinktime back to AIs, along with a a specific
TicTacToeAIRSleep
---
.../app/widget/view/LocalMultiplayerView.java | 5 ++--
.../game/games/tictactoe/TicTacToeAIR.java | 4 +--
.../games/tictactoe/TicTacToeAIRSleep.java | 25 +++++++++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)
create mode 100644 game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIRSleep.java
diff --git a/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java b/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java
index 4e5cc3a..aa9cefe 100644
--- a/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java
+++ b/app/src/main/java/org/toop/app/widget/view/LocalMultiplayerView.java
@@ -6,6 +6,7 @@ import org.toop.app.gameControllers.AbstractGameController;
import org.toop.app.gameControllers.ReversiController;
import org.toop.app.gameControllers.TicTacToeController;
import org.toop.framework.gameFramework.model.player.Player;
+import org.toop.game.games.tictactoe.TicTacToeAIRSleep;
import org.toop.game.players.ArtificialPlayer;
import org.toop.game.players.LocalPlayer;
import org.toop.app.widget.Primitive;
@@ -52,12 +53,12 @@ public class LocalMultiplayerView extends ViewWidget {
if (information.players[0].isHuman) {
players[0] = new LocalPlayer<>(information.players[0].name);
} else {
- players[0] = new ArtificialPlayer<>(new TicTacToeAIR(information.players[0].computerDifficulty), information.players[0].name);
+ players[0] = new ArtificialPlayer<>(new TicTacToeAIRSleep(information.players[0].computerDifficulty, information.players[1].computerThinkTime), information.players[0].name);
}
if (information.players[1].isHuman) {
players[1] = new LocalPlayer<>(information.players[1].name);
} else {
- players[1] = new ArtificialPlayer<>(new TicTacToeAIR(information.players[1].computerDifficulty), information.players[1].name);
+ players[1] = new ArtificialPlayer<>(new TicTacToeAIRSleep(information.players[1].computerDifficulty, information.players[1].computerThinkTime), information.players[1].name);
}
if (AppSettings.getSettings().getTutorialFlag() && AppSettings.getSettings().getFirstTTT()) {
new ShowEnableTutorialWidget(
diff --git a/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java b/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java
index faeba18..dc0a285 100644
--- a/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java
+++ b/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIR.java
@@ -13,7 +13,7 @@ import org.toop.framework.gameFramework.GameState;
* opening or when no clear best move is found.
*
*/
-public final class TicTacToeAIR extends AbstractAI {
+public class TicTacToeAIR extends AbstractAI {
/**
* Determines the best move for the given Tic-Tac-Toe game state.
@@ -26,7 +26,6 @@ public final class TicTacToeAIR extends AbstractAI {
* @param game the current Tic-Tac-Toe game state
* @param depth the depth of lookahead for evaluating moves (non-negative)
* @return the index of the best move, or -1 if no moves are available
- *
*/
private int depth;
@@ -34,6 +33,7 @@ public final class TicTacToeAIR extends AbstractAI {
public TicTacToeAIR(int depth) {
this.depth = depth;
}
+
public int getMove(TicTacToeR game) {
assert game != null;
final int[] legalMoves = game.getLegalMoves();
diff --git a/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIRSleep.java b/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIRSleep.java
new file mode 100644
index 0000000..bdd21cf
--- /dev/null
+++ b/game/src/main/java/org/toop/game/games/tictactoe/TicTacToeAIRSleep.java
@@ -0,0 +1,25 @@
+package org.toop.game.games.tictactoe;
+
+import java.util.Random;
+
+public class TicTacToeAIRSleep extends TicTacToeAIR {
+
+ private int thinkTime;
+
+ public TicTacToeAIRSleep(int depth, int thinkTime) {
+ super(depth);
+ this.thinkTime = thinkTime;
+ }
+
+ @Override
+ public int getMove(TicTacToeR game) {
+ int score = super.getMove(game);
+ try {
+ Random random = new Random();
+ Thread.sleep(this.thinkTime * 1000L + random.nextInt(1000));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return score;
+ }
+}
From 72d5989d24065ed6ed58177c74d8f80e48b7cf7d Mon Sep 17 00:00:00 2001
From: ramollia <>
Date: Thu, 4 Dec 2025 16:06:43 +0100
Subject: [PATCH 05/24] fixed overlapping back and disconnect buttons
---
app/src/main/java/org/toop/app/Server.java | 2 +-
.../main/java/org/toop/app/widget/complex/ViewWidget.java | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/src/main/java/org/toop/app/Server.java b/app/src/main/java/org/toop/app/Server.java
index 74cebae..56f4c10 100644
--- a/app/src/main/java/org/toop/app/Server.java
+++ b/app/src/main/java/org/toop/app/Server.java
@@ -123,7 +123,7 @@ public final class Server {
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(clientId, user)).postEvent();
primary = new ServerView(user, this::sendChallenge, this::disconnect);
- WidgetContainer.getCurrentView().transitionNext(primary);
+ WidgetContainer.getCurrentView().transitionNextCustom(primary);
startPopulateScheduler();
populateGameList();
diff --git a/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java b/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
index fd0dbb1..84205ba 100644
--- a/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
+++ b/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
@@ -37,6 +37,11 @@ public abstract class ViewWidget extends StackWidget {
view.add(Pos.BOTTOM_LEFT, Primitive.vbox(backButton));
}
+ public void transitionNextCustom(ViewWidget view) {
+ view.previous = this;
+ replace(Pos.CENTER, view);
+ }
+
public void transitionPrevious() {
if (previous == null) {
return;
From 75af655b49773e2115f3c67dda1d6fb4ff474aae Mon Sep 17 00:00:00 2001
From: lieght <49651652+BAFGdeJong@users.noreply.github.com>
Date: Thu, 4 Dec 2025 16:51:32 +0100
Subject: [PATCH 06/24] Changed to debug instead of info
---
app/src/main/java/org/toop/app/widget/Widget.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/app/src/main/java/org/toop/app/widget/Widget.java b/app/src/main/java/org/toop/app/widget/Widget.java
index 5f7a269..46a7331 100644
--- a/app/src/main/java/org/toop/app/widget/Widget.java
+++ b/app/src/main/java/org/toop/app/widget/Widget.java
@@ -2,19 +2,28 @@ package org.toop.app.widget;
import javafx.geometry.Pos;
import javafx.scene.Node;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.toop.framework.resource.ResourceLoader;
public interface Widget {
+ Logger logger = LogManager.getLogger(Widget.class);
+
Node getNode();
default void show(Pos position) {
+ logger.debug("Showing Widget: {} at position: {}", this.getNode(), position.toString());
WidgetContainer.add(position, this);
}
default void hide() {
+ logger.debug("Hiding Widget: {}", this.getNode());
WidgetContainer.remove(this);
}
default void replace(Pos position, Widget widget) {
+ logger.debug("Replacing Widget: {}, with widget: {}, to position: {}",
+ this.getNode(), widget.getNode(), position.toString());
widget.show(position);
hide();
}
From e2be973c9a521fdbc3ecabb08b235c3dc1af0e43 Mon Sep 17 00:00:00 2001
From: ramollia <>
Date: Thu, 4 Dec 2025 17:02:12 +0100
Subject: [PATCH 07/24] changed the transitionNextCustom to be easier to use
---
app/src/main/java/org/toop/app/Server.java | 4 ++--
.../java/org/toop/app/widget/complex/ViewWidget.java | 10 +++++++++-
.../main/java/org/toop/app/widget/view/ServerView.java | 5 +----
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/app/src/main/java/org/toop/app/Server.java b/app/src/main/java/org/toop/app/Server.java
index 56f4c10..786b7d9 100644
--- a/app/src/main/java/org/toop/app/Server.java
+++ b/app/src/main/java/org/toop/app/Server.java
@@ -122,8 +122,8 @@ public final class Server {
new EventFlow().addPostEvent(new NetworkEvents.SendLogin(clientId, user)).postEvent();
- primary = new ServerView(user, this::sendChallenge, this::disconnect);
- WidgetContainer.getCurrentView().transitionNextCustom(primary);
+ primary = new ServerView(user, this::sendChallenge);
+ WidgetContainer.getCurrentView().transitionNextCustom(primary, "disconnect", this::disconnect);
startPopulateScheduler();
populateGameList();
diff --git a/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java b/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
index 84205ba..4dc8b04 100644
--- a/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
+++ b/app/src/main/java/org/toop/app/widget/complex/ViewWidget.java
@@ -37,9 +37,17 @@ public abstract class ViewWidget extends StackWidget {
view.add(Pos.BOTTOM_LEFT, Primitive.vbox(backButton));
}
- public void transitionNextCustom(ViewWidget view) {
+ public void transitionNextCustom(ViewWidget view, String key, Runnable runnable) {
view.previous = this;
+
replace(Pos.CENTER, view);
+
+ var customButton = Primitive.button(key, () -> {
+ runnable.run();
+ view.transitionPrevious();
+ });
+
+ view.add(Pos.BOTTOM_LEFT, Primitive.vbox(customButton));
}
public void transitionPrevious() {
diff --git a/app/src/main/java/org/toop/app/widget/view/ServerView.java b/app/src/main/java/org/toop/app/widget/view/ServerView.java
index 94da1e2..7365e74 100644
--- a/app/src/main/java/org/toop/app/widget/view/ServerView.java
+++ b/app/src/main/java/org/toop/app/widget/view/ServerView.java
@@ -14,14 +14,12 @@ import javafx.scene.control.ListView;
public final class ServerView extends ViewWidget {
private final String user;
private final Consumer onPlayerClicked;
- private final Runnable onDisconnect;
private final ListView