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


Python PlayerUtil類代碼示例

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


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

示例1: isWillingToTalk

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,代碼行數:27,代碼來源:DiplomacyUtil.py

示例2: printStatus

def printStatus(ePlayer, eAskingPlayer=None):
	player = PlayerUtil.getPlayer(ePlayer)
	if eAskingPlayer is None:
		eAskingPlayer = PlayerUtil.getActivePlayerID()
	print "Trade Status -- %s" % player.getCivilizationShortDescription(0)
	for eItem, name in STATUS_TRADE_ITEMS:
		tradeData = TradeData()
		tradeData.ItemType = eItem
		can = player.canTradeItem(eAskingPlayer, tradeData, False)
		denial = player.getTradeDenial(eAskingPlayer, tradeData)
		will = denial == DenialTypes.NO_DENIAL
		if denial in DENIALS:
			denial = DENIALS[denial]
		else:
			denial = str(denial)
		if not can:
			if will:
				print "%s: can't but will" % (name)
			else:
				print "%s: can't and won't because %s" % (name, denial)
		else:
			if will:
				print "%s: will" % (name)
			else:
				print "%s: won't because %s" % (name, denial)
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:25,代碼來源:TradeUtil.py

示例3: onCivicRejected

def onCivicRejected(argsList):
	#BugUtil.debug("DiplomacyUtil::onCivicRejected %s" %(str(argsList)))
	eTargetPlayer, eDemandPlayer, eCivic = argsList
	BugUtil.debug("DiplomacyUtil - %s rejects demand from %s to switch to %s",
			PlayerUtil.getPlayer(eTargetPlayer).getName(), 
			PlayerUtil.getPlayer(eDemandPlayer).getName(), 
			gc.getCivicInfo(eCivic).getDescription())
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例4: onDealRejected

def onDealRejected(argsList):
	#BugUtil.debug("DiplomacyUtil::onDealRejected %s" %(str(argsList)))
	eTargetPlayer, eOfferPlayer, pTrade = argsList
	BugUtil.debug("DiplomacyUtil - %s accepts trade offered by %s: %r",
			PlayerUtil.getPlayer(eTargetPlayer).getName(),
			PlayerUtil.getPlayer(eOfferPlayer).getName(), 
			pTrade)
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例5: onHelpOffered

def onHelpOffered(argsList):
	#BugUtil.debug("DiplomacyUtil::onHelpOffered %s" %(str(argsList)))
	eOfferPlayer, eTargetPlayer, pTrade = argsList
	BugUtil.debug("DiplomacyUtil - %s offers help to %s: %r",
			PlayerUtil.getPlayer(eOfferPlayer).getName(), 
			PlayerUtil.getPlayer(eTargetPlayer).getName(),
			pTrade)
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例6: onEmbargoRejected

def onEmbargoRejected(argsList):
	#BugUtil.debug("DiplomacyUtil::onEmbargoRejected %s" %(str(argsList)))
	eTargetPlayer, eDemandPlayer, eVictim = argsList
	BugUtil.debug("DiplomacyUtil - %s rejects demand from %s to stop trading with %s",
			PlayerUtil.getPlayer(eTargetPlayer).getName(), 
			PlayerUtil.getPlayer(eDemandPlayer).getName(), 
			PlayerUtil.getPlayer(eVictim).getName())
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例7: isWorstEnemy

def isWorstEnemy(playerOrID, enemyOrID):
	"""
	Returns True if <enemy> is one of the worst enemies of <player>'s team.
	"""
	player, team = PlayerUtil.getPlayerAndTeam(playerOrID)
	enemy, enemyTeam = PlayerUtil.getPlayerAndTeam(enemyOrID)
	return not team.isHuman() and team.getID() != enemyTeam.getID() and getWorstEnemyTeam(player) == enemyTeam.getID()
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:7,代碼來源:AttitudeUtil.py

示例8: getWorstEnemyTeams

def getWorstEnemyTeams():
	"""
	Returns a dictionary of the team IDs that are each team's worst enemy.
	
	The key is team ID; the value is the worst enemy team ID.
	If a team has no worst enemy, -1 is stored as its value.
	Ignores dead, human, barbarian, and minor teams.
	
	Loops over players because CyTeam does not have getWorstEnemyName().
	"""
	namesToID = {}
	for team in PlayerUtil.teams(alive=True, barbarian=False, minor=False):
		namesToID[team.getName()] = team.getID()
	enemies = {}
	for team in PlayerUtil.teams(alive=True, human=False, barbarian=False, minor=False):
		eTeam = team.getID()
		eLeader = team.getLeaderID()
		if eLeader != -1:
			player = PlayerUtil.getPlayer(eLeader)
			worstEnemyName = player.getWorstEnemyName()
			if worstEnemyName:
				try:
					enemies[eTeam] = namesToID[worstEnemyName]
				except KeyError:
					BugUtil.debug("Cannot find team \"%s\"", worstEnemyName)
					enemies[eTeam] = -1
			else:
				enemies[eTeam] = -1
	return enemies
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:29,代碼來源:AttitudeUtil.py

示例9: onWarRejected

