10 /** |
10 /** |
11 * Class that handles all company related functions. |
11 * Class that handles all company related functions. |
12 */ |
12 */ |
13 class AICompany : public AIObject { |
13 class AICompany : public AIObject { |
14 public: |
14 public: |
15 /** |
|
16 * The name of the class, needed by several sub-processes. |
|
17 */ |
|
18 static const char *GetClassName() { return "AICompany"; } |
15 static const char *GetClassName() { return "AICompany"; } |
19 |
16 |
20 /** Different constants related to companies */ |
17 /** Different constants related to companies */ |
21 enum CompanyIndex { |
18 enum CompanyIndex { |
22 FIRST_COMPANY = 0, ///< The first available company. |
19 FIRST_COMPANY = 0, ///< The first available company. |
69 * @note the returned president name must be free'd (C++ only). |
66 * @note the returned president name must be free'd (C++ only). |
70 */ |
67 */ |
71 static char *GetPresidentName(CompanyIndex company); |
68 static char *GetPresidentName(CompanyIndex company); |
72 |
69 |
73 /** |
70 /** |
74 * Gets the current value of the given company. |
71 * Sets the amount to loan. |
75 * @param company the company to get the company value of. |
72 * @param loan the amount to loan (multiplier of GetLoanInterval()). |
76 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
73 * @pre loan must be non-negative. |
77 * @return the current value of the given company. |
74 * @pre GetLoanInterval must be a multiplier of loan. |
|
75 * @pre loan must be below GetMaxLoan(). |
|
76 * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative. |
|
77 * @return true if the loan could be set to your requested amount. |
78 */ |
78 */ |
79 static int32 GetCompanyValue(CompanyIndex company); |
79 static bool SetLoanAmount(int32 loan); |
80 |
80 |
81 /** |
81 /** |
82 * Gets the bank balance. In other words, the amount of money the given company can spent. |
82 * Sets the minimum amount to loan, i.e. the given amount of loan rounded up. |
83 * @param company the company to get the bank balance of. |
83 * @param loan the amount to loan (any positive number). |
84 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
84 * @pre loan must be non-negative. |
85 * @return the actual bank balance. |
85 * @pre loan must be below GetMaxLoan(). |
|
86 * @return true if we could allocate a minimum of "loan" loan. |
86 */ |
87 */ |
87 static int32 GetBankBalance(CompanyIndex company); |
88 static bool SetMinimumLoanAmount(int32 loan); |
88 |
89 |
89 /** |
90 /** |
90 * Gets the amount your company have loaned. |
91 * Gets the amount your company have loaned. |
91 * @return the amount loaned money. |
92 * @return the amount loaned money. |
92 * @post the return value is always non-negative. |
93 * @post the return value is always non-negative. |
108 * @post return value is always positive. |
109 * @post return value is always positive. |
109 */ |
110 */ |
110 static int32 GetLoanInterval(); |
111 static int32 GetLoanInterval(); |
111 |
112 |
112 /** |
113 /** |
113 * Sets the amount to loan. |
114 * Gets the current value of the given company. |
114 * @param loan the amount to loan (multiplier of GetLoanInterval()). |
115 * @param company the company to get the company value of. |
115 * @pre loan must be non-negative. |
116 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
116 * @pre GetLoanInterval must be a multiplier of loan. |
117 * @return the current value of the given company. |
117 * @pre loan must be below GetMaxLoan(). |
|
118 * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative. |
|
119 * @return true if the loan could be set to your requested amount. |
|
120 */ |
118 */ |
121 static bool SetLoanAmount(int32 loan); |
119 static int32 GetCompanyValue(CompanyIndex company); |
122 |
120 |
123 /** |
121 /** |
124 * Sets the minimum amount to loan, i.e. the given amount of loan rounded up. |
122 * Gets the bank balance. In other words, the amount of money the given company can spent. |
125 * @param loan the amount to loan (any positive number). |
123 * @param company the company to get the bank balance of. |
126 * @pre loan must be non-negative. |
124 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
127 * @pre loan must be below GetMaxLoan(). |
125 * @return the actual bank balance. |
128 * @return true if we could allocate a minimum of "loan" loan. |
|
129 */ |
126 */ |
130 static bool SetMinimumLoanAmount(int32 loan); |
127 static int32 GetBankBalance(CompanyIndex company); |
131 |
128 |
132 /** |
129 /** |
133 * Build your company's HQ on the given tile. |
130 * Build your company's HQ on the given tile. |
134 * @param tile the tile to build your HQ on, this tile is the most nothern tile of your HQ. |
131 * @param tile the tile to build your HQ on, this tile is the most nothern tile of your HQ. |
135 * @pre AIMap::IsValidTile(tile). |
132 * @pre AIMap::IsValidTile(tile). |