Updated 'Game' class.
Updated the 'Game' class by adding the 'getPlayerIdByColor' method to it.
This commit is contained in:
@@ -152,6 +152,22 @@ public Player getPlayerByColor(Color color) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be used to return the id of the Player defined by the given color parameter.
|
||||||
|
*
|
||||||
|
* @param color as the color of the player as a Color enumeration.
|
||||||
|
* @return the id of the player as an Integer.
|
||||||
|
*/
|
||||||
|
public int getPlayerIdByColor(Color color) {
|
||||||
|
for (Map.Entry<Integer, Player> entry : this.players.entrySet()) {
|
||||||
|
if (entry.getValue().getColor() == color) {
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be used to return the number of active players of this game.
|
* This method will be used to return the number of active players of this game.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user