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