def onWarRejected(argsList):
	#BugUtil.debug("DiplomacyUtil::onWarRejected %s" %(str(argsList)))
	eTargetPlayer, eDemandPlayer, eVictim = argsList
	BugUtil.debug("DiplomacyUtil - %s rejects demand from %s to declare war on %s",
			PlayerUtil.getPlayer(eTargetPlayer).getName(), 
			PlayerUtil.getPlayer(eDemandPlayer).getName(), 
			PlayerUtil.getPlayer(eVictim).getName())
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例10: onWarDemanded

def onWarDemanded(argsList):
	#BugUtil.debug("DiplomacyUtil::onWarDemanded %s" %(str(argsList)))
	eDemandPlayer, eTargetPlayer, eVictim = argsList
	BugUtil.debug("DiplomacyUtil - %s asks %s to declare war on %s",
			PlayerUtil.getPlayer(eDemandPlayer).getName(), 
			PlayerUtil.getPlayer(eTargetPlayer).getName(), 
			PlayerUtil.getPlayer(eVictim).getName())
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例11: getCurrentValuesByTeam

def getCurrentValuesByTeam():
    valuesByTeam = {}
    for team in PlayerUtil.teams(True, None, False):
        valuesByTeam[team.getID()] = values = []
        for targetTeam in PlayerUtil.teams():
            values.append(team.getEspionagePointsAgainstTeam(targetTeam.getID()))
    return valuesByTeam
開發者ID:NikNaks,項目名稱:Civ4-K-Mod,代碼行數:7,代碼來源:SpyUtil.py

示例12: fillStratAdvGrid

	def fillStratAdvGrid(self):
		self.iconGrid.clearData()
		self.iHumanKnowableUnits = UnitUtil.getKnowableUnits(self.iActivePlayer)
		self.iHumanUnits = UnitUtil.getTrainableUnits(self.iActivePlayer, self.iHumanKnowableUnits, True, True)
		#self.iHumanYesUnits, self.iHumanNoUnits = UnitUtil.getTrainableAndUntrainableUnits(self.iActivePlayer, self.iHumanKnowableUnits, True)
		BugUtil.debug("----------------------- fillStratAdvGrid start")
		self.iHumanObsoleteUnits = UnitUtil.findObsoleteUnits(self.iHumanUnits)
		for eUnit in self.iHumanObsoleteUnits:
			BugUtil.debug("  obs %s", gc.getUnitInfo(eUnit).getDescription())
		
		activePlayer, activeTeam = PlayerUtil.getPlayerAndTeam(self.iActivePlayer)
		iRow = 0
		for player in PlayerUtil.players(alive=True, barbarian=False, minor=False):
			ePlayer = player.getID()
			if (ePlayer != self.iActivePlayer
					and (activeTeam.isHasMet(player.getTeam()) or gc.getGame().isDebugMode())):
				self.iconGrid.appendRow(player.getCivilizationShortDescription(0), "", 3)
				
				# add leaderhead icon
				self.iconGrid.addIcon(iRow, self.SA_Col_Leader,
						gc.getLeaderHeadInfo(player.getLeaderType()).getButton(), 64, 
						WidgetTypes.WIDGET_LEADERHEAD, player.getID(), self.iActivePlayer)
				
				# add bonus and unit icons
				self.addStratAdvBonuses(activePlayer, player, iRow)
				self.addStratAdvUnits(activePlayer, player, iRow)
				
				iRow += 1
		
		BugUtil.debug("----------------------- fillStratAdvGrid end")
		self.iconGrid.refresh()
開發者ID:Imperator-Knoedel,項目名稱:RFC-Dawn-of-Knoedel,代碼行數:31,代碼來源:CvBUGMilitaryAdvisor.py

示例13: onReligionRejected

def onReligionRejected(argsList):
	#BugUtil.debug("DiplomacyUtil::onReligionRejected %s" %(str(argsList)))
	eTargetPlayer, eDemandPlayer, eReligion = argsList
	BugUtil.debug("DiplomacyUtil - %s rejects demand from %s to convert to %s",
			PlayerUtil.getPlayer(eTargetPlayer).getName(), 
			PlayerUtil.getPlayer(eDemandPlayer).getName(), 
			gc.getReligionInfo(eReligion).getDescription())
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:7,代碼來源:DiplomacyUtil.py

示例14: onVassalOffered

def onVassalOffered(argsList):
    # BugUtil.debug("DiplomacyUtil::onVassalOffered %s" %(str(argsList)))
    eOfferPlayer, eTargetPlayer = argsList
    BugUtil.debug(
        "DiplomacyUtil - %s offers vassalage to %s",
        PlayerUtil.getPlayer(eOfferPlayer).getCivilizationShortDescription(0),
        PlayerUtil.getPlayer(eTargetPlayer).getCivilizationShortDescription(0),
    )
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:8,代碼來源:DiplomacyUtil.py

示例15: tradeParters

def tradeParters(playerOrID):
	"""
	Iterates over all of <player>'s possible trade partners, yielding each CyPlayer in turn.
	"""
	player = PlayerUtil.getPlayer(playerOrID)
	for partner in PlayerUtil.players(alive=True, barbarian=False, minor=False):
		if canTrade(player, partner):
			yield partner
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:8,代碼來源:TradeUtil.py


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