src/ai/api/ai_company.hpp
branchnoai
changeset 9835 2541c2d325ed
parent 9829 80fbe02a4184
child 9853 b0512cb3ceb1
equal deleted inserted replaced
9834:9abe20fc83e5 9835:2541c2d325ed
    12  */
    12  */
    13 class AICompany : public AIObject {
    13 class AICompany : public AIObject {
    14 public:
    14 public:
    15 	static const char *GetClassName() { return "AICompany"; }
    15 	static const char *GetClassName() { return "AICompany"; }
    16 
    16 
    17 	/** Different constants related to companies */
    17 	/** Different constants related to CompanyIndex. */
    18 	enum CompanyIndex {
    18 	enum CompanyIndex {
    19 		FIRST_COMPANY   = 0, ///< The first available company.
    19 		FIRST_COMPANY   = 0, ///< The first available company.
    20 		LAST_COMPANY    = 7, ///< The last available company.
    20 		LAST_COMPANY    = 7, ///< The last available company.
    21 		MY_COMPANY      = 8, ///< Constant that gets resolved to the correct company index for your company.
    21 		MY_COMPANY      = 8, ///< Constant that gets resolved to the correct company index for your company.
    22 		INVALID_COMPANY = 9, ///< An invalid company
    22 		INVALID_COMPANY = 9, ///< An invalid company.
    23 	};
    23 	};
    24 
    24 
    25 	/**
    25 	/**
    26 	 * Resolved the given company index to the correct index
    26 	 * Resolved the given company index to the correct index for the company. If
    27 	 * for the company. If the company index was MY_COMPANY
    27 	 *  the company index was MY_COMPANY it will be resolved to the index of
    28 	 * it will be resolved to the index of your company.
    28 	 *  your company. If the company with the given index does not exist it will
    29 	 * If the company with the given index does not exist
    29 	 *  return INVALID_COMPANY.
    30 	 * it will return INVALID_COMPANY.
    30 	 * @param company The company index to resolve.
    31 	 * @param company the company index to resolve.
    31 	 * @return The resolved company index.
    32 	 * @return the resolved company index.
       
    33 	 */
    32 	 */
    34 	static CompanyIndex ResolveCompanyIndex(CompanyIndex company);
    33 	static CompanyIndex ResolveCompanyIndex(CompanyIndex company);
    35 
    34 
    36 	/**
    35 	/**
    37 	 * Set the name of your company.
    36 	 * Set the name of your company.
    38 	 * @param name the new name of the company.
    37 	 * @param name The new name of the company.
    39 	 * @pre name != NULL
    38 	 * @return True if the name was changed.
    40 	 * @return true if the name was changed.
       
    41 	 */
    39 	 */
    42 	static bool SetCompanyName(const char *name);
    40 	static bool SetCompanyName(const char *name);
    43 
    41 
    44 	/**
    42 	/**
    45 	 * Get the name of the given company.
    43 	 * Get the name of the given company.
    46 	 * @param company the company to get the name for.
    44 	 * @param company The company to get the name for.
    47 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
    45 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
    48 	 * @return the name of the given company.
    46 	 * @return The name of the given company.
    49 	 * @note the returned company name must be free'd (C++ only).
       
    50 	 */
    47 	 */
    51 	static char *GetCompanyName(CompanyIndex company);
    48 	static char *GetCompanyName(CompanyIndex company);
    52 
    49 
    53 	/**
    50 	/**
    54 	 * Set the name of your president.
    51 	 * Set the name of your president.
    55 	 * @param name the new name of the president.
    52 	 * @param name The new name of the president.
    56 	 * @pre name != NULL
    53 	 * @return True if the name was changed.
    57 	 * @return true if the name was changed.
       
    58 	 */
    54 	 */
    59 	static bool SetPresidentName(const char *name);
    55 	static bool SetPresidentName(const char *name);
    60 
    56 
    61 	/**
    57 	/**
    62 	 * Get the name of the president of the given company.
    58 	 * Get the name of the president of the given company.
    63 	 * @param company the company to get the president's name for.
    59 	 * @param company The company to get the president's name for.
    64 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
    60 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
    65 	 * @return the name of the president of the given company.
    61 	 * @return The name of the president of the given company.
    66 	 * @note the returned president name must be free'd (C++ only).
       
    67 	 */
    62 	 */
    68 	static char *GetPresidentName(CompanyIndex company);
    63 	static char *GetPresidentName(CompanyIndex company);
    69 
    64 
    70 	/**
    65 	/**
    71 	 * Sets the amount to loan.
    66 	 * Sets the amount to loan.
    72 	 * @param loan the amount to loan (multiplier of GetLoanInterval()).
    67 	 * @param loan The amount to loan (multiplier of GetLoanInterval()).
    73 	 * @pre loan must be non-negative.
    68 	 * @pre 'loan' must be non-negative.
    74 	 * @pre GetLoanInterval must be a multiplier of loan.
    69 	 * @pre GetLoanInterval() must be a multiplier of GetLoanInterval().
    75 	 * @pre loan must be below GetMaxLoan().
    70 	 * @pre 'loan' must be below GetMaxLoanAmount().
    76 	 * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative.
    71 	 * @pre 'loan' - GetLoanAmount() + GetBankBalance() must be non-negative.
    77 	 * @return true if the loan could be set to your requested amount.
    72 	 * @return True if the loan could be set to your requested amount.
    78 	 */
    73 	 */
    79 	static bool SetLoanAmount(int32 loan);
    74 	static bool SetLoanAmount(int32 loan);
    80 
    75 
    81 	/**
    76 	/**
    82 	 * Sets the minimum amount to loan, i.e. the given amount of loan rounded up.
    77 	 * Sets the minimum amount to loan, i.e. the given amount of loan rounded up.
    83 	 * @param loan the amount to loan (any positive number).
    78 	 * @param loan The amount to loan (any positive number).
    84 	 * @pre loan must be non-negative.
    79 	 * @pre 'loan' must be non-negative.
    85 	 * @pre loan must be below GetMaxLoan().
    80 	 * @pre 'loan' must be below GetMaxLoanAmount().
    86 	 * @return true if we could allocate a minimum of "loan" loan.
    81 	 * @return True if we could allocate a minimum of "loan" loan.
    87 	 */
    82 	 */
    88 	static bool SetMinimumLoanAmount(int32 loan);
    83 	static bool SetMinimumLoanAmount(int32 loan);
    89 
    84 
    90 	/**
    85 	/**
    91 	 * Gets the amount your company have loaned.
    86 	 * Gets the amount your company have loaned.
    92 	 * @return the amount loaned money.
    87 	 * @return The amount loaned money.
    93 	 * @post the return value is always non-negative.
    88 	 * @post The return value is always non-negative.
    94 	 * @post GetLoanInterval() is always a multiplier of the return value.
    89 	 * @post GetLoanInterval() is always a multiplier of the return value.
    95 	 */
    90 	 */
    96 	static int32 GetLoanAmount();
    91 	static int32 GetLoanAmount();
    97 
    92 
    98 	/**
    93 	/**
    99 	 * Gets the maximum amount your company can loan.
    94 	 * Gets the maximum amount your company can loan.
   100 	 * @return the maximum amount your company can loan.
    95 	 * @return The maximum amount your company can loan.
   101 	 * @post the return value is always non-negative.
    96 	 * @post The return value is always non-negative.
   102 	 * @post GetLoanInterval() is always a multiplier of the return value.
    97 	 * @post GetLoanInterval() is always a multiplier of the return value.
   103 	 */
    98 	 */
   104 	static int32 GetMaxLoanAmount();
    99 	static int32 GetMaxLoanAmount();
   105 
   100 
   106 	/**
   101 	/**
   107 	 * Gets the interval/loan step.
   102 	 * Gets the interval/loan step.
   108 	 * @return the loan step.
   103 	 * @return The loan step.
   109 	 * @post return value is always positive.
   104 	 * @post Return value is always positive.
   110 	 */
   105 	 */
   111 	static int32 GetLoanInterval();
   106 	static int32 GetLoanInterval();
   112 
   107 
   113 	/**
   108 	/**
   114 	 * Gets the current value of the given company.
   109 	 * Gets the current value of the given company.
   115 	 * @param company the company to get the company value of.
   110 	 * @param company The company to get the company value of.
   116 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
   111 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
   117 	 * @return the current value of the given company.
   112 	 * @return The current value of the given company.
   118 	 */
   113 	 */
   119 	static int32 GetCompanyValue(CompanyIndex company);
   114 	static int32 GetCompanyValue(CompanyIndex company);
   120 
   115 
   121 	/**
   116 	/**
   122 	 * Gets the bank balance. In other words, the amount of money the given company can spent.
   117 	 * Gets the bank balance. In other words, the amount of money the given company can spent.
   123 	 * @param company the company to get the bank balance of.
   118 	 * @param company The company to get the bank balance of.
   124 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
   119 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY
   125 	 * @return the actual bank balance.
   120 	 * @return The actual bank balance.
   126 	 */
   121 	 */
   127 	static int32 GetBankBalance(CompanyIndex company);
   122 	static int32 GetBankBalance(CompanyIndex company);
   128 
   123 
   129 	/**
   124 	/**
   130 	 * Build your company's HQ on the given tile.
   125 	 * Build your company's HQ on the given tile.
   131 	 * @param tile the tile to build your HQ on, this tile is the most nothern tile of your HQ.
   126 	 * @param tile The tile to build your HQ on, this tile is the most nothern tile of your HQ.
   132 	 * @pre AIMap::IsValidTile(tile).
   127 	 * @pre AIMap::IsValidTile(tile).
   133 	 * @note An HQ can not be removed, only by water or rebuilding; If an HQ is build again, the old one is removed.
   128 	 * @return True if the HQ could be build.
   134 	 * @return true if the HQ could be build.
   129 	 * @note An HQ can not be removed, only by water or rebuilding; If an HQ is
       
   130 	 *  build again, the old one is removed.
   135 	 */
   131 	 */
   136 	static bool BuildCompanyHQ(TileIndex tile);
   132 	static bool BuildCompanyHQ(TileIndex tile);
   137 
   133 
   138 	/**
   134 	/**
   139 	 * Return the location of a company's HQ.
   135 	 * Return the location of a company's HQ.
   140 	 * @param company the company the get the HQ of.
   136 	 * @param company The company the get the HQ of.
   141 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY.
   137 	 * @pre ResolveCompanyIndex(company) != INVALID_COMPANY.
   142 	 * @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.
   138 	 * @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.
   143 	 */
   139 	 */
   144 	static TileIndex GetCompanyHQ(CompanyIndex company);
   140 	static TileIndex GetCompanyHQ(CompanyIndex company);
   145 };
   141 };