currentPlayer

This commit is contained in:
lieght
2025-09-19 17:41:06 +02:00
parent ba16f2e135
commit 2d84dbfd72
2 changed files with 5 additions and 2 deletions

View File

@@ -51,9 +51,10 @@ public class UIGameBoard {
final int index = i; final int index = i;
cells[i].addActionListener((ActionEvent e) -> { cells[i].addActionListener((ActionEvent e) -> {
int cp = this.localTicTacToe.getCurrentPlayersTurn();
if (cp == 1) { this.currentPlayer = "X"; }
else if (cp == 2) { this.currentPlayer = "O"; }
cells[index].setText(currentPlayer); cells[index].setText(currentPlayer);
if (Objects.equals(currentPlayer, "X")) { currentPlayer = "O"; }
else { currentPlayer = "X"; }
this.localTicTacToe.move(index); this.localTicTacToe.move(index);
System.out.println("Cell clicked: " + index); System.out.println("Cell clicked: " + index);
}); });

View File

@@ -23,6 +23,8 @@ public class LocalTicTacToe { // TODO: Implement runnable
* Is either 1 or 2. * Is either 1 or 2.
*/ */
private int playersTurn = 1; private int playersTurn = 1;
public int getCurrentPlayersTurn() { return this.playersTurn; }
// LocalTicTacToe(String gameId, String connectionId, String serverId) { // LocalTicTacToe(String gameId, String connectionId, String serverId) {
// this.gameId = gameId; // this.gameId = gameId;