src/ai/core/ai_company.hpp
author truelight
Thu, 15 Mar 2007 22:17:28 +0000
branchnoai
changeset 9425 8eec6d10844a
parent 9422 33efcc5f1b09
permissions -rw-r--r--
(svn r9227) [NoAI] -Change: renamed SQUIRREL_CLASS to DEFINE_SQUIRREL_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 AICompany : public AIObject {
public:
	/**
	 * Set the name of the 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 the company
	 * @return the name of the company
	 * @note the returned company name must be freed
	 */
	char *GetCompanyName();

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

	/**
	 * Gets the bank balance, i.e. the amount of money that can be spent
	 * @return the bank balance of the company
	 */
	int32 GetBankBalance();

	/**
	 * Gets the amount the company have loaned
	 * @return the amount loaned
	 * @post return >= 0
	 * @post return % this->GetLoanInterval() == 0
	 */
	int32 GetLoanAmount();

	/**
	 * Gets the maximum amount the company can loan
	 * @return the maximum amount the company can loan
	 * @post return >= 0
	 * @post return % this->GetLoanInterval() == 0
	 */
	int32 GetMaxLoanAmount();

	/**
	 * Gets the interval/loan steps
	 * @return the loan steps
	 * @post return >= 0
	 */
	int32 GetLoanInterval();

	/**
	 * Sets the amount to loan
	 * @param loan the amount to load (multitude of GetLoanInterval())
	 * @pre loan >= 0
	 * @pre loan % this->GetLoanInterval() == 0
	 * @pre loan < GetMaxLoan()
	 * @pre loan - GetLoan() + GetBankBalance() > 0
	 * @return true if the command was send without a problem
	 */
	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 */