added inflation factor (estimated to 3% a year) as requested in https://www.tt-forums.net/viewtopic.php?t=73249#p1182135 and mentioned as an issue in https://dev.openttdcoop.org/issues/8407 - hopefully it works as expected.

This commit is contained in:
2017-06-27 17:56:13 +02:00
parent eaa1ae11cc
commit ebf7f0f46b
3 changed files with 32 additions and 16 deletions

View File

@@ -29,7 +29,8 @@ class CompanyGoal {
subsidyfactor = GSController.GetSetting("subsidy_factor");
rewardfactor_town = GSController.GetSetting("rewardfactor_town");
rewardfactor_ind = GSController.GetSetting("rewardfactor_ind");
inflation_factor = 1.0;
displayed_string = null;
displayed_count = null;
@@ -42,7 +43,19 @@ class CompanyGoal {
this.cargo = cargo;
this.accept = accept;
this.wanted_amount = wanted_amount;
this.reward = (this.wanted_amount * subsidyfactor) / 100; // estimated factor, better would be a random value
local inflationOn = GSGameSettings.GetValue("inflation");
if (inflationOn) {
local gamets = GSDate.GetCurrentDate();
local starting_year = GSGameSettings.GetValue("starting_year");
local gameyears = GSDate.GetYear(gamets) - starting_year;
inflation_factor = 1.0 + (gameyears * 0.03); // calculate new inflation factor; estimate 3% each year
}
local inflation_percent = inflation_factor * 100;
this.reward = (this.wanted_amount * subsidyfactor * inflation_factor) / 100; // estimated factor, better would be a random value
this.ResetTimeout();
// Construct goal if a company id was provided.
@@ -62,6 +75,9 @@ class CompanyGoal {
this.reward = (this.reward * rewardfactor_ind) / 100;
}
local goal_text, goal_news_text;
this.reward = this.reward.tointeger();
if (this.reward > 0) {
goal_text = GSText(GSText.STR_COMPANY_GOAL_REWARD, cargo.cid, this.wanted_amount, destination_string, this.reward);
goal_news_text = GSText(GSText.STR_COMPANY_GOAL_REWARD_NEWS, cargo.cid, this.wanted_amount, destination_string_news, this.reward);