From a7f22a791c2823dcb34991d4a8dc34492f6fe38c Mon Sep 17 00:00:00 2001 From: elb <51070858+elobo91@users.noreply.github.com> Date: Mon, 16 Dec 2024 01:17:06 -0500 Subject: [PATCH] =?UTF-8?q?Repair=20the=20repair=20=F0=9F=91=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/action/repair.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/internal/action/repair.go b/internal/action/repair.go index 9edf8184..92ced5fd 100644 --- a/internal/action/repair.go +++ b/internal/action/repair.go @@ -86,7 +86,7 @@ func RepairRequired() bool { ctx.SetLastAction("RepairRequired") for _, i := range ctx.Data.Inventory.ByLocation(item.LocationEquipped) { - // Check indestructible first + // Skip indestructible items _, indestructible := i.FindStat(stat.Indestructible, 0) if i.Ethereal || indestructible { continue @@ -95,15 +95,24 @@ func RepairRequired() bool { currentDurability, currentDurabilityFound := i.FindStat(stat.Durability, 0) maxDurability, maxDurabilityFound := i.FindStat(stat.MaxDurability, 0) - // Skip if we don't have both stats - if !maxDurabilityFound || !currentDurabilityFound { - continue // Don't trigger repair if we can't properly check durability + // If we have both stats, check percentage + if currentDurabilityFound && maxDurabilityFound { + durabilityPercent := int((float64(currentDurability.Value) / float64(maxDurability.Value)) * 100) + if durabilityPercent <= 20 { + return true + } } - durabilityPercent := int((float64(currentDurability.Value) / float64(maxDurability.Value)) * 100) + // If we only have current durability, check absolute value + if currentDurabilityFound { + if currentDurability.Value <= 5 { + return true + } + } - // Only return true if we have valid durability values and they're low - if durabilityPercent <= 20 || currentDurability.Value <= 5 { + // Handle case where durability stat is missing but max durability exists + // This likely indicates the item needs repair + if maxDurabilityFound && !currentDurabilityFound { return true } }