diff --git a/ChallengeModConfig.xml b/ChallengeModConfig.xml index 7cc9948..0ee9995 100644 --- a/ChallengeModConfig.xml +++ b/ChallengeModConfig.xml @@ -3,6 +3,7 @@ + diff --git a/scripts/VictoryPointManager.lua b/scripts/VictoryPointManager.lua index abb920f..038b1a3 100644 --- a/scripts/VictoryPointManager.lua +++ b/scripts/VictoryPointManager.lua @@ -177,9 +177,18 @@ end function VictoryPointManager:addMoneyFactor(category, factorData, farmId) local farm = g_farmManager:getFarmById(farmId) local money = farm and farm.money - farm.loan or 0 + -- prevents negative points if loan is higher than money + money = math.max(money, 0) category:addElement(VictoryPoint.createFromXml(factorData, money)) end +function VictoryPointManager:addLoanFactor(category, factorData, farmId) + local farm = g_farmManager:getFarmById(farmId) + local loan = farm and farm.loan or 0 + loan = -loan + category:addElement(VictoryPoint.createFromXml(factorData, loan)) +end + function VictoryPointManager:addAreaFactor(category, factorData, farmId) local area = VictoryPointsUtil.getTotalArea(farmId) category:addElement(VictoryPoint.createFromXml(factorData, area)) diff --git a/scripts/VictoryPointsUtil.lua b/scripts/VictoryPointsUtil.lua index 66bf621..b6fcd67 100644 --- a/scripts/VictoryPointsUtil.lua +++ b/scripts/VictoryPointsUtil.lua @@ -18,7 +18,7 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) if totalFillLevels[fillType] == nil then totalFillLevels[fillType] = 0 end - totalFillLevels[fillType] = totalFillLevels[fillType] + math.min(v, maxFillLevel) + totalFillLevels[fillType] = math.min(totalFillLevels[fillType] + v, maxFillLevel) end end end @@ -32,7 +32,21 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) if totalFillLevels[fillType] == nil then totalFillLevels[fillType] = 0 end - totalFillLevels[fillType] = totalFillLevels[fillType] + math.min(fillLevel, maxFillLevel) + totalFillLevels[fillType] = math.min(totalFillLevels[fillType] + fillLevel, maxFillLevel) + end + end + + if g_isModLoaded.FS22_ObjectStorage then + local objectStorages = g_objectStorageManager:getStorages() + + for _, storage in pairs(objectStorages) do + if storage.ownerFarmId == farmId then + for _, storageArea in pairs(storage.indexedStorageAreas) do + for _, objectAttributes in pairs(storageArea.objects) do + totalFillLevels[objectAttributes.fillType] = math.min(totalFillLevels[objectAttributes.fillType] + objectAttributes.fillLevel, maxFillLevel) + end + end + end end end @@ -58,7 +72,7 @@ function VictoryPointsUtil.getBaleAmount(farmId, maxFillLevel) if baleFillLevels[object.fillType] == nil then baleFillLevels[object.fillType] = 0 end - baleFillLevels[object.fillType] = baleFillLevels[object.fillType] + math.min(object.fillLevel, maxFillLevel) + baleFillLevels[object.fillType] = math.min(baleFillLevels[object.fillType] + object.fillLevel, maxFillLevel) end end return baleFillLevels @@ -77,7 +91,7 @@ function VictoryPointsUtil.getPalletAmount(farmId, maxFillLevel, totalFillLevels if totalFillLevels[fillType] == nil then totalFillLevels[fillType] = 0 end - totalFillLevels[fillType] = totalFillLevels[fillType] + math.min(fillLevel, maxFillLevel) + totalFillLevels[fillType] = math.min(totalFillLevels[fillType] + fillLevel, maxFillLevel) end end return totalFillLevels diff --git a/translations/translation_de.xml b/translations/translation_de.xml index d16beae..0053938 100644 --- a/translations/translation_de.xml +++ b/translations/translation_de.xml @@ -48,13 +48,13 @@ Eine Dauer von 0 Monaten deaktiviert das Zeitlimit." - + @@ -62,6 +62,7 @@ Eine Dauer von 0 Monaten deaktiviert das Zeitlimit." + diff --git a/translations/translation_en.xml b/translations/translation_en.xml index 6c5f372..1ca960b 100644 --- a/translations/translation_en.xml +++ b/translations/translation_en.xml @@ -54,6 +54,7 @@ A duration of 0 months will deactivate the time limit." + @@ -61,6 +62,7 @@ A duration of 0 months will deactivate the time limit." +