This commit is contained in:
ramollia
2025-10-02 19:59:14 +02:00
parent 6626157052
commit 3c699cde01
14 changed files with 284 additions and 199 deletions

View File

@@ -4,7 +4,7 @@ import java.util.Arrays;
public abstract class Game {
public enum State {
NORMAL, LOSE, DRAW, WIN,
NORMAL, DRAW, LOSE, WIN,
}
public record Move(int position, char value) {}

View File

@@ -1,3 +1,3 @@
package org.toop.game;
public record Player(String name, char... values) {}
public record Player(String name, boolean isAI, char... values) {}

View File

@@ -8,8 +8,8 @@ import java.util.ArrayList;
public final class TicTacToe extends Game {
private int movesLeft;
public TicTacToe(String player1, String player2) {
super(3, 3, new Player(player1, 'X'), new Player(player2, 'O'));
public TicTacToe(String player1, boolean isPlayer1AI, String player2, boolean isPlayer2AI) {
super(3, 3, new Player(player1, isPlayer1AI, 'X'), new Player(player2, isPlayer2AI, 'O'));
movesLeft = board.length;
}
@@ -51,6 +51,7 @@ public final class TicTacToe extends Game {
return State.DRAW;
}
}
return State.NORMAL;
}