src/ai/api/ai_company.hpp
author rubidium
Sun, 25 Mar 2007 14:19:59 +0000
branchnoai
changeset 9526 a4ad60ba03be
parent 9524 283d23931bb4
child 9529 5f26f4bc574b
permissions -rw-r--r--
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
/* $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
namespace SQConvert {
	/* Allow AICompany to be used as Squirrel parameter */
	template <> AICompany *GetParam(ForceType<AICompany *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AICompany *)instance; }
}; // namespace SQConvert

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 /* DEFINE_SQUIRREL_CLASS */

#endif /* AI_COMPANY_HPP */