void CvPlayerAI::AI_conquerCity(CvCity* pCity)
{
CvCity* pNearestCity;
bool bRaze = false;
int iRazeValue;
int iI;
if (canRaze(pCity))
{
iRazeValue = 0;
if (GC.getGameINLINE().getElapsedGameTurns() > 20)
{
if (getNumCities() > 4)
{
if (!(pCity->isHolyCity()) && !(pCity->hasActiveWorldWonder()))
{
if (pCity->getPreviousOwner() != BARBARIAN_PLAYER)
{
pNearestCity = GC.getMapINLINE().findCity(pCity->getX_INLINE(), pCity->getY_INLINE(), NO_PLAYER, getTeam(), true, false, NO_TEAM, NO_DIRECTION, pCity);
if (pNearestCity == NULL)
{
if (pCity->getPreviousOwner() != NO_PLAYER)
{
if (GET_TEAM(GET_PLAYER(pCity->getPreviousOwner()).getTeam()).countNumCitiesByArea(pCity->area()) > 3)
{
iRazeValue += 30;
}
}
}
else
{
int iDistance = plotDistance(pCity->getX_INLINE(), pCity->getY_INLINE(), pNearestCity->getX_INLINE(), pNearestCity->getY_INLINE());
if ( iDistance > 12)
{
iRazeValue += iDistance * 2;
}
}
}
if (pCity->area()->getCitiesPerPlayer(getID()) > 0)
{
if (AI_isFinancialTrouble())
{
iRazeValue += (70 - 15 * pCity->getPopulation());
}
}
if (getStateReligion() != NO_RELIGION)
{
if (pCity->isHasReligion(getStateReligion()))
{
if (GET_TEAM(getTeam()).hasShrine(getStateReligion()))
{
iRazeValue -= 50;
}
else
{
iRazeValue -= 10;
}
}
}
int iCloseness = pCity->AI_playerCloseness(getID());
if (iCloseness > 0)
{
iRazeValue -= 25;
iRazeValue -= iCloseness * 2;
}
else
{
iRazeValue += 60;
}
if (pCity->area()->getCitiesPerPlayer(getID()) > 0)
{
if (pCity->getPreviousOwner() != BARBARIAN_PLAYER)
{
iRazeValue += GC.getLeaderHeadInfo(getPersonalityType()).getRazeCityProb();
}
}
if (iRazeValue > 0)
{
for (iI = 0; iI < GC.getNumTraitInfos(); iI++)
{
if (hasTrait((TraitTypes)iI))
{
iRazeValue *= (100 - (GC.getTraitInfo((TraitTypes)iI).getUpkeepModifier()));
iRazeValue /= 100;
}
}
if (GC.getGameINLINE().getSorenRandNum(100, "AI Raze City") < iRazeValue)
{
bRaze = true;
pCity->doTask(TASK_RAZE);
}
}
}
}
}
}
if (!bRaze)
{
CvEventReporter::getInstance().cityAcquiredAndKept(GC.getGameINLINE().getActivePlayer(), pCity);
}
}