src/ai/api/ai_company.hpp
author truelight
Sun, 18 Mar 2007 18:02:27 +0000
branchnoai
changeset 9452 4c5eedbc3ba9
parent 9448 2a4c4340233d
child 9520 f7cf8bea10db
permissions -rw-r--r--
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
DoCommand no longer returns the cost, it returns a bool.
Costs are available via this Accounting class.
/* $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:
	/**
	 * Set the name of your company.
	 * @param name the new name of the company.
	 * @pre name != NULL
	 * @return true if the command was send without problem.
	 */
	bool SetCompanyName(const char *name);

	/**
	 * Get the name of your company.
	 * @return the name of your company.
	 * @note the returned company name must be free'd (C++ only).
	 */
	char *GetCompanyName();

	/**
	 * Gets the current value of your company.
	 * @return the current value of your company.
	 */
	int32 GetCompanyValue();

	/**
	 * Gets the bank balance. In other words, the amount of money you can spent.
	 * @return the bank balance of your company.
	 */
	int32 GetBankBalance();

	/**
	 * 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);
};

#ifdef DEFINE_SQUIRREL_CLASS
void SQAICompanyRegister(Squirrel *engine) {
	DefSQClass <AICompany> SQAICompany("AICompany");
	SQAICompany.PreRegister(engine);
	SQAICompany.AddConstructor(engine);
	SQAICompany.DefSQFunction(engine, &AICompany::SetCompanyName,   "SetCompanyName");
	SQAICompany.DefSQFunction(engine, &AICompany::GetCompanyName,   "GetCompanyName");
	SQAICompany.DefSQFunction(engine, &AICompany::GetCompanyValue,  "GetCompanyValue");
	SQAICompany.DefSQFunction(engine, &AICompany::GetBankBalance,   "GetBankBalance");
	SQAICompany.DefSQFunction(engine, &AICompany::GetLoanAmount,    "GetLoanAmount");
	SQAICompany.DefSQFunction(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount");
	SQAICompany.DefSQFunction(engine, &AICompany::GetLoanInterval,  "GetLoanInterval");
	SQAICompany.DefSQFunction(engine, &AICompany::SetLoanAmount,    "SetLoanAmount");
	SQAICompany.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_COMPANY_HPP */