rubidium@9374: /* $Id$ */ rubidium@9374: truebrain@9829: /** @file ai_company.hpp Everything to query a company's financials and statistics or build company related buildings. */ 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: truelight@9529: static const char *GetClassName() { return "AICompany"; } truelight@9529: truebrain@9835: /** Different constants related to CompanyIndex. */ rubidium@9668: enum CompanyIndex { rubidium@9853: FIRST_COMPANY = 0, //!< The first available company. rubidium@9853: LAST_COMPANY = 7, //!< The last available company. rubidium@9853: MY_COMPANY = 8, //!< Constant that gets resolved to the correct company index for your company. rubidium@9853: INVALID_COMPANY = 9, //!< An invalid company. rubidium@9668: }; rubidium@9668: rubidium@9668: /** truebrain@9835: * Resolved the given company index to the correct index for the company. If truebrain@9835: * the company index was MY_COMPANY it will be resolved to the index of truebrain@9835: * your company. If the company with the given index does not exist it will truebrain@9835: * return INVALID_COMPANY. truebrain@9835: * @param company The company index to resolve. truebrain@9835: * @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. truebrain@9835: * @param name The new name of the company. rubidium@9865: * @pre 'name' must have at least one character. rubidium@9865: * @exception AIError::ERR_NAME_IS_NOT_UNIQUE truebrain@9835: * @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. truebrain@9835: * @param company The company to get the name for. rubidium@9668: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY truebrain@9835: * @return The name of the given company. rubidium@9374: */ truebrain@9737: static char *GetCompanyName(CompanyIndex company); rubidium@9374: rubidium@9374: /** truelight@9575: * Set the name of your president. truebrain@9835: * @param name The new name of the president. rubidium@9865: * @pre 'name' must have at least one character. rubidium@9865: * @exception AIError::ERR_NAME_IS_NOT_UNIQUE truebrain@9835: * @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. truebrain@9835: * @param company The company to get the president's name for. rubidium@9668: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY truebrain@9835: * @return The name of the president of the given company. truelight@9575: */ truebrain@9737: static char *GetPresidentName(CompanyIndex company); truelight@9575: truelight@9575: /** truebrain@9829: * Sets the amount to loan. truebrain@9835: * @param loan The amount to loan (multiplier of GetLoanInterval()). truebrain@9835: * @pre 'loan' must be non-negative. truebrain@9835: * @pre GetLoanInterval() must be a multiplier of GetLoanInterval(). truebrain@9835: * @pre 'loan' must be below GetMaxLoanAmount(). truebrain@9835: * @pre 'loan' - GetLoanAmount() + GetBankBalance() must be non-negative. truebrain@9835: * @return True if the loan could be set to your requested amount. rubidium@9374: */ truebrain@9829: static bool SetLoanAmount(int32 loan); rubidium@9374: rubidium@9374: /** truebrain@9829: * Sets the minimum amount to loan, i.e. the given amount of loan rounded up. truebrain@9835: * @param loan The amount to loan (any positive number). truebrain@9835: * @pre 'loan' must be non-negative. truebrain@9835: * @pre 'loan' must be below GetMaxLoanAmount(). truebrain@9835: * @return True if we could allocate a minimum of "loan" loan. rubidium@9374: */ truebrain@9829: static bool SetMinimumLoanAmount(int32 loan); rubidium@9374: rubidium@9374: /** truelight@9447: * Gets the amount your company have loaned. truebrain@9835: * @return The amount loaned money. truebrain@9835: * @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. truebrain@9835: * @return The maximum amount your company can loan. truebrain@9835: * @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. truebrain@9835: * @return The loan step. truebrain@9835: * @post Return value is always positive. rubidium@9376: */ truebrain@9737: static int32 GetLoanInterval(); rubidium@9376: rubidium@9376: /** truebrain@9829: * Gets the current value of the given company. truebrain@9835: * @param company The company to get the company value of. truebrain@9829: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY truebrain@9835: * @return The current value of the given company. rubidium@9374: */ truebrain@9829: static int32 GetCompanyValue(CompanyIndex company); rubidium@9668: rubidium@9668: /** truebrain@9829: * Gets the bank balance. In other words, the amount of money the given company can spent. truebrain@9835: * @param company The company to get the bank balance of. truebrain@9829: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY truebrain@9835: * @return The actual bank balance. rubidium@9668: */ truebrain@9829: static int32 GetBankBalance(CompanyIndex company); truebrain@9808: truebrain@9808: /** truebrain@9808: * Build your company's HQ on the given tile. truebrain@9835: * @param tile The tile to build your HQ on, this tile is the most nothern tile of your HQ. truebrain@9808: * @pre AIMap::IsValidTile(tile). rubidium@9865: * @exception AIError::ERR_AREA_NOT_CLEAR rubidium@9866: * @exception AIError::ERR_FLAT_LAND_REQUIRED truebrain@9835: * @return True if the HQ could be build. truebrain@9835: * @note An HQ can not be removed, only by water or rebuilding; If an HQ is truebrain@9835: * build again, the old one is removed. truebrain@9808: */ truebrain@9808: static bool BuildCompanyHQ(TileIndex tile); truebrain@9808: truebrain@9808: /** truebrain@9808: * Return the location of a company's HQ. truebrain@9835: * @param company The company the get the HQ of. truebrain@9808: * @pre ResolveCompanyIndex(company) != INVALID_COMPANY. truebrain@9808: * @return The tile of the company's HQ, this tile is the most nothern tile of that HQ, or INVALID_TILE if there is no HQ yet. truebrain@9808: */ truebrain@9808: static TileIndex GetCompanyHQ(CompanyIndex company); rubidium@9374: }; rubidium@9374: rubidium@9668: DECLARE_POSTFIX_INCREMENT(AICompany::CompanyIndex); rubidium@9668: rubidium@9374: #endif /* AI_COMPANY_HPP */