Skip to content

Commit

Permalink
Repair the repair 👀
Browse files Browse the repository at this point in the history
  • Loading branch information
elobo91 authored Dec 16, 2024
1 parent 7df91ec commit a7f22a7
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions internal/action/repair.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
Expand Down

0 comments on commit a7f22a7

Please sign in to comment.