From 4d1f90bf16bdadc3901f272d30a66aed2184798e Mon Sep 17 00:00:00 2001 From: Antonin Boyon Date: Wed, 27 Jan 2021 13:00:52 +0100 Subject: [PATCH] methode play, copie, switchPlayer --- src/othello/State.java | 49 ++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/othello/State.java b/src/othello/State.java index 28259ee..7dcca67 100644 --- a/src/othello/State.java +++ b/src/othello/State.java @@ -1,14 +1,15 @@ package othello; +import java.util.ArrayList; + public class State { - private int[][] plateau; - private String[][] board; - private String player1; - private String player2; - private String currentPlayer; + private int[][] board; + private int player1; + private int player2; + private int currentPlayer; - public State(String[][] board, String p1, String p2) { + public State(int[][] board, int p1, int p2) { this.board = board; this.player1 = p1; this.player2 = p2; @@ -19,20 +20,46 @@ public class State { return false; } - public void getMove(String player) { - + public ArrayList getMove(String player) { + return null; } public int getScore(String player) { return 0; } - public void play(int move) { - + public State play(int x, int y) { + State copie = this.copie(); + copie.board[x][y] = copie.getCurrentPlayer(); + copie.switchPlayer(); + return copie; } - public String getCurrentPlayer() { + public int getCurrentPlayer() { return currentPlayer; } + public void setCurrentPlayer(int currentPlayer) { + this.currentPlayer = currentPlayer; + } + + public State copie () { + State copie = new State (this.board, this.player1, this.player2); + for (int i=0; i