15 /** |
15 /** |
16 * The name of the class, needed by several sub-processes. |
16 * The name of the class, needed by several sub-processes. |
17 */ |
17 */ |
18 static const char *GetClassName() { return "AICompany"; } |
18 static const char *GetClassName() { return "AICompany"; } |
19 |
19 |
|
20 /** Different constants related to companies */ |
|
21 enum CompanyIndex { |
|
22 FIRST_COMPANY = 0, ///< The first available company. |
|
23 LAST_COMPANY = 7, ///< The last available company. |
|
24 MY_COMPANY = 8, ///< Constant that gets resolved to the correct company index for your company. |
|
25 INVALID_COMPANY = 9, ///< An invalid company |
|
26 }; |
|
27 |
|
28 /** |
|
29 * Resolved the given company index to the correct index |
|
30 * for the company. If the company index was MY_COMPANY |
|
31 * it will be resolved to the index of your company. |
|
32 * If the company with the given index does not exist |
|
33 * it will return INVALID_COMPANY. |
|
34 * @param company the company index to resolve. |
|
35 * @return the resolved company index. |
|
36 */ |
|
37 CompanyIndex ResolveCompanyIndex(CompanyIndex company); |
|
38 |
20 /** |
39 /** |
21 * Set the name of your company. |
40 * Set the name of your company. |
22 * @param name the new name of the company. |
41 * @param name the new name of the company. |
23 * @pre name != NULL |
42 * @pre name != NULL |
24 * @return true if the name was changed. |
43 * @return true if the name was changed. |
25 */ |
44 */ |
26 bool SetCompanyName(const char *name); |
45 bool SetCompanyName(const char *name); |
27 |
46 |
28 /** |
47 /** |
29 * Get the name of your company. |
48 * Get the name of the given company. |
30 * @return the name of your company. |
49 * @param company the company to get the name for. |
|
50 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
|
51 * @return the name of the given company. |
31 * @note the returned company name must be free'd (C++ only). |
52 * @note the returned company name must be free'd (C++ only). |
32 */ |
53 */ |
33 char *GetCompanyName(); |
54 char *GetCompanyName(CompanyIndex company); |
34 |
55 |
35 /** |
56 /** |
36 * Set the name of your president. |
57 * Set the name of your president. |
37 * @param name the new name of the president. |
58 * @param name the new name of the president. |
38 * @pre name != NULL |
59 * @pre name != NULL |
39 * @return true if the name was changed. |
60 * @return true if the name was changed. |
40 */ |
61 */ |
41 bool SetPresidentName(const char *name); |
62 bool SetPresidentName(const char *name); |
42 |
63 |
43 /** |
64 /** |
44 * Get the name of your president. |
65 * Get the name of the president of the given company. |
45 * @return the name of your president. |
66 * @param company the company to get the president's name for. |
|
67 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
|
68 * @return the name of the president of the given company. |
46 * @note the returned president name must be free'd (C++ only). |
69 * @note the returned president name must be free'd (C++ only). |
47 */ |
70 */ |
48 char *GetPresidentName(); |
71 char *GetPresidentName(CompanyIndex company); |
49 |
72 |
50 /** |
73 /** |
51 * Gets the current value of your company. |
74 * Gets the current value of the given company. |
52 * @return the current value of your company. |
75 * @param company the company to get the company value of. |
|
76 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
|
77 * @return the current value of the given company. |
53 */ |
78 */ |
54 int32 GetCompanyValue(); |
79 int32 GetCompanyValue(CompanyIndex company); |
55 |
80 |
56 /** |
81 /** |
57 * Gets the bank balance. In other words, the amount of money you can spent. |
82 * Gets the bank balance. In other words, the amount of money the given company can spent. |
58 * @return the bank balance of your company. |
83 * @param company the company to get the bank balance of. |
|
84 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY |
|
85 * @return the actual bank balance. |
59 */ |
86 */ |
60 int32 GetBankBalance(); |
87 int32 GetBankBalance(CompanyIndex company); |
61 |
88 |
62 /** |
89 /** |
63 * Gets the amount your company have loaned. |
90 * Gets the amount your company have loaned. |
64 * @return the amount loaned money. |
91 * @return the amount loaned money. |
65 * @post the return value is always non-negative. |
92 * @post the return value is always non-negative. |
90 * @pre loan must be below GetMaxLoan(). |
117 * @pre loan must be below GetMaxLoan(). |
91 * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative. |
118 * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative. |
92 * @return true if the loan could be set to your requested amount. |
119 * @return true if the loan could be set to your requested amount. |
93 */ |
120 */ |
94 bool SetLoanAmount(int32 loan); |
121 bool SetLoanAmount(int32 loan); |
|
122 |
|
123 /** |
|
124 * Sets the minimum amount to loan, i.e. the given amount of loan rounded up. |
|
125 * @param loan the amount to loan (any positive number). |
|
126 * @pre loan must be non-negative. |
|
127 * @pre loan must be below GetMaxLoan(). |
|
128 * @return true if we could allocate a minimum of "loan" loan. |
|
129 */ |
|
130 bool SetMinimumLoanAmount(int32 loan); |
95 }; |
131 }; |
96 |
132 |
|
133 DECLARE_POSTFIX_INCREMENT(AICompany::CompanyIndex); |
|
134 |
97 #endif /* AI_COMPANY_HPP */ |
135 #endif /* AI_COMPANY_HPP */ |