From 5e6c171e7d32850c70665267a52bd69fae9bfb1f Mon Sep 17 00:00:00 2001 From: Alberth Date: Thu, 1 Jan 2015 20:25:13 +0100 Subject: [PATCH] Add: Setting for the number of goals of a company. --- company.nut | 3 ++- info.nut | 18 ++++++++++++++++-- main.nut | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/company.nut b/company.nut index dbb9256..f3393b9 100644 --- a/company.nut +++ b/company.nut @@ -210,7 +210,8 @@ class CompanyData { this.active_goals = {}; this.comp_id = comp_id; - for (local num = 0; num < 5; num += 1) this.active_goals[num] <- null; + local num_goals = GSController.GetSetting("num_goals"); + for (local num = 0; num < num_goals; num += 1) this.active_goals[num] <- null; } function FinalizeCompany(); diff --git a/info.nut b/info.nut index 05277ea..0235890 100644 --- a/info.nut +++ b/info.nut @@ -17,7 +17,7 @@ * Fifth Floor, Boston, MA 02110-1301 USA. */ -class BusyBeeClass extends GSInfo { +class BusyBeeInfo extends GSInfo { function GetAuthor() { return "alberth & andythenorth"; } function GetName() { return "BusyBee"; } function GetDescription() { return "Goal: Have fun"; } @@ -27,6 +27,20 @@ class BusyBeeClass extends GSInfo { function GetShortName() { return "BBEE"; } function GetAPIVersion() { return "1.5"; } function GetUrl() { return ""; } + function GetSettings(); } -RegisterGS(BusyBeeClass()); +function BusyBeeInfo::GetSettings() +{ + GSInfo.AddSetting({name="num_goals", + description="Number of goals for a company", + min_value=1, + max_value=10, + easy_value=5, + medium_value=5, + hard_value=5, + custom_value=5, + flags=GSInfo.CONFIG_NONE}); +} + +RegisterGS(BusyBeeInfo()); diff --git a/main.nut b/main.nut index ca6ff0a..cfb048d 100644 --- a/main.nut +++ b/main.nut @@ -376,7 +376,7 @@ function BusyBeeClass::Start() // GSGoal.Question(1, GSCompany.COMPANY_INVALID, lake_news, GSGoal.QT_INFORMATION, GSGoal.BUTTON_GO); // Sleep until the next event. - local delay_time = 5 * 74; // Check events every 2 days. + local delay_time = 5 * 74; // Check events every 5 days. if (delay_time > new_goal_timeout) delay_time = new_goal_timeout; if (delay_time > monitor_timeout) delay_time = monitor_timeout; if (delay_time > finished_timeout) delay_time = finished_timeout;