forked from MagicBane/Server
item_value refactored to template
This commit is contained in:
@@ -423,10 +423,11 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
|
||||
for (int ib : rollableSet) {
|
||||
ItemBase item = ItemBase.getItemBase(ib);
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(ib);
|
||||
writer.put((byte) 1);
|
||||
writer.putInt(0);
|
||||
writer.putInt(ib); //itemID
|
||||
writer.putInt(item.getBaseValue());
|
||||
writer.putInt(template.item_value);
|
||||
writer.putInt(600);
|
||||
writer.put((byte) 1);
|
||||
writer.put((byte) item.getModTable());
|
||||
@@ -443,14 +444,14 @@ public class ManageNPCMsg extends ClientNetMsg {
|
||||
for (Item i : itemList) {
|
||||
|
||||
ItemBase ib = i.getItemBase();
|
||||
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(ib);
|
||||
writer.put((byte) 0); // ? Unknown45
|
||||
writer.putInt(i.getObjectType().ordinal());
|
||||
writer.putInt(i.getObjectUUID());
|
||||
|
||||
writer.putInt(0);
|
||||
writer.putInt(i.getTemplsteID());
|
||||
writer.putInt(ib.getBaseValue());
|
||||
writer.putInt(template.item_value);
|
||||
|
||||
long timeLife = i.getDateToUpgrade() - System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -234,7 +234,7 @@ public class Item extends AbstractWorldObject {
|
||||
} else
|
||||
writer.putInt(item.numberOfItems); // Amount of gold
|
||||
} else
|
||||
writer.putInt(item.getItemBase().getBaseValue());
|
||||
writer.putInt(item.template.item_value);
|
||||
|
||||
writer.putInt(item.getValue());
|
||||
|
||||
@@ -1049,7 +1049,7 @@ public class Item extends AbstractWorldObject {
|
||||
public final void loadEnchantments() {
|
||||
//dont load mobloot enchantments, they arent in db.
|
||||
if (this.getObjectType().equals(GameObjectType.MobLoot)) {
|
||||
this.magicValue = this.getItemBase().getBaseValue() + calcMagicValue();
|
||||
this.magicValue = this.template.item_value + calcMagicValue();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1063,7 +1063,7 @@ public class Item extends AbstractWorldObject {
|
||||
}
|
||||
}
|
||||
|
||||
this.magicValue = this.getItemBase().getBaseValue() + calcMagicValue();
|
||||
this.magicValue = this.template.item_value + calcMagicValue();
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> getBakedInStats() {
|
||||
@@ -1226,7 +1226,7 @@ public class Item extends AbstractWorldObject {
|
||||
public int getValue() {
|
||||
|
||||
if (this.value == 0)
|
||||
if (this.template.item_flags.contains(ItemFlags.Identified)) {
|
||||
if (this.isID()) {
|
||||
return this.getMagicValue();
|
||||
} else
|
||||
return this.template.item_value;
|
||||
|
||||
@@ -45,7 +45,6 @@ public class ItemBase {
|
||||
public EnumSet<Enum.ClassType> requiredClasses;
|
||||
public EnumSet<Enum.DisciplineType> requiredDiscs;
|
||||
public EnumSet<Enum.DisciplineType> restrictedDiscs;
|
||||
private final int value;
|
||||
private final short weight;
|
||||
private final short color;
|
||||
private final ItemType type;
|
||||
@@ -91,7 +90,6 @@ public class ItemBase {
|
||||
|
||||
this.uuid = rs.getInt("ID");
|
||||
|
||||
this.value = rs.getInt("value");
|
||||
this.weight = rs.getShort("weight");
|
||||
this.color = rs.getShort("color");
|
||||
this.type = ItemType.valueOf(rs.getString("Type"));
|
||||
@@ -258,15 +256,6 @@ public class ItemBase {
|
||||
DbManager.ItemBaseQueries.LOAD_BAKEDINSTATS(this);
|
||||
}
|
||||
|
||||
//TODO fix this later. Shouldn't be gotten from item base
|
||||
public int getMagicValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public int getBaseValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public short getWeight() {
|
||||
return this.weight;
|
||||
}
|
||||
@@ -463,7 +452,7 @@ public class ItemBase {
|
||||
if (this.canCharacterEquip(abstractCharacter) == false)
|
||||
return false;
|
||||
|
||||
return item.getItemBase().value != 0 || Kit.IsNoobGear(item.getItemBase().uuid);
|
||||
return item.template.item_value != 0 || Kit.IsNoobGear(item.getItemBase().uuid);
|
||||
//players can't wear 0 value items.
|
||||
|
||||
}
|
||||
|
||||
@@ -124,9 +124,8 @@ public class ItemFactory {
|
||||
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
|
||||
|
||||
|
||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, ib.getBaseValue());
|
||||
int overdraft = BuildingManager.GetOverdraft(forge, ib.getBaseValue());
|
||||
|
||||
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);
|
||||
@@ -308,7 +307,7 @@ public class ItemFactory {
|
||||
if (prefixValue == null)
|
||||
return null;
|
||||
|
||||
int baseCost = ib.getBaseValue();
|
||||
int baseCost = template.item_value;
|
||||
int effectCost = (int) prefixValue.getValue();
|
||||
int total = baseCost * 10 + effectCost;
|
||||
|
||||
@@ -361,7 +360,7 @@ public class ItemFactory {
|
||||
if (suffixValue == null)
|
||||
return null;
|
||||
suffixResourceCosts = suffix.getResourcesForEffect();
|
||||
int baseCost = ib.getBaseValue();
|
||||
int baseCost = template.item_value;
|
||||
int effectCost = (int) suffixValue.getValue();
|
||||
suffixCost = effectCost;
|
||||
int total = baseCost * 10 + effectCost;
|
||||
@@ -405,7 +404,7 @@ public class ItemFactory {
|
||||
|
||||
|
||||
//Check if Total suffix and prefix costs + itemCost can be withdrawn.
|
||||
int costToCreate = suffixCost + prefixCost + (ib.getBaseValue());
|
||||
int costToCreate = suffixCost + prefixCost + template.item_value;
|
||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate);
|
||||
|
||||
int overdraft = BuildingManager.GetOverdraft(forge, costToCreate);
|
||||
@@ -510,7 +509,7 @@ public class ItemFactory {
|
||||
|
||||
if (prefix == null && suffix == null) {
|
||||
|
||||
int baseCost = ib.getBaseValue();
|
||||
int baseCost = template.item_value;
|
||||
int total = (int) (baseCost + baseCost * (float) .10);
|
||||
|
||||
buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total);
|
||||
@@ -889,7 +888,7 @@ public class ItemFactory {
|
||||
|
||||
ItemBase goldIB = ItemBase.getGoldItemBase();
|
||||
|
||||
int baseCost = ib.getBaseValue();
|
||||
int baseCost = template.item_value;
|
||||
int total = (int) (baseCost + baseCost * .10);
|
||||
|
||||
EffectsBase suffix = null;
|
||||
@@ -903,7 +902,7 @@ public class ItemFactory {
|
||||
|
||||
//calculate gold costs and remove from the warehouse
|
||||
if (prefix != null || suffix != null) {
|
||||
int costToCreate = (int) (ib.getBaseValue() + ib.getBaseValue() * .10f);
|
||||
int costToCreate = (int) (template.item_value + template.item_value * .10f);
|
||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate);
|
||||
int overdraft = BuildingManager.GetOverdraft(forge, costToCreate);
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ public class MobEquipment extends AbstractGameObject {
|
||||
|
||||
public static void serializeForVendor(MobEquipment mobEquipment, ByteBufferWriter writer, float percent) throws SerializationException {
|
||||
_serializeForClientMsg(mobEquipment, writer, false);
|
||||
int baseValue = mobEquipment.itemBase.getBaseValue() + mobEquipment.itemBase.getMagicValue();
|
||||
writer.putInt(mobEquipment.magicValue);
|
||||
writer.putInt(mobEquipment.magicValue);
|
||||
}
|
||||
@@ -161,7 +160,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
writer.putInt(0); // Pad
|
||||
writer.putInt(0); // Pad
|
||||
|
||||
writer.putInt(mobEquipment.itemBase.getBaseValue());
|
||||
writer.putInt(mobEquipment.template.item_value);
|
||||
writer.putInt(mobEquipment.magicValue);
|
||||
|
||||
serializeEffects(mobEquipment, writer);
|
||||
@@ -262,7 +261,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
public final void setMagicValue() {
|
||||
float value = 1;
|
||||
if (itemBase != null)
|
||||
value = itemBase.getBaseValue();
|
||||
value = template.item_value;
|
||||
if (this.prefix != null) {
|
||||
if (this.prefix.getEffectsBase() != null)
|
||||
value += this.prefix.getEffectsBase().getValue();
|
||||
@@ -300,7 +299,7 @@ public class MobEquipment extends AbstractGameObject {
|
||||
public int getMagicValue() {
|
||||
|
||||
if (!this.isID) {
|
||||
return itemBase.getBaseValue();
|
||||
return template.item_value;
|
||||
}
|
||||
return this.magicValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user