CvDiplomacyAI::IsCanMakeResearchAgreementRightNow(PlayerTypes)
- Defined in
- CvDiplomacyAI.cpp, line 7526
- Class
- CvDiplomacyAI
- Hook name
CivHooks::CvDiplomacyAI_IsCanMakeResearchAgreementRightNow
Hooks
static bool BeforeCvDiplomacyAI_IsCanMakeResearchAgreementRightNow(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static void AfterCvDiplomacyAI_IsCanMakeResearchAgreementRightNow(CvDiplomacyAI* self, PlayerTypes ePlayer, bool& result);static bool ReplaceCvDiplomacyAI_IsCanMakeResearchAgreementRightNow(bool (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsCanMakeResearchAgreementRightNow>(host, &BeforeCvDiplomacyAI_IsCanMakeResearchAgreementRightNow);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsCanMakeResearchAgreementRightNow>(host, &AfterCvDiplomacyAI_IsCanMakeResearchAgreementRightNow);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsCanMakeResearchAgreementRightNow>(host, &ReplaceCvDiplomacyAI_IsCanMakeResearchAgreementRightNow);
Code
7525/// Are we able to make a Research Agreement with ePlayer right now?7526bool CvDiplomacyAI::IsCanMakeResearchAgreementRightNow(PlayerTypes ePlayer)7527{7528 CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");7529 CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");75307531 // Either side already have all techs?7532 if(GET_TEAM(GetPlayer()->getTeam()).GetTeamTechs()->HasResearchedAllTechs() || GET_TEAM(GET_PLAYER(ePlayer).getTeam()).GetTeamTechs()->HasResearchedAllTechs())7533 {7534 return false;7535 }75367537 // We don't want a RA with this guy7538 if(!IsWantsResearchAgreementWithPlayer(ePlayer))7539 {7540 return false;7541 }75427543 // Already have a RA?7544 if(GET_TEAM(GetPlayer()->getTeam()).IsHasResearchAgreement(GET_PLAYER(ePlayer).getTeam()))7545 {7546 return false;7547 }75487549 // Can we have a research agreement right now?7550 if(!(GET_TEAM(GetPlayer()->getTeam()).IsResearchAgreementTradingAllowedWithTeam(GET_PLAYER(ePlayer).getTeam()) || // We have Tech & embassy to make a RA7551 GET_TEAM(GET_PLAYER(ePlayer).getTeam()).IsResearchAgreementTradingAllowedWithTeam(GetPlayer()->getTeam()))) // They have Tech & embassy to make RA7552 {7553 return false;7554 }75557556 int iGoldAmount = GC.getGame().GetGameDeals()->GetTradeItemGoldCost(TRADE_ITEM_RESEARCH_AGREEMENT, GetPlayer()->GetID(), ePlayer);75577558 // We don't have enough Gold7559 if(GetPlayer()->GetTreasury()->GetGold() < iGoldAmount)7560 {7561 return false;7562 }75637564 // They don't have enough Gold7565 if(GET_PLAYER(ePlayer).GetTreasury()->GetGold() < iGoldAmount)7566 {7567 return false;7568 }75697570 return true;7571}
Calls
- CvDiplomacyAI::GetPlayer()
- CvDiplomacyAI::IsWantsResearchAgreementWithPlayer(PlayerTypes) const
- CvGame::GetGameDeals()
- CvGameDeals::GetTradeItemGoldCost(TradeableItems, PlayerTypes, PlayerTypes) const
- CvGlobals::getGame()
- CvPlayer::GetID() const
- CvPlayer::getTeam() const
- CvPlayer::GetTreasury() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvTeam::getTeam(TeamTypes)
- CvTeam::GetTeamTechs() const
- CvTeam::IsHasResearchAgreement(TeamTypes) const
- CvTeam::IsResearchAgreementTradingAllowedWithTeam(TeamTypes) const
- CvTeamTechs::HasResearchedAllTechs() const
- CvTreasury::GetGold() const