Browse Source

Refactor out itembase

combat-2
MagicBot 8 months ago
parent
commit
6ed4faded2
  1. 2
      src/engine/db/handlers/dbItemHandler.java
  2. 2
      src/engine/devcmd/cmds/InfoCmd.java
  3. 2
      src/engine/devcmd/cmds/PrintBankCmd.java
  4. 2
      src/engine/devcmd/cmds/PrintBonusesCmd.java
  5. 2
      src/engine/devcmd/cmds/PrintEquipCmd.java
  6. 2
      src/engine/devcmd/cmds/PrintInventoryCmd.java
  7. 2
      src/engine/devcmd/cmds/PrintVaultCmd.java
  8. 2
      src/engine/gameManager/ChatManager.java
  9. 6
      src/engine/gameManager/LootManager.java
  10. 2
      src/engine/net/client/handlers/ActivateNPCMsgHandler.java
  11. 2
      src/engine/net/client/handlers/ObjectActionMsgHandler.java
  12. 4
      src/engine/net/client/msg/ItemProductionMsg.java
  13. 4
      src/engine/net/client/msg/ManageNPCMsg.java
  14. 20
      src/engine/objects/Item.java
  15. 20
      src/engine/objects/ItemFactory.java
  16. 6
      src/engine/objects/Warehouse.java

2
src/engine/db/handlers/dbItemHandler.java

@ -61,7 +61,7 @@ public class dbItemHandler extends dbHandlerBase {
PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) { PreparedStatement preparedStatement = connection.prepareStatement("CALL `item_CREATE`(?, ?, ?, ?, ?, ?, ?, ?, ?,?);")) {
preparedStatement.setInt(1, toAdd.ownerID); preparedStatement.setInt(1, toAdd.ownerID);
preparedStatement.setInt(2, toAdd.getTemplsteID()); preparedStatement.setInt(2, toAdd.getTemplateID());
preparedStatement.setInt(3, (byte) toAdd.chargesRemaining); preparedStatement.setInt(3, (byte) toAdd.chargesRemaining);
preparedStatement.setInt(4, (short) toAdd.durabilityCurrent); preparedStatement.setInt(4, (short) toAdd.durabilityCurrent);
preparedStatement.setInt(5, (int) toAdd.template.item_health_full); preparedStatement.setInt(5, (int) toAdd.template.item_health_full);

2
src/engine/devcmd/cmds/InfoCmd.java

@ -506,7 +506,7 @@ public class InfoCmd extends AbstractDevCmd {
case MobLoot: case MobLoot:
Item item = (Item) target; Item item = (Item) target;
ItemBase itemBase = item.getItemBase(); ItemBase itemBase = item.getItemBase();
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20); output += StringUtils.addWS("ItemBase: " + itemBase.getUUID(), 20);
output += "Weight: " + template.item_wt; output += "Weight: " + template.item_wt;
output += newline; output += newline;

2
src/engine/devcmd/cmds/PrintBankCmd.java

@ -52,7 +52,7 @@ public class PrintBankCmd extends AbstractDevCmd {
throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Bank for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems()); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
} }

2
src/engine/devcmd/cmds/PrintBonusesCmd.java

