Method made static and moved to manager.
This commit is contained in:
@@ -293,4 +293,29 @@ public enum NPCManager {
|
|||||||
return nameList.get(ThreadLocalRandom.current().nextInt(nameList.size()));
|
return nameList.get(ThreadLocalRandom.current().nextInt(nameList.size()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Building> getProtectedBuildings(NPC npc) {
|
||||||
|
|
||||||
|
ArrayList<Building> protectedBuildings = new ArrayList<>();
|
||||||
|
|
||||||
|
if (npc.building == null)
|
||||||
|
return protectedBuildings;
|
||||||
|
|
||||||
|
if (npc.building.getCity() == null)
|
||||||
|
return protectedBuildings;
|
||||||
|
|
||||||
|
for (Building b : npc.building.getCity().getParent().zoneBuildingSet) {
|
||||||
|
|
||||||
|
if (b.getBlueprint() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (b.getProtectionState().equals(Enum.ProtectionState.CONTRACT))
|
||||||
|
protectedBuildings.add(b);
|
||||||
|
|
||||||
|
if (b.getProtectionState().equals(Enum.ProtectionState.PENDING))
|
||||||
|
protectedBuildings.add(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
return protectedBuildings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import engine.Enum.SupportMsgType;
|
|||||||
import engine.Enum.TaxType;
|
import engine.Enum.TaxType;
|
||||||
import engine.exception.MsgSendException;
|
import engine.exception.MsgSendException;
|
||||||
import engine.gameManager.BuildingManager;
|
import engine.gameManager.BuildingManager;
|
||||||
|
import engine.gameManager.NPCManager;
|
||||||
import engine.gameManager.SessionManager;
|
import engine.gameManager.SessionManager;
|
||||||
import engine.net.Dispatch;
|
import engine.net.Dispatch;
|
||||||
import engine.net.DispatchMessage;
|
import engine.net.DispatchMessage;
|
||||||
@@ -71,7 +72,7 @@ public class AssetSupportMsgHandler extends AbstractClientMsgHandler {
|
|||||||
|
|
||||||
protectionSlots = (2 * serverCity.getRuneMaster().getRank()) + 6;
|
protectionSlots = (2 * serverCity.getRuneMaster().getRank()) + 6;
|
||||||
|
|
||||||
if (serverCity.getRuneMaster().getProtectedBuildings().size() >=
|
if (NPCManager.getProtectedBuildings(serverCity.getRuneMaster()).size() >=
|
||||||
protectionSlots) {
|
protectionSlots) {
|
||||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster can only protect " + protectionSlots + " structura!");
|
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster can only protect " + protectionSlots + " structura!");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ package engine.net.client.msg;
|
|||||||
import engine.Enum.GameObjectType;
|
import engine.Enum.GameObjectType;
|
||||||
import engine.Enum.MinionType;
|
import engine.Enum.MinionType;
|
||||||
import engine.Enum.ProtectionState;
|
import engine.Enum.ProtectionState;
|
||||||
|
import engine.gameManager.NPCManager;
|
||||||
import engine.gameManager.PowersManager;
|
import engine.gameManager.PowersManager;
|
||||||
import engine.net.AbstractConnection;
|
import engine.net.AbstractConnection;
|
||||||
import engine.net.ByteBufferReader;
|
import engine.net.ByteBufferReader;
|
||||||
@@ -440,7 +441,7 @@ public class ManageNPCMsg extends ClientNetMsg {
|
|||||||
|
|
||||||
//TODO add runemaster list here
|
//TODO add runemaster list here
|
||||||
|
|
||||||
ArrayList<Building> buildingList = npc.getProtectedBuildings();
|
ArrayList<Building> buildingList = NPCManager.getProtectedBuildings(npc);
|
||||||
|
|
||||||
writer.putInt(buildingList.size());
|
writer.putInt(buildingList.size());
|
||||||
|
|
||||||
|
|||||||
@@ -1271,31 +1271,6 @@ public class NPC extends AbstractCharacter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Building> getProtectedBuildings() {
|
|
||||||
|
|
||||||
ArrayList<Building> protectedBuildings = new ArrayList<>();
|
|
||||||
|
|
||||||
if (this.building == null)
|
|
||||||
return protectedBuildings;
|
|
||||||
|
|
||||||
if (this.building.getCity() == null)
|
|
||||||
return protectedBuildings;
|
|
||||||
|
|
||||||
for (Building b : this.building.getCity().getParent().zoneBuildingSet) {
|
|
||||||
|
|
||||||
if (b.getBlueprint() == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (b.getProtectionState().equals(ProtectionState.CONTRACT))
|
|
||||||
protectedBuildings.add(b);
|
|
||||||
|
|
||||||
if (b.getProtectionState().equals(ProtectionState.PENDING))
|
|
||||||
protectedBuildings.add(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
return protectedBuildings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Guild getGuild() {
|
public Guild getGuild() {
|
||||||
if (this.building != null)
|
if (this.building != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user