diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 8edded1..7230f7b 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -228,7 +228,7 @@ public class Game { } while (!source.canHazZPM()) { - int j = 0; + int newSourceCounter = 0; for (int i = 0; i < dungeon.getMapHeight(); i++) { compare = source.getAdjacentTile(Direction.getRandom()); @@ -236,12 +236,17 @@ public class Game { source = compare; } - while(j != 20) { + while(newSourceCounter != 20) { compare = source.getAdjacentTile(Direction.getRandom()); - if (compare != null) - if (!compare.hasZPM() && (compare.playerBaseOnTile == null)) - source = compare; - j++; + if (compare != null) { + source = compare; + if (!compare.hasZPM() && (compare.playerBaseOnTile == null)) { + if (source.canHazZPM()) { + break; + } + } + } + newSourceCounter++; } }