From e16aa6824aa4c7d1ba0850b8858187581650122d Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sun, 15 May 2016 13:11:18 +0200 Subject: [PATCH] GenerateZPM fixed, now it doesn't reach infinite purrs. --- cicaprojekt/Game.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cicaprojekt/Game.java b/cicaprojekt/Game.java index 8e8004d..8edded1 100644 --- a/cicaprojekt/Game.java +++ b/cicaprojekt/Game.java @@ -219,17 +219,30 @@ public class Game { if(((jaffa.getZPMCount() + oneill.getZPMCount()) % 2) == 0) { Tile source = oneill.getCurrentTile(); Tile compare; - for (int i = 0; i < dungeon.getMapHeight() * dungeon.getMapWidth(); i++) { + + + for (int i = 0; i < dungeon.getMapHeight(); i++) { compare = source.getAdjacentTile(Direction.getRandom()); if (compare != null) source = compare; } while (!source.canHazZPM()) { - compare = source.getAdjacentTile(Direction.getRandom()); - if (compare != null) - if(!compare.hasZPM() && (compare.playerBaseOnTile == null)) + int j = 0; + + for (int i = 0; i < dungeon.getMapHeight(); i++) { + compare = source.getAdjacentTile(Direction.getRandom()); + if (compare != null) source = compare; + } + + while(j != 20) { + compare = source.getAdjacentTile(Direction.getRandom()); + if (compare != null) + if (!compare.hasZPM() && (compare.playerBaseOnTile == null)) + source = compare; + j++; + } } source.setZPMOnTile(new ZPM());