feat(kæde): manglende led forklares i Kræver handling, fanen og som besked

problemText giver årsag og råd for køb/flaskehals/kredsløb og 'slukket af dig'
(userOff-kopi på ADChain.last); modellens problemer får need. Fanen Kæder viser
teksten som rød tekstrække under varen (foldet ud). Kræver handling får én rød
post pr. kæde (højst 2, score 3500+alvor mellem rød tom og rød fuld); klik åbner
fanen med kæden foldet ud. Engangsbesked pr. nyt led (rod|vare|art) kun fra
tick, ikke i opstartsfristen eller på delvise data/ufærdig markscanning.
Manualer og CHANGELOG opdateret.
This commit is contained in:
2026-09-30 14:40:29 +02:00
parent 1e7b2ec699
commit 19a10ab67c
12 changed files with 254 additions and 20 deletions
+7 -6
View File
@@ -63,8 +63,9 @@ function ADChainModel.build(recipes, husbandry, crops)
end
table.sort(roots, byKey)
local function problem(kind, fillType, rootKey, detail)
table.insert(chain.problems, {kind = kind, fillType = fillType, rootKey = rootKey, detail = detail})
-- detail = manglende liter/md (flaskehals/køb), need = varens behov pr. måned i den gren
local function problem(kind, fillType, rootKey, detail, need)
table.insert(chain.problems, {kind = kind, fillType = fillType, rootKey = rootKey, detail = detail, need = need})
end
local need
@@ -86,7 +87,7 @@ function ADChainModel.build(recipes, husbandry, crops)
chain.demand[name] = (chain.demand[name] or 0) + perMonth
if depth > ADChainModel.MAX_DEPTH or path[name] then
node.source = "cycle"
problem("cycle", name, rootKey)
problem("cycle", name, rootKey, nil, perMonth)
return node
end
path[name] = true
@@ -110,7 +111,7 @@ function ADChainModel.build(recipes, husbandry, crops)
if rest <= 1e-9 then break end
end
if rest > 1e-9 and #node.producers > 0 then
problem("bottleneck", name, rootKey, rest)
problem("bottleneck", name, rootKey, rest, perMonth)
node.shortPerMonth = rest
end
if rest > 1e-9 and #node.producers == 0 then
@@ -139,11 +140,11 @@ function ADChainModel.build(recipes, husbandry, crops)
if rest > 1e-9 and makers ~= nil and #node.producers == 0 and #node.herds == 0 then
node.source = "production"
node.shortPerMonth = rest
problem("bottleneck", name, rootKey, rest)
problem("bottleneck", name, rootKey, rest, perMonth)
elseif rest > 1e-9 and (node.source == nil or node.source == "husbandry") then
if node.source == nil then node.source = "buy" end
node.shortPerMonth = rest
problem("buy", name, rootKey, rest)
problem("buy", name, rootKey, rest, perMonth)
end
node.coveredPerMonth = perMonth - (node.shortPerMonth or 0)
path[name] = nil