chore: Alt automatisk logger afgrødekandidater og udelukkelser — 1.62.281
This commit is contained in:
@@ -82,8 +82,32 @@ end
|
||||
|
||||
-- Knappen: slå alle marker til, frigiv dem til kæderne, giv marker uden mål den bedste afgrøde.
|
||||
-- -> {enabled, targeted, fruit}
|
||||
-- Diagnose: hvor mange afgrøder hver betingelse udelukker + de mest værdifulde med deres flag.
|
||||
function ADAutoCrop.describe(candidates)
|
||||
local counts = {sow = 0, harvest = 0, soon = 0, price = 0}
|
||||
local sorted = {}
|
||||
for _, c in ipairs(candidates or {}) do
|
||||
if c.canSow then counts.sow = counts.sow + 1 end
|
||||
if c.canHarvest then counts.harvest = counts.harvest + 1 end
|
||||
if c.plantableSoon then counts.soon = counts.soon + 1 end
|
||||
if (tonumber(c.value) or 0) > 0 then counts.price = counts.price + 1 end
|
||||
table.insert(sorted, c)
|
||||
end
|
||||
table.sort(sorted, function(a, b) return (tonumber(a.value) or 0) > (tonumber(b.value) or 0) end)
|
||||
local top = {}
|
||||
for index = 1, math.min(8, #sorted) do
|
||||
local c = sorted[index]
|
||||
table.insert(top, string.format("%s %.0f %s%s%s", tostring(c.name), tonumber(c.value) or 0,
|
||||
c.canSow and "S" or "-", c.canHarvest and "H" or "-", c.plantableSoon and "T" or "-"))
|
||||
end
|
||||
return string.format("%d afgrøder: kan sås %d, kan høstes %d, såtid snart %d, har pris %d | top: %s (S=så H=høst T=tid)",
|
||||
#(candidates or {}), counts.sow, counts.harvest, counts.soon, counts.price, table.concat(top, ", "))
|
||||
end
|
||||
|
||||
function ADAutoCrop.applyAll(farmId)
|
||||
local best = ADAutoCrop.pickBest(ADAutoCrop.candidates(farmId))
|
||||
local candidates = ADAutoCrop.candidates(farmId)
|
||||
Logging.info("ADSmartPickup: Alt automatisk: %s", ADAutoCrop.describe(candidates))
|
||||
local best = ADAutoCrop.pickBest(candidates)
|
||||
local bestName = best ~= nil and best.name or nil
|
||||
local enabled, targeted = 0, 0
|
||||
for _, info in ipairs(ADFields.list() or {}) do
|
||||
|
||||
Reference in New Issue
Block a user