summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-12-17 01:39:42 +0100
committerWuzzy <almikes@aol.com>2016-12-17 01:39:42 +0100
commit233e84438f304000048194f4a5b0766f4f2137bc (patch)
tree6287aca92d5ec65c4cb1817050c62981fc50254c
parent11c34326d034824e7e80d2b1d9457e042f8ff8a0 (diff)
Take use count into account for tool sort
-rw-r--r--init.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index eca537e..7e0a025 100644
--- a/init.lua
+++ b/init.lua
@@ -942,6 +942,7 @@ doc.new_category("tools", {
for k,v in pairs(gc) do
if groupcount == 0 then
group = k
+ uses = v.uses
end
for rating, time in pairs(v.times) do
if mintime == nil or time < mintime then
@@ -956,14 +957,20 @@ doc.new_category("tools", {
comp[e].count = groupcount
comp[e].group = group
comp[e].mintime = mintime
+ comp[e].uses = uses
end
-- We want to sort out digging tools with multiple capabilities
if comp[1].count > 1 and comp[1].count > comp[2].count then
return false
- -- Tiebreaker 1: Minimum digging time
elseif comp[1].group == comp[2].group then
- return comp[1].mintime < comp[2].mintime
+ -- Tiebreaker 1: Minimum digging time
+ if comp[1].mintime == comp[2].mintime then
+ -- Tiebreaker 2: Use count
+ return comp[1].uses > comp[2].uses
+ else
+ return comp[1].mintime < comp[2].mintime
+ end
-- Final tiebreaker: Sort by group name
else
return comp[1].group < comp[2].group