|
楼主 |
发表于 2013-11-19 07:10:57
|
显示全部楼层
/// What would the unhappiness be if we chose this Ideology?//根据不满等级计算红脸数
int CvPlayerCulture::ComputeHypotheticalPublicOpinionUnhappiness(PolicyBranchTypes eBranch)
{
int iDissatisfaction = 0;
PolicyBranchTypes eFreedomBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_FREEDOM();
PolicyBranchTypes eAutocracyBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_AUTOCRACY();
PolicyBranchTypes eOrderBranch = (PolicyBranchTypes)GC.getPOLICY_BRANCH_ORDER();
if (eFreedomBranch == NO_POLICY_BRANCH_TYPE || eAutocracyBranch == NO_POLICY_BRANCH_TYPE || eOrderBranch == NO_POLICY_BRANCH_TYPE)
{
return 0;
}
// Start with World Congress
int iPressureForFreedom = GC.getGame().GetGameLeagues()->GetPressureForIdeology(m_pPlayer->GetID(), eFreedomBranch);
int iPressureForAutocracy = GC.getGame().GetGameLeagues()->GetPressureForIdeology(m_pPlayer->GetID(), eAutocracyBranch);
int iPressureForOrder = GC.getGame().GetGameLeagues()->GetPressureForIdeology(m_pPlayer->GetID(), eOrderBranch);
// Look at each civ
for (int iLoopPlayer = 0; iLoopPlayer < MAX_MAJOR_CIVS; iLoopPlayer++)
{
CvPlayer &kPlayer = GET_PLAYER((PlayerTypes)iLoopPlayer);
if (iLoopPlayer != m_pPlayer->GetID() && kPlayer.isAlive() && !kPlayer.isMinorCiv())
{
PolicyBranchTypes eOtherCivIdeology = kPlayer.GetPlayerPolicies()->GetLateGamePolicyTree();
if (eOtherCivIdeology != NO_POLICY_BRANCH_TYPE)
{
int iCulturalDominanceOverUs = kPlayer.GetCulture()->GetInfluenceLevel(m_pPlayer->GetID()) - m_pPlayer->GetCulture()->GetInfluenceLevel((PlayerTypes)iLoopPlayer);
if (iCulturalDominanceOverUs > 0)
{
if (eOtherCivIdeology == eFreedomBranch)
{
iPressureForFreedom += iCulturalDominanceOverUs;
}
else if (eOtherCivIdeology == eAutocracyBranch)
{
iPressureForAutocracy += iCulturalDominanceOverUs;
}
else
{
iPressureForOrder += iCulturalDominanceOverUs;
}
}
}
}
}
if (eBranch == eFreedomBranch)
{
if (iPressureForFreedom < (iPressureForAutocracy + iPressureForOrder))
{
if (iPressureForAutocracy > iPressureForOrder)
{
m_ePreferredIdeology = eAutocracyBranch;
}
else if (iPressureForOrder >= iPressureForAutocracy)
{
m_ePreferredIdeology = eOrderBranch;
}
iDissatisfaction = (iPressureForAutocracy + iPressureForOrder) - iPressureForFreedom;
}
}
else if (eBranch == eAutocracyBranch)
{
if (iPressureForAutocracy < (iPressureForFreedom + iPressureForOrder))
{
if (iPressureForFreedom >= iPressureForOrder)
{
m_ePreferredIdeology = eFreedomBranch;
}
else if (iPressureForOrder > iPressureForFreedom)
{
m_ePreferredIdeology = eOrderBranch;
}
iDissatisfaction = (iPressureForFreedom + iPressureForOrder) - iPressureForAutocracy;
}
}
else
{
if (iPressureForOrder < (iPressureForFreedom + iPressureForAutocracy))
{
if (iPressureForFreedom > iPressureForAutocracy)
{
m_ePreferredIdeology = eFreedomBranch;
}
else if (iPressureForAutocracy >= iPressureForFreedom)
{
m_ePreferredIdeology = eAutocracyBranch;
}
iDissatisfaction = (iPressureForFreedom + iPressureForAutocracy) - iPressureForOrder;
}
}
int iPerCityUnhappy = 1;
int iUnhappyPerXPop = 10;
if (iDissatisfaction == 0)
{
return 0;
}
else
{
return ComputePublicOpinionUnhappiness(iDissatisfaction, iPerCityUnhappy, iUnhappyPerXPop);//调用红脸计算过程
}
}
/// Compute effects of dissatisfaction//分别根据城市数量和人口数量计算红脸,取两种算法最大值
//每城红脸和人口红脸分数分别为:秉持异议1和10,和平抗争2和5,革命浪潮4和3
int CvPlayerCulture::ComputePublicOpinionUnhappiness(int iDissatisfaction, int &iPerCityUnhappy, int &iUnhappyPerXPop)
{
if (iDissatisfaction < 3)
{
iPerCityUnhappy = 1;
iUnhappyPerXPop = 10;
}
else if (iDissatisfaction < 5)
{
iPerCityUnhappy = 2;
iUnhappyPerXPop = 5;
}
else
{
iPerCityUnhappy = 4;
iUnhappyPerXPop = 3;
}
return max(m_pPlayer->getNumCities() * iPerCityUnhappy, m_pPlayer->getTotalPopulation() / iUnhappyPerXPop);
} |
|