src/ai/api/ai_townlist_valuator.hpp
author truebrain
Thu, 28 Feb 2008 01:11:23 +0000
branchnoai
changeset 9803 c86d5834fb11
parent 9781 d583b3eb60e0
permissions -rw-r--r--
(svn r12309) [NoAI] -Codechange: optimize a little bit (a very small little bit, but every bit counts :) ) (glx)
/* $Id$ */

/** @file ai_townlist_valuator.hpp all the valuators for AITownList */

#ifndef AI_TOWNLIST_VALUATOR_HPP
#define AI_TOWNLIST_VALUATOR_HPP

#include "ai_abstractlist.hpp"

/**
 * Get the population for entries in an AITownList instance.
 * @note Resulting items are of the type int32.
 * @note Can only operate on an AITownList instance.
 * @ingroup AITownList
 */
class AITownList_vPopulation : public AIAbstractList::Valuator {
public:
	static const char *GetClassName() { return "AITownList_vGetPopulation"; }

private:
	const char *GetListName() const { return "AITownList"; }
	int32 Valuate(int32 town) const;
};

/**
 * Get the location for entries in an AITownList instance.
 * @note Resulting items are of the type TileIndex.
 * @note Can only operate on an AITownList instance.
 * @ingroup AITownList
 */
class AITownList_vLocation : public AIAbstractList::Valuator {
public:
	static const char *GetClassName() { return "AITownList_vGetLocation"; }

private:
	const char *GetListName() const { return "AITownList"; }
	int32 Valuate(int32 town) const;
};

/**
 * Get the manhattan distance to a tile for entries in an AITownList instance.
 * @note Resulting items are of the type uint32.
 * @note Can only operate on an AITownList instance.
 * @ingroup AITownList
 */
class AITownList_vDistanceManhattanToTile : public AIAbstractList::Valuator {
public:
	static const char *GetClassName() { return "AITownList_vDistanceManhattanToTile"; }

	/**
	 * Custom constructor, we want a tile as parameter.
	 */
	AITownList_vDistanceManhattanToTile(TileIndex tile) :
		tile(tile)
	{}

private:
	TileIndex tile;

	/**
	 * @param tile The tile to get the distance to.
	 */
	const char *GetListName() const { return "AITownList"; }

	int32 Valuate(int32 station) const;
};

/**
 * Get the square distance to a tile for entries in an AITownList instance.
 * @note Resulting items are of the type uint32.
 * @note Can only operate on an AITownList instance.
 * @ingroup AITownList
 */
class AITownList_vDistanceSquareToTile : public AIAbstractList::Valuator {
public:
	static const char *GetClassName() { return "AITownList_vDistanceSquareToTile"; }

	/**
	 * @param tile The tile to get the distance to.
	 */
	AITownList_vDistanceSquareToTile(TileIndex tile) :
		tile(tile)
	{}

private:
	TileIndex tile;

	const char *GetListName() const { return "AITownList"; }
	int32 Valuate(int32 station) const;
};

#endif /* AI_TOWNLIST_VALUATOR_HPP */