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


Python PlayerUtil.getPlayerID方法代碼示例

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


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

示例1: isWillingToTalk

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import getPlayerID [as 別名]
def isWillingToTalk(playerOrID, toPlayerOrID):
	"""
	Returns True if <player> is willing to talk to <toPlayer>.
	
	- Every player is willing to talk to themselves
	- All human players are willing to talk
	- Uses BUG DLL if present, otherwise scans attitude hover text
	  for "Refuses to Talk!!!" in the current language
	
	Note: This function does not check if the two players can make contact.
	"""
	playerID, player = PlayerUtil.getPlayerAndID(playerOrID)
	toPlayerID = PlayerUtil.getPlayerID(toPlayerOrID)
	# if playerID == toPlayerID or player.isHuman():
		# # all players talk to themselves, and all humans talk
		# return True
	# if BugDll.isPresent():
		# return player.AI_isWillingToTalk(toPlayerID)
	# else:
		# hover = AttitudeUtil.getAttitudeString(playerID, toPlayerID)
		# if hover:
			# return (hover.find(BugUtil.getPlainText("TXT_KEY_MISC_REFUSES_TO_TALK")) == -1)
		# else:
			# # haven't met yet
			# return False
	# K-Mod
	return playerID == toPlayerID or player.AI_isWillingToTalk(toPlayerID)
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:29,代碼來源:DiplomacyUtil.py

示例2: getTradeableBonuses

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import getPlayerID [as 別名]
def getTradeableBonuses(fromPlayerOrID, toPlayerOrID):
	"""
	Returns two sets of bonus IDs that <fromPlayer> will and won't trade to <toPlayer>.
	
	Assumes that the two players can trade bonuses.
	"""
	fromPlayer = PlayerUtil.getPlayer(fromPlayerOrID)
	eToPlayer = PlayerUtil.getPlayerID(toPlayerOrID)
	fromPlayerIsHuman = fromPlayer.isHuman()
	will = set()
	wont = set()
	tradeData = TradeData()
	tradeData.ItemType = TradeableItems.TRADE_RESOURCES
	for eBonus in range(gc.getNumBonusInfos()):
		tradeData.iData = eBonus
		if fromPlayer.canTradeItem(eToPlayer, tradeData, False):
			if fromPlayerIsHuman or fromPlayer.canTradeItem(eToPlayer, tradeData, True):
				will.add(eBonus)
			else:
				wont.add(eBonus)
	return will, wont
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:23,代碼來源:TradeUtil.py

示例3: calculateTradeRoutes

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import getPlayerID [as 別名]
def calculateTradeRoutes(playerOrID, withPlayerOrID=None):
	"""
	Returns the domestic and foreign trade route yields and counts for <playerOrID>:
	domestic yield, domestic count, foreign yield, and foreign count.
	
	If <withPlayerOrID> is given, only counts trade routes to their cities.
	If Fractional Trade Routes is active, the value returned is fractional (times 100).
	"""
	domesticTrade = domesticCount = foreignTrade = foreignCount = 0
	eTeam = PlayerUtil.getPlayerTeam(playerOrID)
	eWithPlayer = PlayerUtil.getPlayerID(withPlayerOrID)
	for city in PlayerUtil.playerCities(playerOrID):
		for i in range(city.getTradeRoutes()):
			tradeCity = city.getTradeCity(i)
			if tradeCity and tradeCity.getOwner() >= 0 and (eWithPlayer == -1 or eWithPlayer == tradeCity.getOwner()):
				trade = city.calculateTradeYield(YieldTypes.YIELD_COMMERCE, TRADE_PROFIT_FUNC(city, tradeCity))
				if tradeCity.getTeam() == eTeam:
					domesticTrade += trade
					domesticCount += 1
				else:
					foreignTrade += trade
					foreignCount += 1
	return domesticTrade, domesticCount, foreignTrade, foreignCount
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:25,代碼來源:TradeUtil.py


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