Merge branch 'master' of https://gitlab.isima.fr/audorival/gomoku
This commit is contained in:
@@ -1,15 +1,32 @@
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GomokuBoard {
|
||||
private GomokuCell firstCell;
|
||||
private int boardWith;
|
||||
private int bordHeight;
|
||||
|
||||
public GomokuBoard(int width, int height){
|
||||
//------------------Constructors--------------------------
|
||||
|
||||
/**
|
||||
* This constructor take the width and the height to creat a board of gomoku.
|
||||
* @param width Size of width.
|
||||
* @param height Size of height.
|
||||
*/
|
||||
public GomokuBoard(int width, int height){
|
||||
this.firstCell = new GomokuCell(Color.NIL);
|
||||
this.boardWith = width;
|
||||
this.bordHeight = height;
|
||||
}
|
||||
|
||||
//------------------Gets--------------------------
|
||||
|
||||
/**
|
||||
* This method get a cell in specific position in the board.
|
||||
* @param x The position x on the board.
|
||||
* @param y The position y on the board.
|
||||
* @return GomokuCell in the position.
|
||||
*/
|
||||
public GomokuCell get(int x, int y){
|
||||
int i = 0, j = 0;
|
||||
GomokuCell act = this.firstCell;
|
||||
@@ -24,4 +41,25 @@ public class GomokuBoard {
|
||||
return act;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a list of playable cell.
|
||||
* @return List of GomokuCell wich all is playable.
|
||||
*/
|
||||
|
||||
public List<GomokuCell> getPlayableCells(){
|
||||
List<GomokuCell> output = new ArrayList<>();
|
||||
GomokuCell act = null;
|
||||
for (int i = 0; i < this.boardWith; i++) {
|
||||
for (int j = 0; j < this.bordHeight; j++) {
|
||||
act = this.get(i,j);
|
||||
if (act.isPlayable()){
|
||||
output.add(act);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user