@ -33,7 +33,7 @@ public class PrintBonusesCmd extends AbstractDevCmd {
if (target instanceof Item) { if (target instanceof Item) {
type = "Item"; type = "Item";
tar = (Item) target; tar = (Item) target;
ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(((Item) tar).getTemplateID());
name = template.item_base_name; name = template.item_base_name;
} else if (target instanceof AbstractCharacter) { } else if (target instanceof AbstractCharacter) {
tar = (AbstractCharacter) target; tar = (AbstractCharacter) target;

2
src/engine/devcmd/cmds/PrintEquipCmd.java

@ -89,7 +89,7 @@ public class PrintEquipCmd extends AbstractDevCmd {
for (Enum.EquipSlotType slot : list.keySet()) { for (Enum.EquipSlotType slot : list.keySet()) {
Item item = list.get(slot); Item item = list.get(slot);
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot); throwbackInfo(pc, " " + template.item_base_name + ", slot: " + slot);
} }
} }

2
src/engine/devcmd/cmds/PrintInventoryCmd.java

@ -75,7 +75,7 @@ public class PrintInventoryCmd extends AbstractDevCmd {
int goldCount = 0; int goldCount = 0;
for (Item item : inventory) { for (Item item : inventory) {
ItemTemplate template = ItemTemplate.itemTemplates.get(item.templsteID); ItemTemplate template = ItemTemplate.itemTemplates.get(item.templateID);
if (item.template.item_type.equals(ItemType.GOLD) == false) { if (item.template.item_type.equals(ItemType.GOLD) == false) {

2
src/engine/devcmd/cmds/PrintVaultCmd.java

@ -50,7 +50,7 @@ public class PrintVaultCmd extends AbstractDevCmd {
ArrayList<Item> list = cim.getVault(); ArrayList<Item> list = cim.getVault();
throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')'); throwbackInfo(pc, "Vault for " + type + ' ' + name + " (" + tar.getObjectUUID() + ')');
for (Item item : list) { for (Item item : list) {
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems()); throwbackInfo(pc, " " + template.item_base_name + ", count: " + item.getNumOfItems());
} }
Item gold = cim.getGoldVault(); Item gold = cim.getGoldVault();

2
src/engine/gameManager/ChatManager.java

@ -612,7 +612,7 @@ public enum ChatManager {
name = amount + " gold "; name = amount + " gold ";
else { else {
String vowels = "aeiou"; String vowels = "aeiou";
ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(item.getTemplateID());
String iName = template.item_base_name; String iName = template.item_base_name;
if (iName.length() > 0) if (iName.length() > 0)
if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0) if (vowels.indexOf(iName.substring(0, 1).toLowerCase()) >= 0)

6
src/engine/gameManager/LootManager.java

@ -87,7 +87,7 @@ public enum LootManager {
if (ib == null) if (ib == null)
break; break;
ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(it.getTemplateID());
if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) { if (ib.isDiscRune() || template.item_base_name.toLowerCase().contains("of the gods")) {
ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?"); ChatSystemMsg chatMsg = new ChatSystemMsg(null, mob.getName() + " in " + mob.getParentZone().zoneName + " has found the " + template.item_base_name + ". Are you tough enough to take it?");
@ -381,8 +381,8 @@ public enum LootManager {
int tableID = 0; int tableID = 0;
if (_bootySetMap.get(gift.getTemplsteID()) != null) if (_bootySetMap.get(gift.getTemplateID()) != null)
tableID = _bootySetMap.get(gift.getTemplsteID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplsteID()).size())).genTable; tableID = _bootySetMap.get(gift.getTemplateID()).get(ThreadLocalRandom.current().nextInt(_bootySetMap.get(gift.getTemplateID()).size())).genTable;
if (tableID == 0) if (tableID == 0)
return; return;

2
src/engine/net/client/handlers/ActivateNPCMsgHandler.java

@ -50,7 +50,7 @@ public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
for (Item hirelings : player.getInventory()) { for (Item hirelings : player.getInventory()) {
if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) { if (hirelings.template.item_type.equals(ItemType.EMPLOYMENTCONTRACT)) {
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templsteID); contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.templateID);
if (contract == null) if (contract == null)
continue; continue;

2
src/engine/net/client/handlers/ObjectActionMsgHandler.java

@ -77,7 +77,7 @@ public class ObjectActionMsgHandler extends AbstractClientMsgHandler {
if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) { if (itemMan.doesCharOwnThisItem(item.getObjectUUID())) {
int uuid = item.templsteID; int uuid = item.templateID;
switch (item.template.item_type) { switch (item.template.item_type) {

4
src/engine/net/client/msg/ItemProductionMsg.java

@ -284,7 +284,7 @@ public class ItemProductionMsg extends ClientNetMsg {
writer.putInt(this.itemUUID); writer.putInt(this.itemUUID);
writer.putInt(0); //items left to produce? writer.putInt(0); //items left to produce?
if (toRoll != null) { if (toRoll != null) {
writer.putInt(toRoll.getTemplsteID()); writer.putInt(toRoll.getTemplateID());
writer.putInt(toRoll.getValue()); writer.putInt(toRoll.getValue());
} else { } else {
writer.putInt(0); writer.putInt(0);
@ -301,7 +301,7 @@ public class ItemProductionMsg extends ClientNetMsg {
timeLeft /= 1000; timeLeft /= 1000;
writer.putInt((int) timeLeft); writer.putInt((int) timeLeft);
writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplsteID())); writer.putInt(vendor.getRollingTimeInSeconds(toRoll.getTemplateID()));
} }
} else { } else {

4
src/engine/net/client/msg/ManageNPCMsg.java

@ -450,14 +450,14 @@ public class ManageNPCMsg extends ClientNetMsg {
writer.putInt(i.getObjectUUID()); writer.putInt(i.getObjectUUID());
writer.putInt(0); writer.putInt(0);
writer.putInt(i.getTemplsteID()); writer.putInt(i.getTemplateID());
writer.putInt(template.item_value); writer.putInt(template.item_value);
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis(); long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();
timeLife /= 1000; timeLife /= 1000;
writer.putInt((int) timeLife); writer.putInt((int) timeLife);
writer.putInt(npc.getRollingTimeInSeconds(i.getTemplsteID())); writer.putInt(npc.getRollingTimeInSeconds(i.getTemplateID()));
writer.putInt(1); writer.putInt(1);
if (i.isComplete()) if (i.isComplete())

20
src/engine/objects/Item.java

@ -52,7 +52,7 @@ public class Item extends AbstractWorldObject {
private boolean isRandom = false; private boolean isRandom = false;
private int value; private int value;
public OwnerType ownerType; public OwnerType ownerType;
public int templsteID; public int templateID;
private AbstractWorldObject lastOwner; private AbstractWorldObject lastOwner;
private long dateToUpgrade; private long dateToUpgrade;
private String customName = ""; private String customName = "";
@ -67,7 +67,7 @@ public class Item extends AbstractWorldObject {
public Item(int templateID) { public Item(int templateID) {
super(); super();
this.templsteID = templateID; this.templateID = templateID;
this.template = ItemTemplate.itemTemplates.get(templateID); this.template = ItemTemplate.itemTemplates.get(templateID);
this.chargesRemaining = this.template.item_initial_charges; this.chargesRemaining = this.template.item_initial_charges;
this.durabilityCurrent = this.template.combat_health_full; this.durabilityCurrent = this.template.combat_health_full;
@ -84,11 +84,11 @@ public class Item extends AbstractWorldObject {
public Item(ResultSet rs) throws SQLException { public Item(ResultSet rs) throws SQLException {
super(rs); super(rs);
this.templsteID = rs.getInt("item_itemBaseID"); this.templateID = rs.getInt("item_itemBaseID");
this.template = ItemTemplate.itemTemplates.get(this.templsteID); this.template = ItemTemplate.itemTemplates.get(this.templateID);
if (this.template == null) if (this.template == null)
Logger.error("Null template of " + this.templsteID) Logger.error("Null template of " + this.templateID)
; ;
// Set container enumeration // Set container enumeration
@ -227,7 +227,7 @@ public class Item extends AbstractWorldObject {
writer.putInt(0); // Pad writer.putInt(0); // Pad
writer.putInt(0); // Pad writer.putInt(0); // Pad
if (item.getItemBase().equals(ItemBase.GOLD_ITEM_BASE)) { if (item.templateID == ResourceType.GOLD.templateID) {
if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) { if (item.getOwner() != null && item.getOwner().getObjectType() == GameObjectType.PlayerCharacter) {
PlayerCharacter player = (PlayerCharacter) item.getOwner(); PlayerCharacter player = (PlayerCharacter) item.getOwner();
@ -660,11 +660,11 @@ public class Item extends AbstractWorldObject {
} }
public ItemBase getItemBase() { public ItemBase getItemBase() {
return ItemBase.getItemBase(templsteID); return ItemBase.getItemBase(templateID);
} }
public int getTemplsteID() { public int getTemplateID() {
return this.templsteID; return this.templateID;
} }
public int getOwnerID() { public int getOwnerID() {
@ -1012,7 +1012,7 @@ public class Item extends AbstractWorldObject {
if (this.customName.isEmpty() == false) if (this.customName.isEmpty() == false)
return this.customName; return this.customName;
ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplsteID()); ItemTemplate template = ItemTemplate.itemTemplates.get(this.getTemplateID());
return template.item_base_name; return template.item_base_name;
} }

20
src/engine/objects/ItemFactory.java

@ -179,8 +179,8 @@ public class ItemFactory {
time = (20 - rate); time = (20 - rate);
time *= MBServerStatics.ONE_MINUTE; time *= MBServerStatics.ONE_MINUTE;
if (ml.templsteID > 910010 && ml.templsteID < 910019) { if (ml.templateID > 910010 && ml.templateID < 910019) {
rank = ml.getTemplsteID() - 910010; rank = ml.getTemplateID() - 910010;
time = rank * 60 * 60 * 3 * 1000; time = rank * 60 * 60 * 3 * 1000;
} }
@ -201,8 +201,8 @@ public class ItemFactory {
if (pc != null) if (pc != null)
playerID = pc.getObjectUUID(); playerID = pc.getObjectUUID();
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, "", "", "", false, playerID); DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, "", "", "", false, playerID);
ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, "", "", "", playerID); ProducedItem pi = new ProducedItem(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, "", "", "", playerID);
pi.setProducedItemID(ml.getObjectUUID()); pi.setProducedItemID(ml.getObjectUUID());
pi.setAmount(itemsToRoll); pi.setAmount(itemsToRoll);
pi.setRandom(false); pi.setRandom(false);
@ -589,7 +589,7 @@ public class ItemFactory {
time *= MBServerStatics.ONE_MINUTE; time *= MBServerStatics.ONE_MINUTE;
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) { if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
rank = ml.getTemplsteID() - 910010; rank = ml.getTemplateID() - 910010;
time = rank * 60 * 60 * 3 * 1000; time = rank * 60 * 60 * 3 * 1000;
} }
@ -610,8 +610,8 @@ public class ItemFactory {
if (pc != null) if (pc != null)
playerID = pc.getObjectUUID(); playerID = pc.getObjectUUID();
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID); DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(ml.getObjectUUID(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, prefixString, suffixString, ml.getCustomName(), false, playerID);
ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplsteID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID); ProducedItem pi = new ProducedItem(npc.getRolling().size(), npc.getObjectUUID(), ml.getTemplateID(), dateTime, false, prefixString, suffixString, ml.getCustomName(), playerID);
pi.setProducedItemID(ml.getObjectUUID()); pi.setProducedItemID(ml.getObjectUUID());
pi.setAmount(itemsToRoll); pi.setAmount(itemsToRoll);
@ -728,7 +728,7 @@ public class ItemFactory {
time *= MBServerStatics.ONE_MINUTE; time *= MBServerStatics.ONE_MINUTE;
if (toRoll.getItemBase().getUUID() > 910010 && toRoll.getItemBase().getUUID() < 910019) { if (toRoll.getItemBase().getUUID() > 910010 && toRoll.getItemBase().getUUID() < 910019) {
rank = toRoll.getTemplsteID() - 910010; rank = toRoll.getTemplateID() - 910010;
time = rank * 60 * 60 * 3 * 1000; time = rank * 60 * 60 * 3 * 1000;
} }
@ -748,9 +748,9 @@ public class ItemFactory {
if (playerCharacter != null) if (playerCharacter != null)
playerID = playerCharacter.getObjectUUID(); playerID = playerCharacter.getObjectUUID();
DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID); DbManager.NPCQueries.ADD_TO_PRODUCTION_LIST(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, prefix, suffix, toRoll.getCustomName(), true, playerID);
ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplsteID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID); ProducedItem pi = new ProducedItem(toRoll.getObjectUUID(), vendor.getObjectUUID(), toRoll.getTemplateID(), dateTime, true, prefix, suffix, toRoll.getCustomName(), playerID);
pi.setProducedItemID(toRoll.getObjectUUID()); pi.setProducedItemID(toRoll.getObjectUUID());
pi.setAmount(itemsToRoll); pi.setAmount(itemsToRoll);
ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue()))); ItemQueue produced = ItemQueue.borrow(pi, (long) (time * Float.parseFloat(ConfigManager.MB_PRODUCTION_RATE.getValue())));

6
src/engine/objects/Warehouse.java

@ -223,7 +223,7 @@ public class Warehouse extends AbstractWorldObject {
return false; return false;
} }
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templsteID); Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templateID);
if (warehouse.resources.get(resourceType) == null) if (warehouse.resources.get(resourceType) == null)
return false; return false;
@ -251,7 +251,7 @@ public class Warehouse extends AbstractWorldObject {
int newAmount = oldAmount + amount; int newAmount = oldAmount + amount;
if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templsteID).deposit_limit) { if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templateID).deposit_limit) {
//ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource."); //ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource.");
return false; return false;
} }
@ -293,7 +293,7 @@ public class Warehouse extends AbstractWorldObject {
if (resource.template.item_type.equals(Enum.ItemType.GOLD)) if (resource.template.item_type.equals(Enum.ItemType.GOLD))
resourceType = Enum.ResourceType.GOLD; resourceType = Enum.ResourceType.GOLD;
else else
resourceType = Enum.ResourceType.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplsteID()).item_base_name.toUpperCase()); resourceType = Enum.ResourceType.valueOf(ItemTemplate.itemTemplates.get(resource.getTemplateID()).item_base_name.toUpperCase());
if (transaction) if (transaction)
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount); AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount);

Loading…
Cancel
Save