本文整理汇总了C++中CvCity类的典型用法代码示例。如果您正苦于以下问题:C++ CvCity类的具体用法?C++ CvCity怎么用?C++ CvCity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CvCity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setActiveDirty
void CvTradeRoute::setSourceCity(const IDInfo& kCity)
{
if (getSourceCity() != kCity)
{
setActiveDirty();
const IDInfo& kOldCity = getSourceCity();
m_kSourceCity = kCity;
CvCity* pCity = ::getCity(getSourceCity());
FAssert(pCity != NULL);
if (pCity != NULL)
{
pCity->updateExport(getYield());
}
pCity = ::getCity(kOldCity);
FAssert(pCity != NULL);
if (pCity != NULL)
{
pCity->updateExport(getYield());
}
setActiveDirty();
}
}
示例2: GET_PLAYER
//------------------------------------------------------------------------------
void CvDllNetMessageHandler::ResponseSellBuilding(PlayerTypes ePlayer, int iCityID, BuildingTypes eBuilding)
{
CvCity* pCity = GET_PLAYER(ePlayer).getCity(iCityID);
if(pCity)
{
pCity->GetCityBuildings()->DoSellBuilding(eBuilding);
#if defined(MOD_EVENTS_CITY)
if (MOD_EVENTS_CITY) {
GAMEEVENTINVOKE_HOOK(GAMEEVENT_CitySoldBuilding, ePlayer, iCityID, eBuilding);
} else {
#endif
ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();
if (pkScriptSystem)
{
CvLuaArgsHandle args;
args->Push(ePlayer);
args->Push(iCityID);
args->Push(eBuilding);
bool bResult;
LuaSupport::CallHook(pkScriptSystem, "CitySoldBuilding", args.get(), bResult);
}
#if defined(MOD_EVENTS_CITY)
}
#endif
}
}
示例3: getYield
void CvTradeRoute::setYield(YieldTypes eYield)
{
if (getYield() != eYield)
{
YieldTypes eOldYield = getYield();
m_eYield = eYield;
CvCity* pCity = ::getCity(getDestinationCity());
FAssert(pCity != NULL);
if (pCity != NULL)
{
pCity->updateImport(getYield());
pCity->updateImport(eOldYield);
}
pCity = ::getCity(getSourceCity());
FAssert(pCity != NULL);
if (pCity != NULL)
{
pCity->updateExport(getYield());
pCity->updateExport(eOldYield);
}
setActiveDirty();
}
}
示例4: GET_PLAYER
// Find all our enemies (combat units)
void CvTacticalAnalysisMap::BuildEnemyUnitList()
{
m_EnemyUnits.clear();
m_EnemyCities.clear();
TeamTypes ourTeam = GET_PLAYER(m_ePlayer).getTeam();
for(int iPlayer = 0; iPlayer < MAX_PLAYERS; iPlayer++)
{
const PlayerTypes ePlayer = (PlayerTypes)iPlayer;
CvPlayer& kPlayer = GET_PLAYER(ePlayer);
const TeamTypes eTeam = kPlayer.getTeam();
// for each opposing civ
if(kPlayer.isAlive() && GET_TEAM(eTeam).isAtWar(ourTeam))
{
int iLoop;
CvUnit* pLoopUnit = NULL;
CvCity* pLoopCity;
for(pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop))
if (pLoopCity->plot()->isRevealed(ourTeam))
m_EnemyCities.push_back(pLoopCity->GetIDInfo());
for(pLoopUnit = kPlayer.firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = kPlayer.nextUnit(&iLoop))
if(pLoopUnit->IsCanAttack() && pLoopUnit->plot()->isVisible(ourTeam))
m_EnemyUnits.push_back(pLoopUnit->GetIDInfo());
}
}
}
示例5: GetCityConnectionTradeRouteGoldChange
/// Get the amount of gold granted by connecting the city
int CvTreasury::GetCityConnectionRouteGoldTimes100(CvCity* pNonCapitalCity) const
{
CvCity* pCapitalCity = m_pPlayer->getCapitalCity();
if(!pNonCapitalCity || pNonCapitalCity == pCapitalCity || pCapitalCity == NULL)
{
return 0;
}
int iGold = 0;
int iTradeRouteBaseGold = /*100*/ GC.getTRADE_ROUTE_BASE_GOLD();
int iTradeRouteCapitalGoldMultiplier = /*0*/ GC.getTRADE_ROUTE_CAPITAL_POP_GOLD_MULTIPLIER();
int iTradeRouteCityGoldMultiplier = /*125*/ GC.getTRADE_ROUTE_CITY_POP_GOLD_MULTIPLIER();
iGold += iTradeRouteBaseGold; // Base Gold: 0
iGold += (pCapitalCity->getPopulation() * iTradeRouteCapitalGoldMultiplier); // Capital Multiplier
iGold += (pNonCapitalCity->getPopulation() * iTradeRouteCityGoldMultiplier); // City Multiplier
iGold += GetCityConnectionTradeRouteGoldChange() * 100;
if(GetCityConnectionTradeRouteGoldModifier() != 0)
{
iGold *= (100 + GetCityConnectionTradeRouteGoldModifier());
iGold /= 100;
}
return iGold;
}
示例6: GET_PLAYER
// What are our gold maintenance costs because of Vassals?
int CvTreasury::GetVassalGoldMaintenance() const
{
int iRtnValue = 0;
// We have a vassal
for(int iI = 0; iI < MAX_MAJOR_CIVS; iI++)
{
if(!GET_PLAYER((PlayerTypes)iI).isMinorCiv()
&& !GET_PLAYER((PlayerTypes)iI).isBarbarian()
&& GET_PLAYER((PlayerTypes)iI).isAlive())
{
int iLoop, iCityPop;
// This player is our vassal
if(GET_TEAM(GET_PLAYER((PlayerTypes)iI).getTeam()).IsVassal(m_pPlayer->getTeam()))
{
// Loop through our vassal's cities
for(CvCity* pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
{
iCityPop = pLoopCity->getPopulation();
iRtnValue += std::max(0, (int)(pow((double)iCityPop, (double)/*0.6*/ GC.getVASSALAGE_VASSAL_CITY_POP_EXPONENT())));
}
iRtnValue += std::max(0, (GET_PLAYER((PlayerTypes)iI).GetTreasury()->GetExpensePerTurnUnitMaintenance() * /*10*/GC.getVASSALAGE_VASSAL_UNIT_MAINT_COST_PERCENT() / 100));
}
}
}
// Modifier for vassal maintenance?
iRtnValue *= (100 + m_pPlayer->GetVassalGoldMaintenanceMod());
iRtnValue /= 100;
return iRtnValue;
}
示例7: changeNumBonuses
void CvPlotGroup::changeNumBonuses(BonusTypes eBonus, int iChange)
{
CLLNode<XYCoords>* pPlotNode;
CvCity* pCity;
int iOldNumBonuses;
FAssertMsg(eBonus >= 0, "eBonus is expected to be non-negative (invalid Index)");
FAssertMsg(eBonus < GC.getNumBonusInfos(), "eBonus is expected to be within maximum bounds (invalid Index)");
if (iChange != 0)
{
iOldNumBonuses = getNumBonuses(eBonus);
m_paiNumBonuses[eBonus] = (m_paiNumBonuses[eBonus] + iChange);
//FAssertMsg(m_paiNumBonuses[eBonus] >= 0, "m_paiNumBonuses[eBonus] is expected to be non-negative (invalid Index)"); XXX
pPlotNode = headPlotsNode();
while (pPlotNode != NULL)
{
pCity = GC.getMapINLINE().plotSorenINLINE(pPlotNode->m_data.iX, pPlotNode->m_data.iY)->getPlotCity();
if (pCity != NULL)
{
if (pCity->getOwnerINLINE() == getOwnerINLINE())
{
pCity->changeNumBonuses(eBonus, iChange);
}
}
pPlotNode = nextPlotsNode(pPlotNode);
}
}
}
示例8: GET_PLAYER
//------------------------------------------------------------------------------
void CvDllNetMessageHandler::ResponseSellBuilding(PlayerTypes ePlayer, int iCityID, BuildingTypes eBuilding)
{
CvCity* pCity = GET_PLAYER(ePlayer).getCity(iCityID);
if(pCity)
{
pCity->GetCityBuildings()->DoSellBuilding(eBuilding);
}
}
示例9: operator
result_type operator() (const ResourceInfo::BaseNode& node)
{
info.rawHappy = node.baseHappy;
for (size_t i = 0, count = node.buildingNodes.size(); i < count; ++i)
{
(*this)(node.buildingNodes[i]);
}
CityIter iter(CvPlayerAI::getPlayer(playerType_));
CvCity* pLoopCity;
// how many citizens are made happy now if we had the resource, how many would be happy if we had the requisite buildings,
// and how many more could be made happy with the buildings we have.
// E.g. suppose we have 1 unhappy citizen in a city, with a forge - and we analyse gold - this would give:
// actualHappy = 1, potentialHappy = 0, unusedHappy = 1, but if the city had no forge, it should give:
// actualHappy = 1, potentialHappy = 1, unusedHappy = 0
int actualHappy = 0, potentialHappy = 0, unusedHappy = 0;
while (pLoopCity = iter())
{
int unhappyCitizens = std::max<int>(0, pLoopCity->unhappyLevel() - pLoopCity->happyLevel());
int baseHappy = std::min<int>(node.baseHappy, unhappyCitizens);
// have we got any left?
unhappyCitizens = std::max<int>(0, unhappyCitizens - baseHappy);
if (unhappyCitizens == 0)
{
unusedHappy += node.baseHappy - baseHappy;
}
actualHappy += baseHappy;
for (size_t i = 0, count = info.buildingHappy.size(); i < count; ++i)
{
int buildingCount = pLoopCity->getNumBuilding(info.buildingHappy[i].first);
if (buildingCount > 0)
{
int thisBuildingCount = std::min<int>(buildingCount * info.buildingHappy[i].second, unhappyCitizens);
unhappyCitizens = std::max<int>(0, unhappyCitizens - thisBuildingCount);
if (unhappyCitizens == 0)
{
unusedHappy += buildingCount * info.buildingHappy[i].second - thisBuildingCount;
}
actualHappy += thisBuildingCount;
}
else // just assumes one building allowed (should use getCITY_MAX_NUM_BUILDINGS(), but this would be wrong if building is limited in some other way, e.g. wonders)
{
potentialHappy += info.buildingHappy[i].second;
}
}
}
info.actualHappy = actualHappy;
info.potentialHappy = potentialHappy;
info.unusedHappy = unusedHappy;
}
示例10: GET_PLAYER
//------------------------------------------------------------------------------
void CvDllNetMessageHandler::ResponseFaithGreatPersonChoice(PlayerTypes ePlayer, UnitTypes eGreatPersonUnit)
{
CvPlayerAI& kPlayer = GET_PLAYER(ePlayer);
CvCity* pCity = kPlayer.GetGreatPersonSpawnCity(eGreatPersonUnit);
if(pCity)
{
pCity->GetCityCitizens()->DoSpawnGreatPerson(eGreatPersonUnit, true, true);
}
kPlayer.ChangeNumFaithGreatPeople(-1);
}
示例11: GET_PLAYER
void CvNetDoTask::Execute()
{
if (m_ePlayer != NO_PLAYER)
{
CvCity* pCity = GET_PLAYER(m_ePlayer).getCity(m_iCityID);
if (pCity != NULL)
{
pCity->doTask(m_eTask, m_iData1, m_iData2, m_bOption, m_bAlt, m_bShift, m_bCtrl);
}
}
}
示例12: GET_PLAYER
// Can this tile be attacked by an enemy unit or city next turn?
bool CvDangerPlotContents::IsUnderImmediateThreat(const CvUnit* pUnit)
{
if (!m_pPlot || !pUnit)
return false;
// Air units operate off of intercepts instead of units/cities that can attack them
if (pUnit->getDomainType() == DOMAIN_AIR)
{
if (pUnit->GetBestInterceptor(*m_pPlot))
{
return true;
}
}
else
{
// Cities in range
for (DangerCityVector::iterator it = m_apCities.begin(); it < m_apCities.end(); ++it)
{
CvCity* pCity = GET_PLAYER(it->first).getCity(it->second);
if (pCity && pCity->getTeam() != pUnit->getTeam())
{
return true;
}
}
// Units in range
for (DangerUnitVector::iterator it = m_apUnits.begin(); it < m_apUnits.end(); ++it)
{
CvUnit* pUnit = GET_PLAYER(it->first).getUnit(it->second);
if (pUnit && !pUnit->isDelayedDeath() && !pUnit->IsDead())
{
return true;
}
}
// Citadel etc in range
if (GetDamageFromFeatures(pUnit->getOwner()) > 0)
{
return true;
}
}
// Terrain damage is greater than heal rate
int iMinimumDamage = m_bFlatPlotDamage ? m_pPlot->getTurnDamage(pUnit->ignoreTerrainDamage(), pUnit->ignoreFeatureDamage(), pUnit->extraTerrainDamage(), pUnit->extraFeatureDamage()) : 0;
if (pUnit->canHeal(m_pPlot))
{
iMinimumDamage -= pUnit->healRate(m_pPlot);
}
return (iMinimumDamage > 0);
}
示例13: GetBaseBuildingGoldMaintenance
/// What are our gold maintenance costs because of Buildings?
int CvTreasury::GetBuildingGoldMaintenance() const
{
int iMaintenance = GetBaseBuildingGoldMaintenance();
// Player modifier
iMaintenance *= (100 + m_pPlayer->GetBuildingGoldMaintenanceMod());
iMaintenance /= 100;
#if defined(MOD_BALANCE_CORE)
iMaintenance *= (100 + m_pPlayer->GetBuildingMaintenanceMod());
iMaintenance /= 100;
#endif
// Modifier for difficulty level
CvHandicapInfo& playerHandicap = m_pPlayer->getHandicapInfo();
//iMaintenance *= playerHandicap->getBuildingCostPercent();
//iMaintenance /= 100;
// Human bonus for Building maintenance costs
if(m_pPlayer->isHuman())
{
iMaintenance *= playerHandicap.getBuildingCostPercent();
iMaintenance /= 100;
}
// AI bonus for Building maintenance costs
else if(!m_pPlayer->IsAITeammateOfHuman())
{
iMaintenance *= GC.getGame().getHandicapInfo().getAIBuildingCostPercent();
iMaintenance /= 100;
}
// Start Era mod
iMaintenance *= GC.getGame().getStartEraInfo().getBuildingMaintenancePercent();
iMaintenance /= 100;
#if defined(MOD_BALANCE_CORE)
if(MOD_BALANCE_CORE_BUILDING_RESOURCE_MAINTENANCE)
{
CvCity* pLoopCity;
int iLoop;
for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))
{
if(pLoopCity->GetExtraBuildingMaintenance() > 0)
{
iMaintenance *= (100 + pLoopCity->GetExtraBuildingMaintenance());
iMaintenance /= 100;
}
}
}
#endif
return iMaintenance;
}
示例14: pCity
//------------------------------------------------------------------------------
int CvDllGameContext::GetNUM_CITY_PLOTS() const
{
int iNumCityPlots = AVG_CITY_PLOTS;
auto_ptr<ICvCity1> pCity(GC.GetEngineUserInterface()->getHeadSelectedCity());
if (pCity.get() != NULL) {
CvCity* pkCity = GC.UnwrapCityPointer(pCity.get());
iNumCityPlots = pkCity->GetNumWorkablePlots();
}
return iNumCityPlots;
}
示例15:
// Gold from Cities times 100
int CvTreasury::GetGoldFromCitiesTimes100(bool bExcludeTradeRoutes) const
{
int iGold = 0;
CvCity* pLoopCity;
int iLoop;
for(pLoopCity = m_pPlayer->firstCity(&iLoop); pLoopCity != NULL; pLoopCity = m_pPlayer->nextCity(&iLoop))
{
iGold += pLoopCity->getYieldRateTimes100(YIELD_GOLD, bExcludeTradeRoutes);
}
return iGold;
}