mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
currentPlayer
This commit is contained in:
@@ -51,9 +51,10 @@ public class UIGameBoard {
|
||||
|
||||
final int index = i;
|
||||
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);
|
||||
if (Objects.equals(currentPlayer, "X")) { currentPlayer = "O"; }
|
||||
else { currentPlayer = "X"; }
|
||||
this.localTicTacToe.move(index);
|
||||
System.out.println("Cell clicked: " + index);
|
||||
});
|
||||
|
||||
@@ -23,6 +23,8 @@ public class LocalTicTacToe { // TODO: Implement runnable
|
||||
* Is either 1 or 2.
|
||||
*/
|
||||
private int playersTurn = 1;
|
||||
public int getCurrentPlayersTurn() { return this.playersTurn; }
|
||||
|
||||
|
||||
// LocalTicTacToe(String gameId, String connectionId, String serverId) {
|
||||
// this.gameId = gameId;
|
||||
|
||||
Reference in New Issue
Block a user