Bazaar developer reference

CvGameLeagues::DoPlayerTurn(CvPlayer &)

Defined in
CvVotingClasses.cpp, line 6867
Class
CvGameLeagues
Hook name
CivHooks::CvGameLeagues_DoPlayerTurn
Lua events
GameEvents.ResolutionProposing, GameEvents.ResolutionVoting

Hooks

static bool BeforeCvGameLeagues_DoPlayerTurn(CvGameLeagues* self, CvPlayer& kPlayer);static void AfterCvGameLeagues_DoPlayerTurn(CvGameLeagues* self, CvPlayer& kPlayer);static void ReplaceCvGameLeagues_DoPlayerTurn(void (*original)(CvGameLeagues*, CvPlayer&), CvGameLeagues* self, CvPlayer& kPlayer);CivRegisterBefore<CivHooks::CvGameLeagues_DoPlayerTurn>(host, &BeforeCvGameLeagues_DoPlayerTurn);CivRegisterAfter<CivHooks::CvGameLeagues_DoPlayerTurn>(host, &AfterCvGameLeagues_DoPlayerTurn);CivRegisterReplace<CivHooks::CvGameLeagues_DoPlayerTurn>(host, &ReplaceCvGameLeagues_DoPlayerTurn);

Code

6867void CvGameLeagues::DoPlayerTurn(CvPlayer& kPlayer)6868{6869	if (!GC.getGame().isOption(GAMEOPTION_NO_LEAGUES))6870	{6871		AI_PERF_FORMAT("AI-perf.csv", ("CvGameLeagues::DoPlayerTurn, Turn %03d, %s", GC.getGame().getElapsedGameTurns(), kPlayer.getCivilizationShortDescription()) );6872		for (LeagueList::iterator it = m_vActiveLeagues.begin(); it != m_vActiveLeagues.end(); it++)6873		{6874			if (it->IsMember(kPlayer.GetID()))6875			{6876				// Call for Proposals6877				if (it->CanPropose(kPlayer.GetID()))6878				{6879					if (kPlayer.isHuman())6880					{6881						CvNotifications* pNotifications = kPlayer.GetNotifications();6882						if (pNotifications)6883						{6884							CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_LEAGUE_PROPOSALS_NEEDED");68856886							Localization::String strTemp = Localization::Lookup("TXT_KEY_NOTIFICATION_LEAGUE_PROPOSALS_NEEDED_TT");6887							strTemp << it->GetName();6888							CvString strInfo = strTemp.toUTF8();68896890							pNotifications->Add(NOTIFICATION_LEAGUE_CALL_FOR_PROPOSALS, strInfo, strSummary, -1, -1, it->GetID());6891						}				6892					}6893					else6894					{6895#if defined(MOD_EVENTS_RESOLUTIONS)6896						bool bAllUsed = false;6897						6898						if (MOD_EVENTS_RESOLUTIONS) {6899							if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_ResolutionProposing, kPlayer.GetID(), it->GetID()) == GAMEEVENTRETURN_TRUE) {6900								bAllUsed = true;6901							}6902						}6903						6904						if (!bAllUsed)6905#endif6906						kPlayer.GetLeagueAI()->DoProposals(it);6907					}6908				}6909				// Call for Votes and other Session actions6910				else if (it->IsInSession())6911				{6912					// Honor vote commitments made in deals before spending any other votes6913					kPlayer.GetLeagueAI()->DoVoteCommitments(it);69146915					// Allocate free votes6916					if (it->CanVote(kPlayer.GetID()))6917					{6918						if (it->IsAnythingProposed())6919						{6920							if (kPlayer.isHuman())6921							{6922								CvNotifications* pNotifications = kPlayer.GetNotifications();6923								if (pNotifications)6924								{6925									CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_LEAGUE_VOTES_NEEDED");69266927									Localization::String strTemp = Localization::Lookup("TXT_KEY_NOTIFICATION_LEAGUE_VOTES_NEEDED_TT");6928									strTemp << it->GetName();6929									CvString strInfo = strTemp.toUTF8();69306931									pNotifications->Add(NOTIFICATION_LEAGUE_CALL_FOR_VOTES, strInfo, strSummary, -1, -1, it->GetID());6932								}6933							}6934							else6935							{6936#if defined(MOD_EVENTS_RESOLUTIONS)6937								bool bAllUsed = false;6938								6939								if (MOD_EVENTS_RESOLUTIONS && it->GetRemainingVotesForMember(kPlayer.GetID()) > 0) {6940									if (GAMEEVENTINVOKE_TESTANY(GAMEEVENT_ResolutionVoting, kPlayer.GetID(), it->GetID()) == GAMEEVENTRETURN_TRUE) {6941										bAllUsed = true;6942									}6943								}6944						6945								if (!bAllUsed)6946#endif6947								6948								kPlayer.GetLeagueAI()->DoVotes(it);6949							}6950						}6951						else6952						{6953							kPlayer.GetLeagueAI()->DoAbstainAllVotes(it);6954						}6955					}6956				}6957			}6958		}6959	}6960}

Calls

Called by