[SDK]::Read/::Write Methods for Custom Classes

So if you select one of them it will deselect the other?

Well, take a look at CvCity::setWorkingPlot() for assigning worked plots to a city, and at CvPlot::calculateYield() to modify the calculation of the yields for the plot.

Write your logic there (and maybe in other places, you'll see as you go along).
 
That's done, what I'm wondering is how to modify which plots cities can work.
 
How do you like these methods?

Code:
bool CvCity::canWorkAsVillage(CvPlot* pPlot) const
{
	int iXDiff = abs(pPlot->getX() - getX());
	int iYDiff = abs(pPlot->getY() - getY());

	if((iXDiff > 2) || (iYDiff < 2))
		return false;
	if ((iXDiff == 0) && (iYDiff == 0))
		return false;
	if ((iXDiff == 2) && (iYDiff == 2))
		return false;

	if (iXDiff + iYDiff == 3)
		return true;

	return false;
}

bool CvCity::canWorkThroughVillage(CvPlot* pPlot) const
{
	int iXDiff = abs(pPlot->getX() - getX());
	int iYDiff = abs(pPlot->getY() - getY());

	if((iXDiff == 2) || (iYDiff == 2))
		return true;

	if (((iXDiff == 3) && (!(iYDiff > 1))) || (iYDiff == 3) && (!(iXDiff > 1)))
		return true;

	return false;
}

http://pokiphlanon.com/WoP/f_bfc.html
 
First, in the first function, you probably meant:
Code:
if((iXDiff > 2) || (iYDiff [B][COLOR="Red"]>[/COLOR][/B] 2))

Second, when you calculate distance like that, you ignore the possibility of map wrapping.
You should use xDistance() and yDistance() instead (found in CvGameCoreUtils.h).

The player can assign tiles for the village to work by clicking on a tile and dragging the mouse to an ajecent village.

How are you going to implement this? Is this supposed to be in the city screen?
 
How are you going to implement this? Is this supposed to be in the city screen?
I was thinking something click-and-draggy. The player clicks on the village and drags to the tile to work.
 
Back
Top Bottom