From 5dc3124533994136713e73fa1da423dce8cef50f Mon Sep 17 00:00:00 2001 From: Felix Koppe Date: Sun, 8 Dec 2024 19:40:10 +0100 Subject: [PATCH] Fix colorNext --- .../mdga/model/src/main/java/pp/mdga/game/Color.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java b/Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java index 1708ac52..a3a606bf 100644 --- a/Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java +++ b/Projekte/mdga/model/src/main/java/pp/mdga/game/Color.java @@ -60,9 +60,16 @@ public Color next(Game game) { colorsInGame.add(p.getColor()); } - int nextIndex = (this.ordinal() + 1) % colorsInGame.size(); + int current = -1; + for(int i = 0; i < colorsInGame.size(); i++) { + Color c = colorsInGame.get(i); - return colorsInGame.get(nextIndex); + if(c.equals(game.getActiveColor())) { + current = i; + } + } + + return colorsInGame.get((current + 1) % colorsInGame.size()); } /**