CvPlayerPolicies::DoPolicyAI()
- Defined in
- CvPolicyClasses.cpp, line 4704
- Class
- CvPlayerPolicies
- Hook name
CivHooks::CvPlayerPolicies_DoPolicyAI
Hooks
static bool BeforeCvPlayerPolicies_DoPolicyAI(CvPlayerPolicies* self);static void AfterCvPlayerPolicies_DoPolicyAI(CvPlayerPolicies* self);static void ReplaceCvPlayerPolicies_DoPolicyAI(void (*original)(CvPlayerPolicies*), CvPlayerPolicies* self);CivRegisterBefore<CivHooks::CvPlayerPolicies_DoPolicyAI>(host, &BeforeCvPlayerPolicies_DoPolicyAI);CivRegisterAfter<CivHooks::CvPlayerPolicies_DoPolicyAI>(host, &AfterCvPlayerPolicies_DoPolicyAI);CivRegisterReplace<CivHooks::CvPlayerPolicies_DoPolicyAI>(host, &ReplaceCvPlayerPolicies_DoPolicyAI);
Code
4703/// Update the policy AI for the turn4704void CvPlayerPolicies::DoPolicyAI()4705{4706 CvString strBuffer;47074708 m_pPolicyAI->DoConsiderIdeologySwitch(m_pPlayer);47094710 // Do we have enough points to buy a new policy?4711 if(m_pPlayer->getNextPolicyCost() > 0)4712 {4713 // Adopt new policies until we run out of freebies and culture (usually only one per turn)4714 while(m_pPlayer->getJONSCulture() >= m_pPlayer->getNextPolicyCost() || m_pPlayer->GetNumFreePolicies() > 0 || m_pPlayer->GetNumFreeTenets() > 0)4715 {4716 // Choose the policy we want next (or a branch)4717 int iNextPolicy = m_pPolicyAI->ChooseNextPolicy(m_pPlayer);4718 if (iNextPolicy == NO_POLICY)4719 break;47204721 // These actions should spend our number of free policies or our culture, otherwise we'll loop forever4722 if(iNextPolicy < m_pPolicies->GetNumPolicyBranches()) // Low return values indicate a branch has been chosen4723 {4724 m_pPlayer->GetPlayerPolicies()->DoUnlockPolicyBranch((PolicyBranchTypes)iNextPolicy);4725 }4726 else4727 {4728 m_pPlayer->doAdoptPolicy((PolicyTypes)(iNextPolicy - m_pPolicies->GetNumPolicyBranches()));4729 }4730 }4731 }4732}
Calls
- CvPlayer::doAdoptPolicy(PolicyTypes)
- CvPlayer::getJONSCulture() const
- CvPlayer::getNextPolicyCost() const
- CvPlayer::GetNumFreePolicies() const
- CvPlayer::GetNumFreeTenets() const
- CvPlayer::GetPlayerPolicies() const
- CvPlayerPolicies::DoUnlockPolicyBranch(PolicyBranchTypes)
- CvPolicyAI::ChooseNextPolicy(CvPlayer *)
- CvPolicyAI::DoConsiderIdeologySwitch(CvPlayer *)
- CvPolicyXMLEntries::GetNumPolicyBranches()
CvString::CvString