From 0513cc978e7b91a14e7d8f96fa91c032270707e9 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 24 Apr 2023 16:17:55 -0400 Subject: [PATCH] Helper method for slot lookup added. --- src/engine/gameManager/BuildingManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 4712e742..9f60acbf 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -27,6 +27,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ThreadLocalRandom; public enum BuildingManager { @@ -36,6 +37,17 @@ public enum BuildingManager { public static HashMap> _stuckLocations; public static HashMap> _slotLocations; + public static int getAvailableSlot(Building building) { + + int numOfSlots = _slotLocations.get(building.meshUUID).size(); + + for (int i = 1; i < numOfSlots; i++) { + if (!building.getHirelings().containsValue(i)) + return i; + } + return -1; + } + public static boolean playerCanManage(PlayerCharacter player, Building building) { if (player == null)