/* Public methods */ /** * Is this a Company Value GS game? * @return true, if the game has a GS that respond to Company Value GS * commands, otherwise false. * @note If you call this method to early, it will return false even if * the game has the Company Value GS with SCP activated because a round-trip * has not yet been completed. */ function IsCompanyValueGSGame(); /** * Is Company Value GS running in Goal mode? * In this mode, companies are competing to become the first to reach a * company value target. See GetCurrentTargetValue to get the value. * @return true, if Company Value GS is running in Goal mode. * @note When it returns false, it doesn't necessarily mean that Company Value GS * is running in Ranking mode. * @note When the target value is reached by one of the companies, Company Value GS * pauses the game, and switches from Goal mode to Ranking mode after a user presses * the "Continue" button. Note that AIs are unable to respond when the game is paused. */ function IsCompanyValueGSInGoalMode(); /** * Is Company Value GS running in Ranking mode? * In this mode, companies are competing between each other to be the most * valuable company at all times. See GetBestCompanyValue to get the value. * @return true, if Company Value GS is running in Ranking mode. * @note When it returns false, it doesn't necessarily mean that Company Value GS * is running in Goal mode. */ function IsCompanyValueGSInRankingMode(); /** * Get the Company ID of the current most valuable company. * @return CompanyID of the company with the highest value at the moment. * @note Returns AICompany.COMPANY_INVALID when Company Value GS SCP isn't active, * or when no companies are found (shouldn't happen, because we're a company too). */ function GetBestCompanyID(); /** * Get the value of the current most valuable company. * @return integer value of the company with the best value at the moment. * @note Returns -1 when Company Value GS SCP isn't active, or when no companies * are found (shouldn't happen, because we're a company too). */ function GetBestCompanyValue(); /** * Get the current targetted value to be reached. * In Goal mode, the value is defined in the Company Value GS settings. * In Ranking mode, the value is that of the current most valuable company. * @return integer value of the current target to be reached. * @note Returns -1 when Company Value GS SCP isn't active, or when no companies * are found (shouldn't happen, because we're a company too). */ function GetCurrentTargetValue(); /** * Get the rank position of the provided Company ID from a list of running * companies with their respective company values. * @return integer position of provided company in relation to the * others regarding their company value. * @note The rank at the top has a value of 1. The rank at the bottom has a value * dependant on the number of companies running in the game. * @note Returns -1 when the provided Company ID is invalid, or when no companies * are found (shouldn't happen, because we're a company too). */ function GetCompanyIDRank(company_id); } /**** Public API methods: ****/ function SCPClient_CompanyValueGS::IsCompanyValueGSGame() { if (this._scp == null) return false; return this._company_value_gs_game == true; } function SCPClient_CompanyValueGS::IsCompanyValueGSInGoalMode() { if (this._scp == null) return false; return this._goal_mode == true; } function SCPClient_CompanyValueGS::IsCompanyValueGSInRankingMode() { if (this._scp == null) return false; return this._goal_mode == false; } function SCPClient_CompanyValueGS::GetBestCompanyID() { if (this._scp == null) return AICompany.COMPANY_INVALID; if (this._company_value_gs_game != true) return AICompany.COMPANY_INVALID; local best_company_id = AICompany.COMPANY_INVALID; local best_company_value = -1; for (local c_id = AICompany.COMPANY_FIRST; c_id < AICompany.COMPANY_LAST; c_id++) { if (AICompany.ResolveCompanyID(c_id) != AICompany.COMPANY_INVALID) { local c_value = AICompany.GetQuarterlyCompanyValue(c_id, AICompany.CURRENT_QUARTER); if (c_value >= best_company_value) { best_company_id = c_id; best_company_value = c_value; } } } return best_company_id; } function SCPClient_CompanyValueGS::GetBestCompanyValue() { if (this._scp == null) return -1; if (this._company_value_gs_game != true) return -1; local best_company_value = -1; for (local c_id = AICompany.COMPANY_FIRST; c_id < AICompany.COMPANY_LAST; c_id++) { if (AICompany.ResolveCompanyID(c_id) != AICompany.COMPANY_INVALID) { local c_value = AICompany.GetQuarterlyCompanyValue(c_id, AICompany.CURRENT_QUARTER); if (c_value >= best_company_value) { best_company_value = c_value; } } } return best_company_value; } function SCPClient_CompanyValueGS::GetCurrentTargetValue() { if (this._scp == null) return -1; if (this._company_value_gs_game != true) return -1; if (this._goal_mode == true) return this._goal_value; return this.GetBestCompanyValue(); } function SCPClient_CompanyValueGS::GetCompanyIDRank(company_id) { if (this._scp == null) return -1; if (this._company_value_gs_game != true) return -1; if (AICompany.ResolveCompanyID(company_id) == AICompany.COMPANY_INVALID) return -1; local global_list = AIList(); for (local c_id = AICompany.COMPANY_FIRST; c_id < AICompany.COMPANY_LAST; c_id++) { if (AICompany.ResolveCompanyID(c_id) != AICompany.COMPANY_INVALID) { local c_value = AICompany.GetQuarterlyCompanyValue(c_id, AICompany.CURRENT_QUARTER); global_list.AddItem(c_id, c_value); } } global_list.Sort(AIList.SORT_BY_VALUE, AIList.SORT_DESCENDING); local rank = 0; for (local c_id = global_list.Begin(); !global_list.IsEnd(); c_id = global_list.Next()) { rank++; if (c_id == company_id) { return rank; } } return -1; }