Skip to content

Commit

Permalink
v1.2.6.5
Browse files Browse the repository at this point in the history
add setting "toDeliver": harvest contract success factor
  • Loading branch information
Mmtrx committed Jan 18, 2023
1 parent 0bfa3ef commit 8bcac1d
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 3 deletions.
9 changes: 9 additions & 0 deletions betterContracts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
-- v1.2.6.1 05.12.2022 initGui(): utf8ToUpper(). Addtnl l10n translations from github
-- v1.2.6.2 16.12.2022 don't act onFarmlandStateChanged() before mission started. Smaller menu icon
-- v1.2.6.3 02.01.2023 onClickBuyFarmland, missionVehicles (userdefined) fixed
-- v1.2.6.4 17.01.2023 fix issue #88: onClickBuyFarmland() if discountMode off
-- v1.2.6.5 18.01.2023 add setting "toDeliver": harvest contract success factor
--=======================================================================================================
SC = {
FERTILIZER = 1, -- prices index
Expand Down Expand Up @@ -173,6 +175,7 @@ function registerXML(self)
self.xmlSchema:register(XMLValueType.INT, self.baseXmlKey.."#refreshMP")
self.xmlSchema:register(XMLValueType.FLOAT, self.baseXmlKey.."#reward")
self.xmlSchema:register(XMLValueType.FLOAT, self.baseXmlKey.."#lease")
self.xmlSchema:register(XMLValueType.FLOAT, self.baseXmlKey.."#deliver")

local key = self.baseXmlKey..".lazyNPC"
self.xmlSchema:register(XMLValueType.BOOL, key.."#harvest")
Expand Down Expand Up @@ -204,6 +207,7 @@ function readconfig(self)
self.config.maxActive = xmlFile:getValue(key.."#maxActive", 3)
self.config.multReward= xmlFile:getValue(key.."#reward", 1.)
self.config.multLease = xmlFile:getValue(key.."#lease", 1.)
self.config.toDeliver = xmlFile:getValue(key.."#deliver", 0.93)
self.config.refreshMP = xmlFile:getValue(key.."#refreshMP", 2)
self.config.lazyNPC = xmlFile:getValue(key.."#lazyNPC", false)
self.config.hardMode = xmlFile:getValue(key.."#hard", false)
Expand Down Expand Up @@ -380,6 +384,7 @@ function BetterContracts:initialize()
maxActive = 3, -- max active contracts
multReward = 1., -- general reward multiplier
multLease = 1., -- general lease cost multiplier
toDeliver = 0.93, -- HarvestMission.SUCCESS_FACTOR
refreshMP = SC.ADMIN, -- necessary permission to refresh contract list (MP)
lazyNPC = false, -- adjust NPC field work activity
hardMode = false, -- penalty for canceled missions
Expand Down Expand Up @@ -534,6 +539,9 @@ function BetterContracts:onPostLoadMap(mapNode, mapFile)
addConsoleCommand("gsMissionHarvestField", "Harvest a field and print the liters", "consoleHarvestField", g_missionManager)
addConsoleCommand("gsMissionTestHarvests", "Run an expansive tests for harvest missions", "consoleHarvestTests", g_missionManager)
end
-- init HarvestMission.SUCCESS_FACTOR
HarvestMission.SUCCESS_FACTOR = self.config.toDeliver

-- adjust max missions
local fieldsAmount = table.size(g_fieldManager.fields)
local adjustedFieldsAmount = math.max(fieldsAmount, 45)
Expand Down Expand Up @@ -587,6 +595,7 @@ function BetterContracts:onPostSaveSavegame(saveDir, savegameIndex)
xmlFile:setInt ( key.."#maxActive",conf.maxActive)
xmlFile:setFloat( key.."#reward", conf.multReward)
xmlFile:setFloat( key.."#lease", conf.multLease)
xmlFile:setFloat( key.."#deliver", conf.toDeliver)
xmlFile:setInt ( key.."#refreshMP",conf.refreshMP)
xmlFile:setBool ( key.."#lazyNPC", conf.lazyNPC)
xmlFile:setBool ( key.."#discount", conf.discountMode)
Expand Down
3 changes: 3 additions & 0 deletions l10n/l10n_br.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,8 @@
<text name="bc_discPerJob_tooltip" text="Um fazendeiro NPC aumenta seu desconto por esse valor por trabalho concluído. O desconto máximo não pode ultrapassar 50%." />
<text name="bc_discMaxJobs" text="Número de trabalhos efetivos com desconto" />
<text name="bc_discMaxJobs_tooltip" text="Pode reduzir o desconto máximo, por ex. desconto por contrato = 11%, número de trabalhos = 3 -> desconto máximo = 33%. Cuidado: o número atual de trabalhos concluídos diminuirá neste valor na compra de terras agrícolas." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions l10n/l10n_cs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@
<text name="bc_discPerJob_tooltip" text="每完成一项任务,农户NPC就会增加相应的折扣。最高折扣不能超过50%。" />
<text name="bc_discMaxJobs" text="影响折扣的任务数量" />
<text name="bc_discMaxJobs_tooltip" text="将会减少最大的折扣,例如:每个合同的折扣为11%,任务的数量为3,则最大折扣为33%。注意:在购买农田时,当前完成的工作数量将被这个值减少。" />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions l10n/l10n_cz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
<text name="bc_discPerJob_tooltip" text="NPC farmář zvyšuje svou slevu o tuto částku za dokončenou práci. Maximální sleva nesmí přesáhnout 50 %." />
<text name="bc_discMaxJobs" text="Počet zakázek se slevou" />
<text name="bc_discMaxJobs_tooltip" text="Může snížit maximální slevu, např. sleva na smlouvu = 11 %, počet smluv = 3 -> max. sleva = 33 %. Upozornění: Aktuální počet dokončených úloh se při nákupu zemědělské půdy sníží o tuto hodnotu." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
2 changes: 2 additions & 0 deletions l10n/l10n_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
<text name="bc_leaseMultiplier_tooltip" text="Passt die Kosten für bei Verträgen angebotene Leihgeräte an." />
<text name="bc_maxActive" text="Gleichzeitig aktive Verträge" />
<text name="bc_maxActive_tooltip" text="Maximalzahl der gleichzeitig erlaubten aktiven Verträge" />
<text name="bc_toDeliver" text="Lieferanteil Ernteverträge" />
<text name="bc_toDeliver_tooltip" text="Pozentsatz des theoretisch möglichen Ertrags, der zur Erfüllung eines Erntevertrags abgeliefert werden muss." />
<text name="bc_refreshMP" text="Berechtigung Vertragsliste" />
<text name="bc_refreshMP_tooltip" text="Wer in einem MP-Spiel Verträge löschen/ erzeugen darf" />
<text name="bc_debug" text="Debug Modus" />
Expand Down
2 changes: 2 additions & 0 deletions l10n/l10n_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
<text name="bc_leaseMultiplier_tooltip" text="Adjust the cost for borrowing equipment for contracts." />
<text name="bc_maxActive" text="Concurrently active contracts" />
<text name="bc_maxActive_tooltip" text="Max number of concurrently active contracts." />
<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
<text name="bc_refreshMP" text="Permission contracts list" />
<text name="bc_refreshMP_tooltip" text="Who can delete / refresh contracts in an MP game." />
<text name="bc_debug" text="Debug Modus" />
Expand Down
3 changes: 3 additions & 0 deletions l10n/l10n_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
<text name="bc_discPerJob_tooltip" text="An NPC farmer increases their discount by this amount per job completed. Maximum discount cannot rise above 50%." />
<text name="bc_discMaxJobs" text="Number of discount-effective jobs" />
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions l10n/l10n_it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
<text name="bc_discPerJob_tooltip" text="An NPC farmer increases their discount by this amount per job completed. Maximum discount cannot rise above 50%." />
<text name="bc_discMaxJobs" text="Number of discount-effective jobs" />
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions l10n/l10n_jp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
<text name="bc_discPerJob_tooltip" text="An NPC farmer increases their discount by this amount per job completed. Maximum discount cannot rise above 50%." />
<text name="bc_discMaxJobs" text="Number of discount-effective jobs" />
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions l10n/l10n_pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@
<text name="bc_discPerJob_tooltip" text="An NPC farmer increases their discount by this amount per job completed. Maximum discount cannot rise above 50%." />
<text name="bc_discMaxJobs" text="Number of discount-effective jobs" />
<text name="bc_discMaxJobs_tooltip" text="Can reduce the max discount, e.g. discount per contract = 11%, number of jobs = 3 -> max discount = 33%. Caution: Current number of jobs complete will decrease by this value on a farmland purchase." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
3 changes: 3 additions & 0 deletions l10n/l10n_ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,8 @@
<text name="bc_discPerJob_tooltip" text="NPC-фермер увеличивает свою скидку на эти проценты за выполненную работу. Максимальная скидка не может превышать 50%." />
<text name="bc_discMaxJobs" text="Количество заданий с эффективными скидками" />
<text name="bc_discMaxJobs_tooltip" text="Можно изменить максимальную скидку: скидка за контракт = 11%, количество заданий = 3 -> максимальная скидка = 33%. Внимание: Текущее количество выполненных работ уменьшится на это значение при покупке участков." />

<text name="bc_toDeliver" text="Delivery on harvest contracts" />
<text name="bc_toDeliver_tooltip" text="Percentage of the estimated total yield you must deliver to complete a harvest contract." />
</texts>
</l10n>
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<modDesc descVersion="72">
<author>Mmtrx</author>
<version>1.2.6.4</version>
<version>1.2.6.5</version>
<title>
<en>Better Contracts</en>
</title>
Expand Down
20 changes: 18 additions & 2 deletions scripts/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- Author: Mmtrx
-- Changelog:
-- v1.2.6.0 30.11.2022 UI for all settings
-- v1.2.6.5 18.01.2023 add setting "toDeliver": harvest contract success factor
--=======================================================================================================
local function lazyNPCDisabled()
return not BetterContracts.config.lazyNPC
Expand Down Expand Up @@ -39,9 +40,20 @@ BCSettingsBySubtitle = {
{name = "maxActive",
values = {0,1,2, 3, 4, 5, 6, 7, 8, 9, 10},
texts = {"unlimited", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"},
default = 4,
default = 1,
title = "bc_maxActive",
tooltip = "bc_maxActive_tooltip",
noTranslate = true
},
{name = "toDeliver",
values = {.85,.87,.89,.91,.93},
texts = {"85 %","87 %","89 %","91 %","standard"},
default = 5,
title = "bc_toDeliver",
tooltip = "bc_toDeliver_tooltip",
actionFunc = function(self,ix)
HarvestMission.SUCCESS_FACTOR = self.values[ix]
end,
noTranslate = true
},
{name = "refreshMP",
Expand Down Expand Up @@ -214,6 +226,7 @@ function BCsetting.new(data, customMt)
-- index of the previous value/text
self.previous = 1
self.isDisabledFunc = data.isDisabledFunc
self.actionFunc = data.actionFunc
self.guiElement = nil
return self
end
Expand All @@ -225,7 +238,7 @@ function BCsetting.init(bc)
local setting = BCsetting.new(data)
setting:setValue(bc.config[setting.name])
table.insert(settings, setting)
bc.settingsByName[setting.name] = setting -- do we still need this?
bc.settingsByName[setting.name] = setting -- needed for SettingsEvent:readStream()
end
end
return settings
Expand Down Expand Up @@ -273,6 +286,9 @@ function BCsetting:setIx(ix)
self.previous = self.current
self.current = ix
conf[self.name] = self.values[ix]
if self.actionFunc ~= nil then
self:actionFunc(ix)
end
debugPrint("** %s set to %s **", self.name,self.values[ix])
end
end
Expand Down

0 comments on commit 8bcac1d

Please sign in to comment.