diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java index 4c27d8f2..9d7d83d5 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Game.java @@ -48,9 +48,6 @@ public class Game { // The color of the active player. private Color activeColor; - // A flag indicating whether all players are ready. - private boolean allReady = false; - /** * This constructor creates a new Game object. */ @@ -114,6 +111,21 @@ public boolean isColorTaken(Color color) { return false; } + /** + * This method will be used to return the first unused color if possible. + * + * @return color as a Color enumeration. + */ + public Color getFirstUnusedColor() { + for (Color color : Color.values()) { + if (!isColorTaken(color)) { + return color; + } + } + + return null; + } + /** * This method will be used to return the player which has the given id parameter. * @@ -156,6 +168,22 @@ public int getNumberOfActivePlayers() { return activePlayers; } + /** + * This method will be used to check if all players are ready. + * If yes it will return true, otherwise false. + * + * @return true or false. + */ + public boolean areAllReady() { + for (Map.Entry entry : this.players.entrySet()) { + if (!entry.getValue().isReady()) { + return false; + } + } + + return true; + } + /** * This method will be used to return a piece based on the UUID. * @@ -351,22 +379,4 @@ public void setDie(Die die) { public void setHost(int host) { this.host = host; } - - /** - * This method returns the all ready state. - * - * @return the already state - */ - public Boolean allReady() { - return allReady; - } - - /** - * This method sets the all ready state. - * - * @param allReady the new all-ready state - */ - public void setAllReady(Boolean allReady) { - this.allReady = allReady; - } }