From a1f233723f3ecdc7cfed1a6e85a81107af078d02 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 27 Mar 2024 13:09:35 -0400 Subject: [PATCH] Cleanup of value handling --- .../net/client/handlers/VendorBuyMsgHandler.java | 2 +- src/engine/objects/Item.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/engine/net/client/handlers/VendorBuyMsgHandler.java b/src/engine/net/client/handlers/VendorBuyMsgHandler.java index cf3e0277..3f3389dd 100644 --- a/src/engine/net/client/handlers/VendorBuyMsgHandler.java +++ b/src/engine/net/client/handlers/VendorBuyMsgHandler.java @@ -90,7 +90,7 @@ public class VendorBuyMsgHandler extends AbstractClientMsgHandler { if (!itemMan.hasRoomInventory(me.template.item_wt)) return true; - int cost = me.magicValue; + int cost = me.getValue(); float bargain = sourcePlayer.getBargain(); diff --git a/src/engine/objects/Item.java b/src/engine/objects/Item.java index 89f38a85..2e14741e 100644 --- a/src/engine/objects/Item.java +++ b/src/engine/objects/Item.java @@ -1152,10 +1152,20 @@ public class Item extends AbstractWorldObject { */ public int getValue() { + int modifiedValue; + if (this.flags.contains(ItemFlags.Identified)) - return this.magicValue; + modifiedValue = this.magicValue; + else + modifiedValue = this.value; + + if (this.template.item_initial_charges > 0) + modifiedValue = modifiedValue * (this.chargesRemaining / this.template.item_initial_charges); + + if (this.template.combat_health_full > 0) + modifiedValue = (int) (modifiedValue * (this.combat_health_current / this.template.combat_health_full)); - return this.value; + return modifiedValue; } /**