src/ai/core/ai_company.hpp
author truelight
Wed, 14 Mar 2007 20:22:07 +0000
branchnoai
changeset 9387 4255a0a2d272
parent 9376 7c12a15c945a
child 9397 d8f8db9c1a2e
permissions -rw-r--r--
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
-Update: SQNoAI does now exactly what NoAI does
/* $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 SQUIRREL_CLASS
void SQAICompanyRegister(HSQUIRRELVM vm) {
	DefSQClass <AICompany> SQAICompany("AICompany");
	SQAICompany.PreRegister(vm);
	SQAICompany.DefSQFunction(vm, &AICompany::SetCompanyName,   "SetCompanyName");
	SQAICompany.DefSQFunction(vm, &AICompany::GetCompanyName,   "GetCompanyName");
	SQAICompany.DefSQFunction(vm, &AICompany::GetCompanyValue,  "GetCompanyValue");
	SQAICompany.DefSQFunction(vm, &AICompany::GetBankBalance,   "GetBankBalance");
	SQAICompany.DefSQFunction(vm, &AICompany::GetLoanAmount,    "GetLoanAmount");
	SQAICompany.DefSQFunction(vm, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount");
	SQAICompany.DefSQFunction(vm, &AICompany::GetLoanInterval,  "GetLoanInterval");
	SQAICompany.DefSQFunction(vm, &AICompany::SetLoanAmount,    "SetLoanAmount");
	SQAICompany.PostRegister(vm);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_COMPANY_HPP */