diff --git a/Projektgruppe_175/src/game/goals/TimeGoal.java b/Projektgruppe_175/src/game/goals/TimeGoal.java index c661502..5cd2597 100644 --- a/Projektgruppe_175/src/game/goals/TimeGoal.java +++ b/Projektgruppe_175/src/game/goals/TimeGoal.java @@ -18,12 +18,13 @@ import game.map.Castle; public class TimeGoal extends Goal { int maxRounds; + boolean isDraw; /** * Creates a new time goal with the default limit */ public TimeGoal() { - this(4); + this(6); } /** @@ -33,11 +34,14 @@ public class TimeGoal extends Goal { public TimeGoal(int maxRounds) { super("Countdown", "Derjenige Spieler gewinnt, der nach " + maxRounds + " Runden die meisten Burgen besitzt."); this.maxRounds = maxRounds; + isDraw = false; } @Override public boolean isCompleted() { - return this.getWinner() != null; + // Call getWinner to set isDraw if needed + getWinner(); + return isDraw || this.getWinner() != null; } @Override @@ -75,17 +79,23 @@ public class TimeGoal extends Goal { } }; - System.out.println(Collections.max(playerList, comp).getNumRegions(game)); - System.out.println(Collections.max(playerList, comp).getName()); + Collections.sort(playerList, comp); + // Edge Case: Mehrere Spieler haben auch die gleiche Anzahl an Regionen. Dann gibt es ein Draw. + // 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); } @Override public boolean hasLost(Player player) { - if(getGame().getRound() < maxRounds) + if(getGame().getRound() < 2) return false; - return !player.equals(getWinner()); + return player.getNumRegions(getGame()) == 0 || (this.isCompleted() && !player.equals(this.getWinner())); } }