Browse Source

Update to list based lookup

bugfix-slot-update-2
MagicBot 9 months ago
parent
commit
dce3822d43
  1. 21
      src/engine/gameManager/BuildingManager.java

21
src/engine/gameManager/BuildingManager.java

@ -56,15 +56,11 @@ public enum BuildingManager { @@ -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 { @@ -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) {

Loading…
Cancel
Save