diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index f1c5bb83..eea9540b 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -56,15 +56,11 @@ public enum BuildingManager { if (building.hirelings.isEmpty()) return 0; - for (int i = 0; i < numOfSlots; i++) { + if (building.hirelings.size() == numOfSlots) + return -1; - if (i > building.hirelings.size()) - return i; + return building.hirelings.size() + 1; - if (building.hirelings.get(i) == null) - return i; - } - return -1; } public static int getLastAvailableSlot(Building building) { @@ -82,15 +78,10 @@ public enum BuildingManager { if (building.hirelings.isEmpty()) return numOfSlots - 1; - for (int i = numOfSlots - 1; i >= 0; i--) { - - if (i > building.hirelings.size()) - return i; + if (building.hirelings.size() == numOfSlots) + return -1; - if (building.hirelings.get(i) == null) - return i; - } - return -1; + return numOfSlots - 1; } public static BuildingLocation getSlotLocation(Building building, int slot) {