From 7dcefdf5d7cba5474b98bf12f759daae52009b62 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 2 May 2023 15:09:09 -0400 Subject: [PATCH] Contract moved to AbstractCharacter. Arty tower restricted to a single tower captain. --- src/engine/gameManager/BuildingManager.java | 2 +- .../net/client/handlers/ActivateNPCMsgHandler.java | 3 +++ src/engine/objects/AbstractCharacter.java | 5 +++-- src/engine/objects/Contract.java | 10 ++++++++-- src/engine/objects/Mob.java | 1 - src/engine/objects/NPC.java | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 183855a2..92deb31e 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -51,7 +51,7 @@ public enum BuildingManager { for (int i = 1; i <= numOfSlots; i++) { - // Slot two is reserved on Arty towers for the trebuchet + // Slot one is reserved on Arty towers for the trebuchet if (i == 1 && building.getBlueprint() != null && diff --git a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java index f1e2532a..7aaa4d87 100644 --- a/src/engine/net/client/handlers/ActivateNPCMsgHandler.java +++ b/src/engine/net/client/handlers/ActivateNPCMsgHandler.java @@ -49,9 +49,12 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler { for (Item hirelings : player.getInventory()) { if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) { + contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID()); + if (contract == null) continue; + if (contract.canSlotinBuilding(building)) ItemLists.add(hirelings); } diff --git a/src/engine/objects/AbstractCharacter.java b/src/engine/objects/AbstractCharacter.java index 372c8c6d..6535ebe4 100644 --- a/src/engine/objects/AbstractCharacter.java +++ b/src/engine/objects/AbstractCharacter.java @@ -117,9 +117,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject { private long lastHateUpdate = 0; private boolean collided = false; protected Regions lastRegion = null; - + protected boolean movingUp = false; - + public Contract contract; + /** * No Id Constructor diff --git a/src/engine/objects/Contract.java b/src/engine/objects/Contract.java index b4ed0fb9..b85a756d 100644 --- a/src/engine/objects/Contract.java +++ b/src/engine/objects/Contract.java @@ -254,10 +254,16 @@ public class Contract extends AbstractGameObject { if (this.allowedBuildings.size() == 0) return false; + // Restrict arty towers to a single captain + + if (this.getContractID() == 842) // Tower Arty Captain + for (AbstractCharacter hireling : building.getHirelings().keySet()) + if (hireling.contract.getContractID() == 842) + return false; + // Binary match return (building.getBlueprint().getBuildingGroup().elementOf(this.allowedBuildings)); - - } + } public int getEquipmentSet() { return equipmentSet; diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index d7fb700e..82ffc22e 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -65,7 +65,6 @@ public class Mob extends AbstractIntelligenceAgent { public int spawnTime; public Zone parentZone; public Building building; - public Contract contract; public boolean hasLoot = false; public boolean isPlayerGuard = false; public AbstractCharacter npcOwner; diff --git a/src/engine/objects/NPC.java b/src/engine/objects/NPC.java index c0b5169d..760df693 100644 --- a/src/engine/objects/NPC.java +++ b/src/engine/objects/NPC.java @@ -52,7 +52,7 @@ public class NPC extends AbstractCharacter { protected MobBase mobBase; protected String name; public Building building; - protected Contract contract; + protected int dbID; protected int currentID; private DateTime upgradeDateTime = null;