src/ai/api/ai_company.hpp
author rubidium
Sat, 14 Apr 2007 20:38:10 +0000
branchnoai
changeset 9594 5009a30f320a
parent 9575 a4b6bbfa6c96
child 9596 8af5a1399842
permissions -rw-r--r--
(svn r9627) [NoAI] -Fix: let the squirrel export script export all needed (and a few more) types of references to structs and classes.
/* $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:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AICompany"; }

	/**
	 * Set the name of your company.
	 * @param name the new name of the company.
	 * @pre name != NULL
	 * @return true if the name was changed.
	 */
	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();

	/**
	 * Set the name of your president.
	 * @param name the new name of the president.
	 * @pre name != NULL
	 * @return true if the name was changed.
	 */
	bool SetPresidentName(const char *name);

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

	/**
	 * 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; }
	template <> AICompany &GetParam(ForceType<AICompany &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AICompany *)instance; }
	template <> const AICompany *GetParam(ForceType<const AICompany *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AICompany *)instance; }
	template <> const AICompany &GetParam(ForceType<const 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.DefSQStaticMethod(engine, &AICompany::GetClassName, "GetClassName", 1, "x");

	SQAICompany.DefSQMethod(engine, &AICompany::SetCompanyName,   "SetCompanyName",   2, "xs");
	SQAICompany.DefSQMethod(engine, &AICompany::GetCompanyName,   "GetCompanyName",   1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::SetPresidentName, "SetPresidentName", 2, "xs");
	SQAICompany.DefSQMethod(engine, &AICompany::GetPresidentName, "GetPresidentName", 1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::GetCompanyValue,  "GetCompanyValue",  1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::GetBankBalance,   "GetBankBalance",   1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::GetLoanAmount,    "GetLoanAmount",    1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount", 1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::GetLoanInterval,  "GetLoanInterval",  1, "x");
	SQAICompany.DefSQMethod(engine, &AICompany::SetLoanAmount,    "SetLoanAmount",    2, "xi");

	SQAICompany.PostRegister(engine);
}
#endif /* DEFINE_SQUIRREL_CLASS */

#endif /* AI_COMPANY_HPP */