added the method tryMove and the methods used by it into serverstate

This commit is contained in:
Hanno Fleischer
2024-11-17 17:52:25 +01:00
parent 9662e1f684
commit 90fb6e4133
4 changed files with 174 additions and 1 deletions

View File

@@ -108,4 +108,32 @@ public Piece removePieceFromWaitingArea() {
public void setPieceInHome(int index, Piece piece) {
homeNodes[index].setOccupant(piece);
}
/**
* This method returns the homeNodes
*
* @return the homeNodes
*/
public boolean homeIncludes(Piece piece) {
for (int i = 0; i < 4; i++) {
if (homeNodes[i].getOccupant() == piece) {
return true;
}
}
return false;
}
/**
* This method returns the homeNodes
*
* @return the homeNodes
*/
public int getIndexInHome(Piece piece) {
for (int i = 0; i < 4; i++) {
if (homeNodes[i].getOccupant() == piece) {
return i;
}
}
return -1;
}
}