rubidium@9374: /* $Id$ */ rubidium@9374: rubidium@9374: /** @file ai_company.hpp Everything to query a company's financials and statistics */ rubidium@9374: rubidium@9374: #ifndef AI_COMPANY_HPP rubidium@9374: #define AI_COMPANY_HPP rubidium@9374: rubidium@9374: #include "ai_object.hpp" rubidium@9374: truelight@9447: /** truelight@9447: * Class that handles all company related functions. truelight@9447: */ rubidium@9374: class AICompany : public AIObject { rubidium@9374: public: rubidium@9374: /** truelight@9529: * The name of the class, needed by several sub-processes. truelight@9529: */ truelight@9529: static const char *GetClassName() { return "AICompany"; } truelight@9529: rubidium@9668: /** Different constants related to companies */ rubidium@9668: enum CompanyIndex { rubidium@9668: FIRST_COMPANY = 0, ///< The first available company. rubidium@9668: LAST_COMPANY = 7, ///< The last available company. rubidium@9668: MY_COMPANY = 8, ///< Constant that gets resolved to the correct company index for your company. rubidium@9668: INVALID_COMPANY = 9, ///< An invalid company rubidium@9668: }; rubidium@9668: rubidium@9668: /** rubidium@9668: * Resolved the given company index to the correct index rubidium@9668: * for the company. If the company index was MY_COMPANY rubidium@9668: * it will be resolved to the index of your company. rubidium@9668: * If the company with the given index does not exist rubidium@9668: * it will return INVALID_COMPANY. rubidium@9668: * @param company the company index to resolve. rubidium@9668: * @return the resolved company index. rubidium@9668: */ truebrain@9737: static CompanyIndex ResolveCompanyIndex(CompanyIndex company); rubidium@9668: truelight@9529: /** truelight@9447: * Set the name of your company. truelight@9447: * @param name the new name of the company. rubidium@9374: * @pre name != NULL truelight@9575: * @return true if the name was changed. rubidium@9374: */ truebrain@9737: static bool SetCompanyName(const char *name); rubidium@9374: rubidium@9374: /** rubidium@9668: * Get the name of the given company. rubidium@9668: * @param company the company to get the name for. rubidium@9668: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY rubidium@9668: * @return the name of the given company. truelight@9447: * @note the returned company name must be free'd (C++ only). rubidium@9374: */ truebrain@9737: static char *GetCompanyName(CompanyIndex company); rubidium@9374: rubidium@9374: /** truelight@9575: * Set the name of your president. truelight@9575: * @param name the new name of the president. truelight@9575: * @pre name != NULL truelight@9575: * @return true if the name was changed. truelight@9575: */ truebrain@9737: static bool SetPresidentName(const char *name); truelight@9575: truelight@9575: /** rubidium@9668: * Get the name of the president of the given company. rubidium@9668: * @param company the company to get the president's name for. rubidium@9668: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY rubidium@9668: * @return the name of the president of the given company. truelight@9575: * @note the returned president name must be free'd (C++ only). truelight@9575: */ truebrain@9737: static char *GetPresidentName(CompanyIndex company); truelight@9575: truelight@9575: /** rubidium@9668: * Gets the current value of the given company. rubidium@9668: * @param company the company to get the company value of. rubidium@9668: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY rubidium@9668: * @return the current value of the given company. rubidium@9374: */ truebrain@9737: static int32 GetCompanyValue(CompanyIndex company); rubidium@9374: rubidium@9374: /** rubidium@9668: * Gets the bank balance. In other words, the amount of money the given company can spent. rubidium@9668: * @param company the company to get the bank balance of. rubidium@9668: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY rubidium@9668: * @return the actual bank balance. rubidium@9374: */ truebrain@9737: static int32 GetBankBalance(CompanyIndex company); rubidium@9374: rubidium@9374: /** truelight@9447: * Gets the amount your company have loaned. truelight@9447: * @return the amount loaned money. truelight@9448: * @post the return value is always non-negative. truelight@9447: * @post GetLoanInterval() is always a multiplier of the return value. rubidium@9374: */ truebrain@9737: static int32 GetLoanAmount(); rubidium@9374: rubidium@9374: /** truelight@9447: * Gets the maximum amount your company can loan. truelight@9447: * @return the maximum amount your company can loan. truelight@9448: * @post the return value is always non-negative. truelight@9447: * @post GetLoanInterval() is always a multiplier of the return value. rubidium@9374: */ truebrain@9737: static int32 GetMaxLoanAmount(); rubidium@9374: rubidium@9374: /** truelight@9447: * Gets the interval/loan step. truelight@9447: * @return the loan step. truelight@9447: * @post return value is always positive. rubidium@9376: */ truebrain@9737: static int32 GetLoanInterval(); rubidium@9376: rubidium@9376: /** truelight@9447: * Sets the amount to loan. truelight@9447: * @param loan the amount to loan (multiplier of GetLoanInterval()). truelight@9448: * @pre loan must be non-negative. truelight@9447: * @pre GetLoanInterval must be a multiplier of loan. truelight@9447: * @pre loan must be below GetMaxLoan(). truelight@9448: * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative. truelight@9447: * @return true if the loan could be set to your requested amount. rubidium@9374: */ truebrain@9737: static bool SetLoanAmount(int32 loan); rubidium@9668: rubidium@9668: /** rubidium@9668: * Sets the minimum amount to loan, i.e. the given amount of loan rounded up. rubidium@9668: * @param loan the amount to loan (any positive number). rubidium@9668: * @pre loan must be non-negative. rubidium@9668: * @pre loan must be below GetMaxLoan(). rubidium@9668: * @return true if we could allocate a minimum of "loan" loan. rubidium@9668: */ truebrain@9737: static bool SetMinimumLoanAmount(int32 loan); rubidium@9374: }; rubidium@9374: rubidium@9668: DECLARE_POSTFIX_INCREMENT(AICompany::CompanyIndex); rubidium@9668: rubidium@9374: #endif /* AI_COMPANY_HPP */