當前位置: 首頁>>代碼示例>>Python>>正文


Python PlayerUtil.isGivingFavoriteCivicDenial方法代碼示例

本文整理匯總了Python中PlayerUtil.isGivingFavoriteCivicDenial方法的典型用法代碼示例。如果您正苦於以下問題:Python PlayerUtil.isGivingFavoriteCivicDenial方法的具體用法?Python PlayerUtil.isGivingFavoriteCivicDenial怎麽用?Python PlayerUtil.isGivingFavoriteCivicDenial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PlayerUtil的用法示例。


在下文中一共展示了PlayerUtil.isGivingFavoriteCivicDenial方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: doUpdate

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import isGivingFavoriteCivicDenial [as 別名]
def doUpdate ():
	""" Goes through the current diplomacy situation to determine potential favorite civics for each civ. """
	if gDetectionNecessary:
		BugUtil.debug("FavoriteCivicDetector.doUpdate() START")
		pActivePlayer = gc.getActivePlayer()
		pActiveTeam = gc.getTeam(pActivePlayer.getTeam())
		for iPlayer in range(gc.getMAX_PLAYERS()):
			pPlayer = gc.getPlayer(iPlayer)
			# Player we are updating must be a valid, living, non-human, full-fledged civ.
			if ( pPlayer and (not pPlayer.isNone()) and pPlayer.isAlive() and (not pPlayer.isHuman())
				 and (not pPlayer.isBarbarian()) and (not pPlayer.isMinorCiv()) ):
				BugUtil.debug("Updating Info for Player %d (%s)" % (iPlayer, pPlayer.getName()))
				iTeam = pPlayer.getTeam()
				pTeam = gc.getTeam(iTeam)
				# Team assumed valid, living, etc. since the player was.
				if (not pActiveTeam.isHasMet(iTeam)):
					BugUtil.debug(" -- Skipping; active team has not met team we are updating")
					continue
				favorite = gFavoriteByPlayer[iPlayer]
				# Check Diplomacy first (if necessary)
				if not favorite.isKnown():
					if PlayerUtil.isGivingFavoriteCivicDenial(pPlayer, pActivePlayer):
						BugUtil.debug(" -- Player showing FAVORITE_CIVIC trade denial; must be running his/her favorite." )
						for eCategory in range(gc.getNumCivicOptionInfos()):
							eCivic = pPlayer.getCivics(eCategory)
							for eOtherCivic in gCivicsByCategory[eCategory]:
								if (eOtherCivic != eCivic):
									favorite.removePossible(eOtherCivic)
				# Now take Attitude survey (if necessary)
				if not favorite.isKnown():
					for iOtherPlayer in range(gc.getMAX_PLAYERS()):
						pOtherPlayer = gc.getPlayer(iOtherPlayer)
						# Test attitude against other valid, living, full-fledged civs; these can be human
						if ( pOtherPlayer and (iOtherPlayer != iPlayer) 
							 and (not pOtherPlayer.isNone()) and pOtherPlayer.isAlive() 
							 and (not pOtherPlayer.isBarbarian()) and (not pOtherPlayer.isMinorCiv()) ):
							BugUtil.debug(" -- Testing against Player %d (%s)" % (iOtherPlayer, pOtherPlayer.getName()))
							iOtherTeam = pOtherPlayer.getTeam()
							if ( (not pActiveTeam.isHasMet(iOtherTeam)) or (not pTeam.isHasMet(iOtherTeam)) ):
								BugUtil.debug("     -- Skipping; either active team or updating team has not met test team")
								continue
							pAttitude = AttitudeUtil.Attitude(iPlayer, iOtherPlayer)
							bFoundPossibleFavorite = pAttitude.hasModifier("TXT_KEY_MISC_ATTITUDE_FAVORITE_CIVIC")
							for eCategory in range(gc.getNumCivicOptionInfos()):
								eCivic = pPlayer.getCivics(eCategory)
								if (eCivic == pOtherPlayer.getCivics(eCategory)):
									if bFoundPossibleFavorite:
										BugUtil.debug("     -- Players share civic %d (%s) and %s is giving the diplo modifier." 
													  % (eCivic, gc.getCivicInfo(eCivic).getText(), pPlayer.getName()))
										BugUtil.debug("         -- This is the only possible favorite in category %d (%s)." 
													  % (eCategory, gc.getCivicOptionInfo(eCategory).getText()))
										for eOtherCivic in gCivicsByCategory[eCategory]:
											if (eOtherCivic != eCivic):
												favorite.removePossible(eOtherCivic)
									else:
										BugUtil.debug("     -- Players share civic %d (%s) but %s is NOT giving the diplo modifier." 
													  % (eCivic, gc.getCivicInfo(eCivic).getText(), pPlayer.getName()))
										BugUtil.debug("         -- This one must be ruled out as a possible favorite.")
										favorite.removePossible(eCivic)
								else:
									if bFoundPossibleFavorite:
										BugUtil.debug("     -- Players do NOT share civic %d (%s) but %s is giving the diplo modifier." 
													  % (eCivic, gc.getCivicInfo(eCivic).getText(), pPlayer.getName()))
										BugUtil.debug("         -- All civics in category %d (%s) must be ruled out." 
													  % (eCategory, gc.getCivicOptionInfo(eCategory).getText()))
										for eOtherCivic in gCivicsByCategory[eCategory]:
											favorite.removePossible(eOtherCivic)
									else:
										BugUtil.debug("     -- Players do NOT share civic %d (%s) and %s is NOT giving the diplo modifier." 
													  % (eCivic, gc.getCivicInfo(eCivic).getText(), pPlayer.getName()))
										BugUtil.debug("         -- This doesn't tell us anything new.") 
				BugUtil.debug(" -- Finished update for %s: %s" % (pPlayer.getName(), str(favorite)))
開發者ID:hardtimes1966,項目名稱:modxml,代碼行數:74,代碼來源:FavoriteCivicDetector.py


注:本文中的PlayerUtil.isGivingFavoriteCivicDenial方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。