Refactor item_type

This commit is contained in:
2024-03-10 13:34:24 -04:00
parent 87290baa52
commit df5c607375
24 changed files with 137 additions and 203 deletions
+21 -22
View File
@@ -191,19 +191,19 @@ public class CharacterItemManager {
}
break;
case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
break;
case VAULT:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldVault = i;
else if (this.vault.contains(i) == false)
this.vault.add(i);
@@ -238,13 +238,13 @@ public class CharacterItemManager {
this.equipped.put(i.equipSlot, i);
break;
case BANK:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldBank = i;
else if (this.bank.contains(i) == false)
this.bank.add(i);
break;
case INVENTORY:
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
this.goldInventory = i;
else if (this.inventory.contains(i) == false)
this.inventory.add(i);
@@ -915,7 +915,7 @@ public class CharacterItemManager {
if (i == null)
return false;
if (i.getItemBase().getType().equals(ItemType.GOLD)) {
if (i.template.item_type.equals(ItemType.GOLD)) {
if (this.getGoldInventory() != null) {
if (i.getObjectUUID() == this.getGoldInventory().getObjectUUID())
this.goldInventory = null;
@@ -945,7 +945,7 @@ public class CharacterItemManager {
}
private synchronized boolean junk(Item i, boolean updateInventory) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) {
if (i.template.item_type.equals(ItemType.GOLD)) {
if (this.getGoldInventory().getObjectUUID() == i.getObjectUUID())
if (DbManager.ItemQueries.UPDATE_GOLD(i, 0)) {
this.getGoldInventory().setNumOfItems(0);
@@ -1000,8 +1000,7 @@ public class CharacterItemManager {
if (equippedContains(item)) {
fromEquip = true;
ItemBase ib = item.getItemBase();
if (ib != null && ib.getType().equals(ItemType.GOLD))
if (item.template.item_type.equals(ItemType.GOLD))
this.absCharacter.cancelOnUnEquip();
}
@@ -1211,7 +1210,7 @@ public class CharacterItemManager {
// This removes ingame item from inventory for loot.
private synchronized boolean removeItemFromInventory(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD)) {
if (i.template.item_type.equals(ItemType.GOLD)) {
if (i.getObjectUUID() != this.getGoldInventory().getObjectUUID())
return false;
if (!DbManager.ItemQueries.UPDATE_GOLD(this.goldInventory, 0)) {
@@ -1234,7 +1233,7 @@ public class CharacterItemManager {
// This adds item to inventory for loot. Validity checks already handled
public synchronized boolean addItemToInventory(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
if (this.absCharacter.getObjectType() == GameObjectType.Mob) {
if (this.goldInventory == null)
loadGoldItems();
@@ -1261,7 +1260,7 @@ public class CharacterItemManager {
//called for adding gold of a specified amount
public synchronized boolean addItemToInventory(Item i, int amount) {
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
return DbManager.ItemQueries.UPDATE_GOLD(this.getGoldInventory(), this.goldInventory.getNumOfItems() + amount);
return false;
}
@@ -1623,9 +1622,9 @@ public class CharacterItemManager {
synchronized (lockFirst) {
synchronized (lockSecond) {
// make sure current player has item in inventory
if (lootItem.getItemBase().getType().equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
if (lootItem.template.item_type.equals(ItemType.GOLD) && lootItem.getObjectUUID() != this.getGoldInventory().getObjectUUID() && !(this.absCharacter.getObjectType().equals(GameObjectType.Mob)))
return null;
else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.getItemBase().getType().equals(ItemType.GOLD))
else if (!this.inventory.contains(lootItem) && !this.getEquippedList().contains(lootItem) && !lootItem.template.item_type.equals(ItemType.GOLD))
return null;
// get weight of item
@@ -1636,10 +1635,10 @@ public class CharacterItemManager {
int weight = lootItem.template.item_wt;
// make sure lootingPlayer has room for item
if (!lootItem.getItemBase().getType().equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
if (!lootItem.template.item_type.equals(ItemType.GOLD) && !looterItems.hasRoomInventory(weight))
return null;
if (lootItem.getItemBase().getType().equals(ItemType.GOLD))
if (lootItem.template.item_type.equals(ItemType.GOLD))
if (amount != -1) { //from steal
int total = lootItem.getNumOfItems();
amount = (amount > total) ? total : amount;
@@ -1702,25 +1701,25 @@ public class CharacterItemManager {
* Delegates
*/
public synchronized boolean bankContains(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldBank() != null && this.goldBank.getObjectUUID() == i.getObjectUUID());
return bank.contains(i);
}
public synchronized boolean inventoryContains(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID());
return inventory.contains(i);
}
public synchronized boolean forgeContains(Item i, NPC vendor) {
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldInventory() != null && this.goldInventory.getObjectUUID() == i.getObjectUUID());
return vendor.getRolling().contains(i);
}
public synchronized boolean vaultContains(Item i) {
if (i.getItemBase().getType().equals(ItemType.GOLD))
if (i.template.item_type.equals(ItemType.GOLD))
return (this.getGoldVault() != null && this.goldVault.getObjectUUID() == i.getObjectUUID());
return this.account.getVault().contains(i);
}
@@ -2004,13 +2003,13 @@ public class CharacterItemManager {
item.zeroItem();
item.containerType = Enum.ItemContainerType.INVENTORY;
if (item.getItemBase().getType().equals(ItemType.GOLD))
if (item.template.item_type.equals(ItemType.GOLD))
//only add gold item once
if (!corpse.hasGold())
corpse.setHasGold(true);
newInventory.add(item);
} else //item
if (item.getItemBase().getType().equals(ItemType.GOLD)) {
if (item.template.item_type.equals(ItemType.GOLD)) {
int amt = item.getNumOfItems();
item.setNumOfItems(0);
MobLoot ml = new MobLoot(this.absCharacter, amt);