item_wt refactored to template

This commit is contained in:
2024-03-03 15:06:44 -05:00
parent 58652ee32f
commit 4dc0f52295
12 changed files with 101 additions and 120 deletions
+17 -26
View File
@@ -30,33 +30,36 @@ import java.util.concurrent.ThreadLocalRandom;
public class ItemFactory {
public static void fillInventory(PlayerCharacter pc, int objectID, int count) {
public static void fillInventory(PlayerCharacter pc, int templateID, int count) {
if (pc == null)
return;
int max = 20;
CharacterItemManager itemManager = pc.getCharItemManager();
ItemBase ib = ItemBase.getItemBase(objectID);
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID);
if (count > max)
count = max;
ClientConnection cc = pc.getClientConnection();
if (itemManager == null || ib == null || cc == null)
if (itemManager == null || template == null || cc == null)
return;
boolean worked;
for (int i = 0; i < count; i++) {
worked = false;
if (!itemManager.hasRoomInventory(ib.getWeight())) {
if (!itemManager.hasRoomInventory(template.item_wt)) {
if (pc != null)
ChatManager.chatSystemInfo(pc, "You can not carry any more of that item.");
break;
}
Item item = new Item(ib.getUUID());
Item item = new Item(templateID);
item.ownerID = pc.getObjectUUID();
item.ownerType = OwnerType.PlayerCharacter;
item.containerType = ItemContainerType.INVENTORY;
@@ -74,7 +77,7 @@ public class ItemFactory {
itemManager.updateInventory();
}
public static Item fillForge(NPC npc, PlayerCharacter pc, int itemsToRoll, int itemID, int pToken, int sToken, String customName) {
public static Item fillForge(NPC npc, PlayerCharacter pc, int itemsToRoll, int templateID, int pToken, int sToken, String customName) {
String prefixString = "";
String suffixString = "";
@@ -83,10 +86,10 @@ public class ItemFactory {
boolean useWarehouse = false;
ItemBase ib = ItemBase.getItemBase(itemID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
ItemBase ib = ItemBase.getItemBase(templateID);
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID);
if (ib == null)
if (template == null)
return null;
Building forge = npc.getBuilding();
@@ -94,8 +97,7 @@ public class ItemFactory {
if (forge == null)
return null;
if (!npc.getCharItemManager().hasRoomInventory(ib.getWeight())) {
if (!npc.getCharItemManager().hasRoomInventory(template.item_wt)) {
if (pc != null)
ErrorPopupMsg.sendErrorPopup(pc, 21);
return null;
@@ -120,12 +122,13 @@ public class ItemFactory {
useWarehouse = true;
// ROLL BANE SCROLL.
if (ib.getUUID() > 910010 && ib.getUUID() < 910019) {
if (templateID > 910010 && templateID < 910019) {
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value);
int overdraft = BuildingManager.GetOverdraft(forge, template.item_value);
if (overdraft > 0 && !useWarehouse) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough gold in building strongbox." + " " + template.item_base_name);
@@ -144,15 +147,6 @@ public class ItemFactory {
return null;
}
//All checks passed, lets withdraw from building first.
// if (pc != null){
// ChatManager.chatGuildInfo(pc.getGuild(), "Building withdraw = " + buildingWithdraw);
// ChatManager.chatGuildInfo(pc.getGuild(), "Warehouse overdraft withdraw = " + overdraft);
//
// ChatManager.chatGuildInfo(pc.getGuild(), "total withdraw = " + (overdraft + buildingWithdraw));
// }
if (!forge.transferGold(-buildingWithdraw, false)) {
overdraft += buildingWithdraw;
@@ -169,15 +163,12 @@ public class ItemFactory {
if (overdraft > 0)
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
return null;
}
ml = new MobLoot(npc, ib, false);
ml.containerType = Enum.ItemContainerType.FORGE;
ml.setValue(0);
ml.loadEnchantments();
@@ -660,10 +651,10 @@ public class ItemFactory {
ItemBase ib = ItemBase.getItemBase(itemBaseID);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID);
if (ib == null)
if (template == null)
return null;
if (!vendor.getCharItemManager().hasRoomInventory(ib.getWeight())) {
if (!vendor.getCharItemManager().hasRoomInventory(template.item_wt)) {
if (playerCharacter != null)
ChatManager.chatSystemInfo(playerCharacter, vendor.getName() + " " + vendor.getContract().getName() + " Inventory is full.");