Esempio n. 1
0
/// Priority for opening up this branch
int CvPolicyAI::WeighBranch(PolicyBranchTypes eBranch)
{
    int iWeight = 0;

    CvPolicyBranchEntry* pkPolicyBranchInfo = GC.getPolicyBranchInfo(eBranch);
    if(pkPolicyBranchInfo)
    {
        for(int iPolicyLoop = 0; iPolicyLoop < m_pCurrentPolicies->GetPolicies()->GetNumPolicies(); iPolicyLoop++)
        {
            const PolicyTypes ePolicyLoop = static_cast<PolicyTypes>(iPolicyLoop);
            CvPolicyEntry* pkLoopPolicyInfo = GC.getPolicyInfo(ePolicyLoop);
            if(pkLoopPolicyInfo)
            {
                // Policy we don't have?
                if(!m_pCurrentPolicies->HasPolicy(ePolicyLoop))
                {
                    // From this branch we are considering opening?
                    if(pkLoopPolicyInfo->GetPolicyBranchType() == eBranch)
                    {
                        // With no prereqs?
                        if(pkLoopPolicyInfo->GetPrereqAndPolicies(0) == NO_POLICY)
                        {
                            iWeight += m_PolicyAIWeights.GetWeight(iPolicyLoop);
                        }
                    }
                }
            }
        }

        // Add weight of free policy from branch
        iWeight += m_PolicyAIWeights.GetWeight(pkPolicyBranchInfo->GetFreePolicy());
    }

    return iWeight;
}