49 lines
1.9 KiB
Lua
49 lines
1.9 KiB
Lua
-- AD Field View
|
|
-- Rene regler for fanen Marker: rækkefølge, statusord, planens tekst og jordtilstand. GUI'et oversætter
|
|
-- nøglerne.
|
|
|
|
ADFieldView = {}
|
|
|
|
-- Alle gårdens marker (slåafgrøder, høstafgrøder og bare), sorteret efter marknummer.
|
|
function ADFieldView.rows(infos, fieldsById)
|
|
local rows = {}
|
|
for _, info in ipairs(infos or {}) do
|
|
table.insert(rows, {info = info, field = fieldsById[info.id] or ADFieldModel.newField(info.id)})
|
|
end
|
|
table.sort(rows, function(a, b) return a.info.id < b.info.id end)
|
|
return rows
|
|
end
|
|
|
|
function ADFieldView.statusKey(field, info)
|
|
if info.markerId == nil then
|
|
return "spu_field_noMarker"
|
|
end
|
|
return "spu_field_stage_" .. tostring(field.stage)
|
|
end
|
|
|
|
-- Planens tekstnøgle ud fra markens art: ensilage/hø for slåafgrøder, høst, eller klargøring (bar mark).
|
|
function ADFieldView.planKey(plan, kind)
|
|
if kind == "bare" then return "spu_field_plan_prep" end
|
|
return "spu_field_plan_" .. ADFieldModel.product(plan, kind)
|
|
end
|
|
|
|
-- Hvad jorden trænger til, som korte nøgler i fast rækkefølge: kalk, pløj, gødning, ukrudt.
|
|
function ADFieldView.soilParts(info)
|
|
local parts = {}
|
|
local needs = info.needs or {}
|
|
if needs.lime then table.insert(parts, "lime") end
|
|
if needs.plow then table.insert(parts, "plow") end
|
|
if info.fert ~= nil and info.fertMax ~= nil and info.fert < info.fertMax then table.insert(parts, "fert") end
|
|
if (info.weed or 0) >= ADFieldModel.WEED_MIN then table.insert(parts, "weed") end
|
|
return parts
|
|
end
|
|
|
|
-- Afgrødekolonnen: høstet mark = "stub (Hvede)", bar mark = "bar jord", ellers afgrøden.
|
|
function ADFieldView.cropText(info, getText)
|
|
if info.kind == "bare" and info.stubbleOf ~= nil then
|
|
return string.format(getText("spu_field_stubble"), tostring(info.stubbleOf))
|
|
end
|
|
if info.kind == "bare" then return getText("spu_field_bare") end
|
|
return tostring(info.cropTitle or "-")
|
|
end
|