added a method for getting a piece through a uuid

This commit is contained in:
Fleischer Hanno
2024-12-01 15:05:26 +01:00
parent dfea7e8736
commit 1d5733a4b9

View File

@@ -144,6 +144,22 @@ public Piece getPieceThroughIdentifier(String identifier){
return board.getPlayerData().get(Color.valueOf(parts[0])).getPieces()[Integer.parseInt(parts[1])];
}
/**
* This method will be used to return a piece based on the UUID.
*
* @return the piece specified by the UUID
*/
public Piece getPieceThroughUUID(UUID pieceId){
for (var playerData : board.getPlayerData().values()) {
for (var piece : playerData.getPieces()) {
if (piece.getUuid().equals(pieceId)) {
return piece;
}
}
}
return null;
}
/**
* This method notifies the observers.
*/