feat: v1.12.1.0 — prisregel via sæsonkurven, reserve til gårdens eget forbrug, paller til palleskur, fanen Lagre (idéer fra Distribution Redux)
This commit is contained in:
@@ -199,5 +199,82 @@ check("S9 fabrik foretrækkes frem for objektlager i nærheden", ADSources.ident
|
||||
local excluded = ADSources.getSourcePlaceables({source1, source2})
|
||||
check("S8 udelukkede placeables", excluded[factory] and excluded[silo], true)
|
||||
|
||||
-- S10 (paller til lager): objektlager med plads der tager varen; nærmeste nåelige fra traktoren
|
||||
objectStorage.getObjectStorageSupportsFillType = function(self, ft) return ft == BASKET or ft == FORAGE end
|
||||
check("S10 tager kurve", ADSources.objectStorageAccepts(objectStorage, BASKET), true)
|
||||
check("S10 tager ikke sukker", ADSources.objectStorageAccepts(objectStorage, SUGAR), false)
|
||||
check("S10 fri pladser", ADSources.objectStorageFreeSlots(objectStorage), 3990)
|
||||
local fullShed = {rootNode = {x = 700, z = 700}, spec_objectStorage = {capacity = 10, numStoredObjects = 10, objectInfos = {}}, getName = function() return "Fuldt skur" end}
|
||||
table.insert(g_currentMission.placeableSystem.placeables, fullShed)
|
||||
addMarker(8, "Fuldt skur", 700, 690)
|
||||
check("S10 fuldt skur 0 pladser", ADSources.objectStorageFreeSlots(fullShed), 0)
|
||||
local truck = {rootNode = {x = 650, z = 650}}
|
||||
local store = ADSources.findPalletStore(adEnv, truck, BASKET, {}, function() return true end, 1)
|
||||
check("S10 nærmeste med plads = Objektlager (skuret er fuldt)", store.wayPointId, 3)
|
||||
check("S10 navn", store.name, "Objektlager")
|
||||
check("S10 udelukket kilde -> nil", ADSources.findPalletStore(adEnv, truck, BASKET, {[objectStorage] = true}, function() return true end, 1), nil)
|
||||
check("S10 uopnåelig -> nil", ADSources.findPalletStore(adEnv, truck, BASKET, {}, function() return false end, 1), nil)
|
||||
check("S10 sukker: intet skur tager det", ADSources.findPalletStore(adEnv, truck, SUGAR, {}, function() return true end, 1), nil)
|
||||
|
||||
-- S11 (reserve): gårdens forbrug det næste døgn af en vare, minus hvad forbrugerne allerede har
|
||||
local BEET, STRAW, WATER = 9, 10, 11
|
||||
DESC[BEET] = {index = BEET, name = "SUGARBEET", title = "Roer"}; DESC[STRAW] = {index = STRAW, name = "STRAW", title = "Halm"}; DESC[WATER] = {index = WATER, name = "WATER", title = "Vand"}
|
||||
local tmrStorage = storageOf({[BEET] = 20000, [FORAGE] = 500000}, {[BEET] = 2500000, [FORAGE] = 3500000})
|
||||
local tmrFactory = {
|
||||
rootNode = {x = 800, z = 800}, ownerFarmId = 1, getOwnerFarmId = function() return 1 end, getName = function() return "TMR-fabrik" end,
|
||||
spec_productionPoint = {productionPoint = {
|
||||
productions = {{id = "tmr3", cyclesPerMinute = 200 / 60, inputs = {{type = BEET, amount = 45}}, outputs = {{type = FORAGE, amount = 240}}}},
|
||||
storage = tmrStorage,
|
||||
getIsProductionEnabled = function(self, id) return id == "tmr3" end,
|
||||
}},
|
||||
}
|
||||
local cowBarn = {
|
||||
rootNode = {x = 900, z = 900}, ownerFarmId = 1, getOwnerFarmId = function() return 1 end, getName = function() return "Kostald" end,
|
||||
spec_husbandryStraw = {inputLitersPerHour = 500}, spec_husbandryWater = {litersPerHour = 100, automaticWaterSupply = true},
|
||||
getHusbandryIsFillTypeSupported = function(self, ft) return ft == STRAW or ft == WATER end,
|
||||
getHusbandryFillLevel = function(self, ft) return ft == STRAW and 2000 or 0 end,
|
||||
getHusbandryFreeCapacity = function(self, ft) return ft == STRAW and 19375 or 0 end,
|
||||
}
|
||||
local otherFarmBarn = {rootNode = {x = 950, z = 950}, ownerFarmId = 2, getOwnerFarmId = function() return 2 end, spec_husbandryStraw = {inputLitersPerHour = 500}, getHusbandryIsFillTypeSupported = function() return true end, getHusbandryFillLevel = function() return 0 end, getHusbandryFreeCapacity = function() return 99999 end}
|
||||
table.insert(g_currentMission.placeableSystem.placeables, tmrFactory)
|
||||
table.insert(g_currentMission.placeableSystem.placeables, cowBarn)
|
||||
table.insert(g_currentMission.placeableSystem.placeables, otherFarmBarn)
|
||||
local demand = ADSources.getFarmDemand(adEnv, BEET, 1, {})
|
||||
-- 45 l × (200/60) pr. min × 1440 min = 216.000 l/døgn; har 20.000 -> 196.000
|
||||
check("S11 roer: døgnforbrug minus beholdning", demand.liters, 196000)
|
||||
check("S11 forbruger-navn", demand.consumers[1], "TMR-fabrik")
|
||||
local strawDemand = ADSources.getFarmDemand(adEnv, STRAW, 1, {})
|
||||
-- 500 l/t × 24 = 12.000; har 2.000 -> 10.000 (under fri plads 19.375)
|
||||
check("S11 halm: stald", strawDemand.liters, 10000)
|
||||
check("S11 anden farm tæller ikke", #strawDemand.consumers, 1)
|
||||
check("S11 automatisk vand = intet behov", ADSources.getFarmDemand(adEnv, WATER, 1, {}).liters, 0)
|
||||
check("S11 output er ikke behov", ADSources.getFarmDemand(adEnv, FORAGE, 1, {}).liters, 0)
|
||||
check("S11 udelukket forbruger", ADSources.getFarmDemand(adEnv, BEET, 1, {[tmrFactory] = true}).liters, 0)
|
||||
tmrStorage.fillLevels[BEET] = 300000
|
||||
check("S11 nok på lager -> 0", ADSources.getFarmDemand(adEnv, BEET, 1, {}).liters, 0)
|
||||
tmrStorage.fillLevels[BEET] = 20000
|
||||
tmrFactory.spec_productionPoint.productionPoint.getIsProductionEnabled = function() return false end
|
||||
check("S11 slukket produktion -> 0", ADSources.getFarmDemand(adEnv, BEET, 1, {}).liters, 0)
|
||||
|
||||
-- S12 (inventar): alt gården har liggende, pr. bygning, kun bygninger med indhold
|
||||
factory.ownerFarmId = 1; silo.ownerFarmId = 1; objectStorage.ownerFarmId = 1
|
||||
local inventory = ADSources.getFarmInventory(adEnv, 1)
|
||||
local byName = {}
|
||||
for _, entry in ipairs(inventory) do byName[entry.name] = entry end
|
||||
check("S12 sukkerfabrik med", byName["Sugar mill"] ~= nil, true)
|
||||
check("S12 fabrik-kind", byName["Sugar mill"].kind, "factory")
|
||||
check("S12 fabrik sukker", byName["Sugar mill"].entries[1].level, 150000)
|
||||
check("S12 fabrik sukker er output", byName["Sugar mill"].entries[1].isOutput, true)
|
||||
local beetEntry
|
||||
for _, e in ipairs(byName["TMR-fabrik"].entries) do if e.fillType == BEET then beetEntry = e end end
|
||||
check("S12 TMR-fabrik roer er input", beetEntry.isOutput, false)
|
||||
check("S12 outputs først", byName["TMR-fabrik"].entries[1].isOutput, true)
|
||||
check("S12 silo", byName["Farma"].entries[1].fillType, FORAGE)
|
||||
check("S12 objektlager kurve som antal", byName["Objektlager"].entries[1].count, 8)
|
||||
check("S12 stald halm", byName["Kostald"].entries[1].level, 2000)
|
||||
check("S12 stald kapacitet = niveau + fri", byName["Kostald"].entries[1].capacity, 21375)
|
||||
check("S12 tomt skur udeladt", byName["Fuldt skur"], nil)
|
||||
check("S12 anden farm udeladt", #inventory, 5)
|
||||
|
||||
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
||||
os.exit(failures == 0 and 0 or 1)
|
||||
|
||||
Reference in New Issue
Block a user