CvLeagueAI::ScoreVoteChoicePlayer(CvProposal *, int, bool)
- Defined in
- CvVotingClasses.cpp, line 9603
- Class
- CvLeagueAI
- Hook name
CivHooks::CvLeagueAI_ScoreVoteChoicePlayer
Hooks
static bool BeforeCvLeagueAI_ScoreVoteChoicePlayer(CvLeagueAI* self, CvProposal* pProposal, int iChoice, bool bEnact, int& result);static void AfterCvLeagueAI_ScoreVoteChoicePlayer(CvLeagueAI* self, CvProposal* pProposal, int iChoice, bool bEnact, int& result);static int ReplaceCvLeagueAI_ScoreVoteChoicePlayer(int (*original)(CvLeagueAI*, CvProposal*, int, bool), CvLeagueAI* self, CvProposal* pProposal, int iChoice, bool bEnact);CivRegisterBefore<CivHooks::CvLeagueAI_ScoreVoteChoicePlayer>(host, &BeforeCvLeagueAI_ScoreVoteChoicePlayer);CivRegisterAfter<CivHooks::CvLeagueAI_ScoreVoteChoicePlayer>(host, &AfterCvLeagueAI_ScoreVoteChoicePlayer);CivRegisterReplace<CivHooks::CvLeagueAI_ScoreVoteChoicePlayer>(host, &ReplaceCvLeagueAI_ScoreVoteChoicePlayer);
Code
9602// Score a particular choice on a particular proposal which is a decision between players (ex. Choose Host, World Leader)9603int CvLeagueAI::ScoreVoteChoicePlayer(CvProposal* pProposal, int iChoice, bool bEnact)9604{9605 CvAssert(pProposal != NULL);9606 if (!(pProposal != NULL)) return 0;9607 CvAssertMsg(bEnact, "Unexpected case when evaluating vote choices for AI. Please send Anton your save file and version.");9608 if (!bEnact) return 0;9609 PlayerTypes eChoicePlayer = (PlayerTypes) iChoice;9610 CvAssert(eChoicePlayer != NO_PLAYER);9611 if (!(eChoicePlayer != NO_PLAYER)) return 0;9612 CvLeague* pLeague = GC.getGame().GetGameLeagues()->GetActiveLeague();9613 CvAssert(pLeague != NULL);9614 if (!(pLeague != NULL)) return 0;96159616 // How much do we like this choice for this proposal? Positive is like, negative is dislike9617 int iScore = 0;96189619 // == Grand Strategy and other factors ==9620 AIGrandStrategyTypes eGrandStrategy = GetPlayer()->GetGrandStrategyAI()->GetActiveGrandStrategy();9621 bool bSeekingDiploVictory = eGrandStrategy == GC.getInfoTypeForString("AIGRANDSTRATEGY_UNITED_NATIONS");96229623 // == Diplomatic Victory ==9624 if (pProposal->GetEffects()->bDiplomaticVictory)9625 {9626 AlignmentLevels eAlignment = EvaluateAlignment(eChoicePlayer);96279628 if (eAlignment == ALIGNMENT_LIBERATOR)9629 {9630 iScore += 200;9631 }9632 else if (eAlignment == ALIGNMENT_LEADER)9633 {9634 iScore += 150;9635 }9636 else if (eAlignment == ALIGNMENT_SELF)9637 {9638 iScore += 100;9639 }9640 else if (eAlignment == ALIGNMENT_WAR)9641 {9642 iScore += -500;9643 }9644 else9645 {9646 iScore += -50;96479648 if (bSeekingDiploVictory)9649 {9650 iScore += -150;9651 }96529653 // Don't hand victory to someone9654 if (pLeague->CalculateStartingVotesForMember(GetPlayer()->GetID()) + pLeague->CalculateStartingVotesForMember(eChoicePlayer) + 49655 >= GC.getGame().GetVotesNeededForDiploVictory())9656 {9657 iScore += -150;9658 }9659 9660 switch (eAlignment)9661 {9662 case ALIGNMENT_ALLY:9663 iScore += 70;9664 break;9665 case ALIGNMENT_CONFIDANT:9666 iScore += 50;9667 break;9668 case ALIGNMENT_FRIEND:9669 iScore += 30;9670 break;9671 case ALIGNMENT_RIVAL:9672 iScore += -30;9673 break;9674 case ALIGNMENT_HATRED:9675 iScore += -50;9676 break;9677 case ALIGNMENT_ENEMY:9678 iScore += -70;9679 break;9680 default:9681 break;9682 }9683 }9684 }96859686 // == Choose Host ==9687 // Mostly same as evaluating Diplomatic Victory, but with higher value to pick others you like9688 if (pProposal->GetEffects()->bChangeLeagueHost)9689 {9690 AlignmentLevels eAlignment = EvaluateAlignment(eChoicePlayer);96919692 if (eAlignment == ALIGNMENT_LIBERATOR)9693 {9694 iScore += 200;9695 }9696 else if (eAlignment == ALIGNMENT_SELF)9697 {9698 iScore += 100;9699 }9700 else if (eAlignment == ALIGNMENT_LEADER)9701 {9702 iScore += 50;9703 }9704 else if (eAlignment == ALIGNMENT_WAR)9705 {9706 iScore += -500;9707 }9708 else9709 {9710 if (bSeekingDiploVictory)9711 {9712 iScore += -150;9713 }97149715 switch (eAlignment)9716 {9717 case ALIGNMENT_ALLY:9718 iScore += 130;9719 break;9720 case ALIGNMENT_CONFIDANT:9721 iScore += 90;9722 break;9723 case ALIGNMENT_FRIEND:9724 iScore += 50;9725 break;9726 case ALIGNMENT_RIVAL:9727 iScore += -50;9728 break;9729 case ALIGNMENT_HATRED:9730 iScore += -90;9731 break;9732 case ALIGNMENT_ENEMY:9733 iScore += -130;9734 break;9735 default:9736 break;9737 }9738 }9739 }97409741 return iScore;9742}
Calls
- CvGame::GetGameLeagues()
- CvGame::GetVotesNeededForDiploVictory() const
- CvGameLeagues::GetActiveLeague()
- CvGlobals::getGame()
- CvGlobals::getInfoTypeForString(const char *, bool) const
- CvGrandStrategyAI::GetActiveGrandStrategy() const
- CvLeague::CalculateStartingVotesForMember(PlayerTypes, bool)
- CvLeagueAI::EvaluateAlignment(PlayerTypes)
- CvLeagueAI::GetPlayer()
- CvPlayer::GetGrandStrategyAI() const
- CvPlayer::GetID() const
- CvResolution::GetEffects()