fix: græs/kløver/lucerne regnes med 3 slæt om året i kæde og Alt automatisk — 1.62.284
This commit is contained in:
@@ -21,14 +21,28 @@ function ADCropPlan.fieldProduct(field)
|
||||
return product
|
||||
end
|
||||
|
||||
-- Afgrøder der gror igen efter slæt (græs, kløver, lucerne) høstes flere gange om året; yields er ét slæt
|
||||
-- (in-game 17/10: hø-behov 207 ha -> 20 marker til græs). Forsigtigt skøn — hellere lidt for meget græs.
|
||||
ADCropPlan.REGROW_CUTS_PER_YEAR = 3
|
||||
|
||||
-- Høst pr. år for afgrøden (navn): 1, eller REGROW_CUTS_PER_YEAR når den gror igen. Ukendt = 1.
|
||||
function ADCropPlan.cutsPerYear(fruitName)
|
||||
-- vin, oliven, poppel gror også igen, men høstes én gang om året
|
||||
if ADChainData ~= nil and ADChainData.isPermanent ~= nil and ADChainData.isPermanent(fruitName) then return 1 end
|
||||
local fruit = g_fruitTypeManager ~= nil and fruitName ~= nil and g_fruitTypeManager:getFruitTypeByName(fruitName) or nil
|
||||
return fruit ~= nil and fruit.regrows == true and ADCropPlan.REGROW_CUTS_PER_YEAR or 1
|
||||
end
|
||||
|
||||
-- demand/stock/yields er pr. afgrøde, eller pr. markvare når products[nøgle] = {fruit, product} (hø = græs med
|
||||
-- produkt hø): så tæller kun marker med samme afgrøde OG produkt som udbud, og manglen bærer afgrøde + produkt.
|
||||
function ADCropPlan.shortages(demand, stock, fields, yields, products)
|
||||
-- cutsOf(afgrøde) -> høst pr. år (nil = ADCropPlan.cutsPerYear): udbyttet pr. ha og år = yields × høst.
|
||||
function ADCropPlan.shortages(demand, stock, fields, yields, products, cutsOf)
|
||||
local list = {}
|
||||
local cutsFor = cutsOf or ADCropPlan.cutsPerYear
|
||||
for key, perMonth in pairs(demand or {}) do
|
||||
local perHa = (yields or {})[key] or 0
|
||||
local spec = (products or {})[key]
|
||||
local fruit, product = spec ~= nil and spec.fruit or key, spec ~= nil and spec.product or nil
|
||||
local perHa = ((yields or {})[key] or 0) * math.max(1, cutsFor(fruit) or 1)
|
||||
if perHa > 0 and (perMonth or 0) > 0 then
|
||||
local need = perMonth * ADCropPlan.HORIZON_MONTHS
|
||||
local supply = (stock or {})[key] or 0
|
||||
|
||||
Reference in New Issue
Block a user