feat: regel 'Hent først når kilden er over X %' for salgsflows (v1.62.68)

This commit is contained in:
2026-10-07 23:24:55 +02:00
parent 31b8b19b9c
commit c5da46e876
11 changed files with 41 additions and 6 deletions
+7
View File
@@ -20,6 +20,8 @@ ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_S
-- "Sælg altid over X %": kildens lager over grænsen sælges uanset pris (0 = fra). Så hober f.eks. gylle
-- ved BGA'en sig ikke op, når prisen er lav.
ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT = 0, 0, 100
-- "hent først ved X % i kilden" (0 = fra): salg venter til kilden er så fuld eller et fuldt læs ligger klar
ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT = 0, 0, 95
local function copyList(list)
local copy = {}
@@ -86,6 +88,7 @@ local function copyRun(run)
sellAtPercent = run.sellAtPercent,
storeAbovePercent = run.storeAbovePercent,
sellAbovePercent = run.sellAbovePercent,
minSourcePercent = run.minSourcePercent,
collectRound = run.collectRound,
targetWayPointId = run.targetWayPointId,
targetWayPointIds = copyList(run.targetWayPointIds),
@@ -138,6 +141,7 @@ function ADRuns.createRun(store, name, kind)
sellAtPercent = ADRuns.DEFAULT_SELL_AT_PERCENT,
storeAbovePercent = ADRuns.DEFAULT_STORE_ABOVE_PERCENT,
sellAbovePercent = ADRuns.DEFAULT_SELL_ABOVE_PERCENT,
minSourcePercent = ADRuns.DEFAULT_MIN_SOURCE_PERCENT,
collectRound = false,
targetWayPointId = nil,
targetWayPointIds = {},
@@ -207,6 +211,7 @@ function ADRuns.updateRun(store, runId, changes)
if changes.sellAtPercent ~= nil then run.sellAtPercent = tonumber(changes.sellAtPercent) == 0 and 0 or clampRange(changes.sellAtPercent, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT) end
if changes.storeAbovePercent ~= nil then run.storeAbovePercent = clampRange(changes.storeAbovePercent, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT) end
if changes.sellAbovePercent ~= nil then run.sellAbovePercent = clampRange(changes.sellAbovePercent, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT) end
if changes.minSourcePercent ~= nil then run.minSourcePercent = clampRange(changes.minSourcePercent, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT) end
if changes.collectRound ~= nil then run.collectRound = changes.collectRound == true end
if changes.chain ~= nil then run.chain = tostring(changes.chain) end
return new
@@ -442,6 +447,7 @@ function ADRuns.toRecords(store)
sellAt = run.sellAtPercent,
storeAbove = run.storeAbovePercent,
sellAbove = run.sellAbovePercent or 0,
minSource = run.minSourcePercent or 0,
collectRound = run.collectRound and 1 or 0,
stopped = run.stopped and 1 or 0,
sleeping = run.sleeping and 1 or 0,
@@ -490,6 +496,7 @@ function ADRuns.fromRecords(records)
sellAtPercent = tonumber(record.sellAt) == 0 and 0 or clampRange(record.sellAt, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT),
storeAbovePercent = clampRange(record.storeAbove, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT),
sellAbovePercent = clampRange(record.sellAbove, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT),
minSourcePercent = clampRange(record.minSource, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT),
collectRound = tonumber(record.collectRound) == 1,
targetWayPointId = targets[1],
targetWayPointIds = targets,