From eba905b15d3bf0bed372fce3762e3777dbf1fa37 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 25 Mar 2024 00:52:47 -0400 Subject: [PATCH] Value set in constructor --- .../net/client/handlers/BuyFromNPCMsgHandler.java | 6 +++--- src/engine/objects/CharacterItemManager.java | 2 +- src/engine/objects/Item.java | 10 +++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java b/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java index 4035b92f..b9bc5031 100644 --- a/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java +++ b/src/engine/net/client/handlers/BuyFromNPCMsgHandler.java @@ -90,7 +90,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { if (!itemMan.hasRoomInventory(me.template.item_wt)) return true; - int cost = me.getMagicValue(); + int cost = me.magicValue; float bargain = sourcePlayer.getBargain(); @@ -112,7 +112,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { if (building != null && building.getProtectionState().equals(Enum.ProtectionState.NPC)) building = null; - int buildingDeposit = cost - me.getMagicValue(); + int buildingDeposit = cost - me.magicValue; if (building != null && (building.getStrongboxValue() + buildingDeposit) > building.getMaxGold()) { ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206); @@ -155,7 +155,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { int cost = vendorItem.template.item_value; if (vendorItem.flags.contains(Enum.ItemFlags.Identified) || vendorItem.isCustomValue()) - cost = vendorItem.getMagicValue(); + cost = vendorItem.magicValue; float bargain = sourcePlayer.getBargain(); diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index ac6c5a4b..28af33c6 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1477,7 +1477,7 @@ public class CharacterItemManager { if (!purchasedItem.moveItemToInventory((PlayerCharacter) this.absCharacter)) return false; - if (purchasedItem.getValue() != purchasedItem.getMagicValue()) { + if (purchasedItem.getValue() != purchasedItem.magicValue) { DbManager.ItemQueries.UPDATE_VALUE(purchasedItem, 0); purchasedItem.setValue(0); } diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index e7de57bc..35f3c6f5 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -56,7 +56,7 @@ public class Item extends AbstractWorldObject { public OwnerType ownerType; public int templateID; private long dateToUpgrade; - private int magicValue; + public int magicValue; public ItemTemplate template; public String name; @@ -76,7 +76,7 @@ public class Item extends AbstractWorldObject { this.numberOfItems = 1; this.flags.addAll(this.template.item_flags); this.value = this.template.item_value; - + this.magicValue = this.value + calcMagicValue(); loadTemplateEnchantments(); } @@ -971,10 +971,6 @@ public class Item extends AbstractWorldObject { return true; } - public final int getMagicValue() { - return this.magicValue; - } - private void loadTemplateEnchantments() { EffectsBase effect; @@ -1155,7 +1151,7 @@ public class Item extends AbstractWorldObject { if (this.value == 0) if (this.flags.contains(ItemFlags.Identified)) { - return this.getMagicValue(); + return this.magicValue; } else return this.template.item_value;