From 8b1a6e4d2a7cfeb0effa2559fe11844ec9022ac2 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 2 Feb 2025 10:19:44 +0000 Subject: [PATCH] Improved GetItemQualityModifierForItems logic --- Libraries/Core/Helpers/ItemHelper.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/Core/Helpers/ItemHelper.cs b/Libraries/Core/Helpers/ItemHelper.cs index da5de4e8..948f1e87 100644 --- a/Libraries/Core/Helpers/ItemHelper.cs +++ b/Libraries/Core/Helpers/ItemHelper.cs @@ -517,7 +517,7 @@ public class ItemHelper( { if (IsOfBaseclass(itemWithChildren[0].Template, BaseClasses.WEAPON)) { - return GetItemQualityModifier(itemWithChildren[0]); + return Math.Round(GetItemQualityModifier(itemWithChildren[0]), 5); } var qualityModifier = 0D; @@ -540,7 +540,7 @@ public class ItemHelper( return 1; } - return Math.Min(qualityModifier / itemsWithQualityCount, 1); + return Math.Min(Math.Round(qualityModifier / itemsWithQualityCount, 5), 1); } /** @@ -624,7 +624,7 @@ public class ItemHelper( */ protected double GetRepairableItemQualityValue(TemplateItem itemDetails, UpdRepairable repairable, Item item) { - // Edge case, max durability is below durability + // Edge case, durability above max if (repairable.Durability > repairable.MaxDurability) { _logger.Warning( @@ -634,10 +634,10 @@ public class ItemHelper( } // Attempt to get the max durability from _props. If not available, use Repairable max durability value instead. - var maxDurability = itemDetails.Properties?.MaxDurability ?? repairable.MaxDurability; - var durability = repairable.Durability / maxDurability; + var maxPossibleDurability = itemDetails.Properties?.MaxDurability ?? repairable.MaxDurability; + var durability = repairable.Durability / maxPossibleDurability; - if (durability is null) + if (durability == 0) { _logger.Error(_localisationService.GetText("item-durability_value_invalid_use_default", item.Template));