diff --git a/Projektgruppe_175/src/game/goals/PopulationGoal.java b/Projektgruppe_175/src/game/goals/PopulationGoal.java index a0f428a..721032d 100644 --- a/Projektgruppe_175/src/game/goals/PopulationGoal.java +++ b/Projektgruppe_175/src/game/goals/PopulationGoal.java @@ -20,16 +20,21 @@ public class PopulationGoal extends Goal { private int populationNeeded = 10; private int castlesNeeded = 5; + boolean isDraw; + /** * Creates a new population goal */ public PopulationGoal() { super("Bevölkerung", "Derjenige Spieler gewinnt, der als erstes jeweils 10 Truppen auf 5 Burgen bringt"); + isDraw = false; } @Override public boolean isCompleted() { - return this.getWinner() != null; + // Call getWinner to set isDraw + getWinner(); + return isDraw || this.getWinner() != null; } @Override @@ -74,7 +79,17 @@ public class PopulationGoal extends Goal { } }; - return Collections.max(highPopulationPlayers, comp); + + Collections.sort(playerList, comp); + // Edge Case: Mind. Zwei spieler haben die gleiche Anzahl an Burgen + if(playerList.get(0).getNumRegions(game) == playerList.get(1).getNumRegions(game)) { + isDraw = true; + return null; + } + + + return Collections.max(playerList, comp); + } // Ansonsten... gewinnt noch kein spieler.