clean board now reset turnNb, advancements on usertouch, the turn
counter now works sometimes, the pieces dont move, idk
This commit is contained in:
parent
651ef9ef43
commit
b821a42571
|
|
@ -13,6 +13,7 @@ public class Main {
|
|||
Board testBoard = new Board(8, 8);
|
||||
testBoard.populateBoard();
|
||||
System.out.println(testBoard.toString());
|
||||
System.out.println(testBoard.setSelectXY(1,2));
|
||||
|
||||
// launches graphical interface :
|
||||
MyInterface mjf = new MyInterface();
|
||||
|
|
|
|||
|
|
@ -82,6 +82,8 @@ public class Board {
|
|||
public void cleanBoard() {
|
||||
//removes all pieces from arraylist pieces
|
||||
pieces.clear();
|
||||
//reset turn nb to 0 as cleanboard is triggered when the restart button is pressed
|
||||
turnNb = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -118,15 +120,18 @@ public class Board {
|
|||
}
|
||||
|
||||
public void userTouch(int x, int y) {
|
||||
if(setSelectXY(x,y) == true) {
|
||||
selectX = x;
|
||||
selectY = y;
|
||||
//needs more work, testing atm
|
||||
if(selectX == x && selectY == y) {
|
||||
movePiece(selectX, selectY, x, y);
|
||||
if(selectX == x && selectY == y) {
|
||||
movePiece(selectX, selectY, x, y);
|
||||
|
||||
// Increment turn number and change turn color
|
||||
turnNb++;
|
||||
selectX = -1;
|
||||
selectY = -1;
|
||||
|
||||
turnNb++;
|
||||
selectX = -1;
|
||||
selectY = -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -141,6 +146,15 @@ public class Board {
|
|||
}
|
||||
}
|
||||
}
|
||||
public boolean setSelectXY(int x, int y) {
|
||||
boolean isPieceHere = false;
|
||||
for (Piece piece : pieces) { // iterate trough all pieces
|
||||
if (piece.getX() == x && piece.getY() == x) {
|
||||
isPieceHere = !isPieceHere;
|
||||
}
|
||||
}
|
||||
return isPieceHere;
|
||||
}
|
||||
|
||||
public boolean isSelected(int x, int y) {
|
||||
//returns true for the selected "SelectX" and "SelectY" variables at the coordinates of the board selected
|
||||
|
|
|
|||
Loading…
Reference in New Issue