fix(kæde): stald-mangel forklares rigtigt og beskeder nævner kæden
Køb af en rest efter gårdens stalde giver nu spu_chain_problem_barn (køb resten eller flere dyr) i stedet for 'byg en fabrik'. Engangsbeskeden får kædens navn foran, så to kæder der mangler samme vare kan skelnes.
This commit is contained in:
@@ -365,8 +365,13 @@ function ADChain.notifyProblems(last)
|
||||
if #fresh == 0 or ADFieldJobs == nil or ADFieldJobs.notify == nil then return 0 end
|
||||
local textOf = function(key) return g_i18n ~= nil and g_i18n:getText(key) or key end
|
||||
local fmt = SmartPickupFrame ~= nil and SmartPickupFrame.formatCompact or nil
|
||||
local rootNames = {}
|
||||
for _, root in ipairs(last.chain ~= nil and last.chain.roots or {}) do
|
||||
rootNames[root.key] = tostring((last.titles or {})[root.name] or root.name)
|
||||
end
|
||||
for _, problem in ipairs(fresh) do
|
||||
local text = ADChainView.problemText(problem, last, textOf, nil, fmt)
|
||||
-- kædens navn foran, så to kæder der mangler samme vare kan skelnes
|
||||
local text = tostring(rootNames[problem.rootKey] or problem.rootKey) .. ": " .. ADChainView.problemText(problem, last, textOf, nil, fmt)
|
||||
Logging.info(ADChain.LOG_PREFIX .. "manglende led: %s", text)
|
||||
ADFieldJobs.notify(text, true)
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ ADChainView.TEXT_KEYS = {"spu_chain_empty", "spu_chain_approve", "spu_chain_dism
|
||||
"spu_chain_pause", "spu_chain_resume", "spu_chain_scanning", "spu_chain_rootOk", "spu_chain_rootError", "spu_chain_rootWaiting",
|
||||
"spu_chain_rootPaused", "spu_chain_rootSummary", "spu_chain_free", "spu_chain_switches", "spu_chain_gone", "spu_chain_col_item",
|
||||
"spu_chain_col_source", "spu_chain_col_perMonth", "spu_chain_col_status", "spu_chain_col_stock",
|
||||
"spu_chain_problem_buy", "spu_chain_problem_bottleneck", "spu_chain_problem_off", "spu_chain_problem_cycle"}
|
||||
"spu_chain_problem_buy", "spu_chain_problem_bottleneck", "spu_chain_problem_off", "spu_chain_problem_cycle", "spu_chain_problem_barn"}
|
||||
|
||||
local FLOW_KEYS = {ok = "spu_chain_flowOk", missing = "spu_chain_flowNone", stopped = "spu_chain_flowStopped", noVehicle = "spu_chain_flowMissing",
|
||||
pallet = "spu_chain_flowPallet"}
|
||||
@@ -148,7 +148,7 @@ local function producersOf(last, fillType)
|
||||
end
|
||||
|
||||
-- Årsag i klart sprog med råd for et problem fra kædemodellen ({kind="buy"|"bottleneck"|"cycle", fillType, rootKey,
|
||||
-- detail = manglende l/md, need = behov l/md}). En producent spilleren selv har slukket (last.userOff, stadig
|
||||
-- detail = manglende l/md, need = behov l/md}). Køb af en rest efter gårdens stalde -> stald-tekst. En producent spilleren selv har slukket (last.userOff, stadig
|
||||
-- slukket) slår igennem som "slukket af dig" — det er den reelle årsag, uanset om modellen så køb eller flaskehals.
|
||||
function ADChainView.problemText(problem, last, textOf, titleOf, fmt)
|
||||
last, textOf, fmt = last or {}, textOf or identity, fmt or ADChainView.compact
|
||||
@@ -171,6 +171,12 @@ function ADChainView.problemText(problem, last, textOf, titleOf, fmt)
|
||||
local made = math.max(0, need - (problem.detail or 0))
|
||||
return string.format(textOf("spu_chain_problem_bottleneck"), joinCapped(names), fmt(math.floor(made + 0.5)), fmt(math.floor(need + 0.5)))
|
||||
end
|
||||
-- modellen melder også "køb" for resten, når gårdens stalde leverer for lidt: så er rådet ikke "byg en fabrik"
|
||||
for _, herd in ipairs(last.data ~= nil and last.data.husbandry or {}) do
|
||||
if ((herd.outputs or {})[problem.fillType] or 0) > 0 then
|
||||
return string.format(textOf("spu_chain_problem_barn"), item)
|
||||
end
|
||||
end
|
||||
return string.format(textOf("spu_chain_problem_buy"), item)
|
||||
end
|
||||
|
||||
|
||||
@@ -611,6 +611,7 @@
|
||||
<text name="spu_attention_chainSuggests" text="Kæde: %d forslag"/>
|
||||
<text name="spu_attention_hintChain" text=" → klik: se Kæder"/>
|
||||
<text name="spu_chain_problem_buy" text="Ingen af dine fabrikker laver %s — byg en eller køb"/>
|
||||
<text name="spu_chain_problem_barn" text="Dine stalde leverer ikke nok %s — køb resten eller flere dyr"/>
|
||||
<text name="spu_chain_problem_bottleneck" text="%s kan kun lave %s af %s/md"/>
|
||||
<text name="spu_chain_problem_off" text="%s (%s) er slukket af dig — tænd den eller sæt kæden på pause"/>
|
||||
<text name="spu_chain_problem_cycle" text="Kredsløb omkring %s — kæden kan ikke beregnes"/>
|
||||
|
||||
@@ -611,6 +611,7 @@
|
||||
<text name="spu_attention_chainSuggests" text="Chain: %d suggestions"/>
|
||||
<text name="spu_attention_hintChain" text=" → click: see Chains"/>
|
||||
<text name="spu_chain_problem_buy" text="None of your factories makes %s — build one or buy it"/>
|
||||
<text name="spu_chain_problem_barn" text="Barns make too little %s — buy the rest or more animals"/>
|
||||
<text name="spu_chain_problem_bottleneck" text="%s can only make %s of %s/mo"/>
|
||||
<text name="spu_chain_problem_off" text="%s (%s) was turned off by you — turn it on or pause the chain"/>
|
||||
<text name="spu_chain_problem_cycle" text="Loop around %s — the chain cannot be calculated"/>
|
||||
|
||||
Reference in New Issue
Block a user