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


Python PlayerUtil.players方法代碼示例

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


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

示例1: updateData

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
	def updateData(self, data):
		"""
		Upgrade previous data formats to latest format.
		"""
		if len(data) == 0:
			# empty, don't care
			return data
		for key, value in data.iteritems():
			if isinstance(key, int):
				# data in latest format
				return data
			else:
				# old format, convert below
				break
		# find first living, human player and assign all data to them
		# if none found, assign to player 0
		for player in PlayerUtil.players(alive=True, human=True):
			ePlayer = player.getID()
			break
		else:
			ePlayer = 0
		newData = {}
		cities = {}
		newData[ePlayer] = cities
		for point, (color, layer) in data.iteritems():
			# use new point-based layer scheme
			grid = 6
			layer = (point[X] % grid) * grid + (point[Y] % grid)
			cities[point] = City(point, color, layer)
		return newData
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:32,代碼來源:CvStrategyOverlay.py

示例2: fillStratAdvGrid

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
	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,代碼行數:33,代碼來源:CvBUGMilitaryAdvisor.py

示例3: updateData

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
	def updateData(self, data):
		"""
		Upgrade previous data formats to latest format.
		"""
		if len(data) == 0:
			# empty, don't care
			return data
		for key, value in data.iteritems():
			if isinstance(key, int):
				# data in latest format
				return data
			else:
				break
		# find first living, human player and assign all data to them
		# if none found, assign to player 0
		for player in PlayerUtil.players(alive=True, human=True):
			ePlayer = player.getID()
			break
		else:
			ePlayer = 0
		newData = {}
		cities = {}
		newData[ePlayer] = cities
		for point, colorLayer in data.iteritems():
			cities[point] = City(point, colorLayer[0], colorLayer[1])
		return newData
開發者ID:hardtimes1966,項目名稱:modxml,代碼行數:28,代碼來源:CvStrategyOverlay.py

示例4: _reset

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
	def _reset(self):
		"""
		The enemies dictionary maps all teams to their worst enemy.
		It will hold -1 for any team or enemy the active team hasn't met.
		"""
		self.enemies = {}
		for player in PlayerUtil.players():
			self.enemies[player.getID()] = [-1] * gc.getMAX_TEAMS()
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:10,代碼來源:Civ4lerts.py

示例5: tradeParters

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
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,代碼行數:10,代碼來源:TradeUtil.py

示例6: updateAliveCivsOption

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
def updateAliveCivsOption():
	import BugGame
	aliveCivsOption = BugGame.ANewDawnSettings.AliveCivilization
	descs = []
	for player in PlayerUtil.players(True, True, False, False, False):
		descs.append(gc.getCivilizationInfo(player.getCivilizationType()).getShortDescription())
	sort(descs)
	aliveCivsOption.setValues(descs)
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例7: check

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
	def check(self):
		if (not Civ4lertsOpt.isShowRefusesToTalkAlert()):
			return
		eActivePlayer, activePlayer = PlayerUtil.getActivePlayerAndID()
		refusals = self.refusals[eActivePlayer]
		newRefusals = set()
		for player in PlayerUtil.players(True, False, False, False):
			if DiplomacyUtil.canContact(activePlayer, player) and not DiplomacyUtil.isWillingToTalk(player, eActivePlayer):
				newRefusals.add(player.getID())
		self.display(eActivePlayer, "TXT_KEY_CIV4LERTS_ON_WILLING_TO_TALK", refusals.difference(newRefusals))
		self.display(eActivePlayer, "TXT_KEY_CIV4LERTS_ON_REFUSES_TO_TALK", newRefusals.difference(refusals))
		self.refusals[eActivePlayer] = newRefusals
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:14,代碼來源:Civ4lerts.py

示例8: placeLandmark

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
def placeLandmark(pPlot, sEventType, iFood, iProd, iComm, bIsSign, iSignOwner):
	""" Places a landmark on a plot identifying a yield change with a short description.

	Parameters:
	* pPlot is the CyPlot object for the plot to mark.
	* sEventType is the str key for the event which is used to get the sign's descriptive caption.
	* iFood, iProd, and iComm are the integer yield changes which will be noted on the caption.
	* bIsSign will be True if we want a team-specific sign and False if we want a generic landmark.
	* iSignOwner is the player number for the visibility of the sign. If it's -1, all players get one.
	Note that iSignOwner is unused if bIsSign is False since everyone can see landmarks.
	"""
	# Bail out early if EventSigns are disabled
	if not EventSignsOpt.isEnabled(): return False
	
	# Bail out if there are no yield changes
	if iFood == 0 and iProd == 0 and iComm == 0: return False

	# This next bit is unused; see the docstring at the start of that function for why.
	#clearSignsAndLandmarks(pPlot)

	sCaptionFood = ""
	sCaptionProd = ""
	sCaptionComm = ""
	sCaptionDesc = localText.getText("TXT_KEY_SIGN_" + sEventType, ())

	# Note the extra spaces added for separation after each yield adjustment; you can remove them
	# if you want a more condensed sign; the reason they are here instead of in the XML formats
	# is because I couldn't come up with a simple way to make them appear only if the yield changes.
	if (iFood != 0):
		sCaptionFood = localText.getText("TXT_KEY_SIGN_FORMAT_FOOD", (iFood, )) + u" "
	if (iProd != 0):
		sCaptionProd = localText.getText("TXT_KEY_SIGN_FORMAT_PROD", (iProd, )) + u" "
	if (iComm != 0):
		sCaptionComm = localText.getText("TXT_KEY_SIGN_FORMAT_COMM", (iComm, )) + u" "

	sCaption = localText.getText("TXT_KEY_SIGN_FORMAT_OVERVIEW", (sCaptionFood, sCaptionProd, sCaptionComm, sCaptionDesc))

	if (bIsSign):
		if (iSignOwner == -1):
			# add signs for all valid human players who are still alive.
			for pPlayer in PlayerUtil.players(human=True, alive=True):
				addSign(pPlot, pPlayer.getID(), sCaption)
		else:
			addSign(pPlot, iSignOwner, sCaption)
	else:
		engine.addLandmark(pPlot, sCaption)

	return True
開發者ID:Alrik2002,項目名稱:Civ4-MMod,代碼行數:50,代碼來源:EventSigns.py

示例9: UL_refreshUnitSelection

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
	def UL_refreshUnitSelection(self, bReload, bRedraw):
		screen = self.getScreen()
		screen.minimapClearAllFlashingTiles()
		
		if (bRedraw):
			iBtn_X = self.X_TEXT + self.MAP_MARGIN
			iBtn_Y = self.Y_TEXT + self.MAP_MARGIN / 2
			iTxt_X = iBtn_X + 22
			iTxt_Y = iBtn_Y + 2
			if (self.bUnitDetails):
				szText = localText.getText("TXT_KEY_MILITARY_ADVISOR_UNIT_TOGGLE_OFF", ())
				screen.setButtonGFC(self.UNIT_BUTTON_ID, u"", "", iBtn_X, iBtn_Y, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_MINUS )
				screen.setLabel(self.UNIT_BUTTON_LABEL_ID, "", szText, CvUtil.FONT_LEFT_JUSTIFY, iTxt_X, iTxt_Y, 0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
			else:
				szText = localText.getText("TXT_KEY_MILITARY_ADVISOR_UNIT_TOGGLE_ON", ())
				screen.setButtonGFC(self.UNIT_BUTTON_ID, u"", "", iBtn_X, iBtn_Y, 20, 20, WidgetTypes.WIDGET_GENERAL, -1, -1, ButtonStyles.BUTTON_STYLE_CITY_PLUS )
				screen.setLabel(self.UNIT_BUTTON_LABEL_ID, "", szText, CvUtil.FONT_LEFT_JUSTIFY, iTxt_X, iTxt_Y, 0, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)

		if bReload:
			self.timer.start()
			_, activePlayer, iActiveTeam, activeTeam = PlayerUtil.getActivePlayerAndTeamAndIDs()
			self.stats = UnitGrouper.GrouperStats(self.grouper)
			for player in PlayerUtil.players(alive=True):
				for unit in PlayerUtil.playerUnits(player):
					plot = unit.plot()
					if plot.isNone():
						continue
					bVisible = plot.isVisible(iActiveTeam, False) and not unit.isInvisible(iActiveTeam, False)
					if not bVisible:
						continue
					if unit.getVisualOwner() in self.selectedLeaders:
						self.stats.processUnit(activePlayer, activeTeam, unit)
			self.timer.log("process units")
		
		iGroupID = 1
		szText = localText.getText("TXT_KEY_PEDIA_ALL_UNITS", ()).upper()
		bAllSelected = iGroupID in self.selectedGroups
		if (bAllSelected):
			szText = localText.changeTextColor(u"<u>" + szText + u"</u>", gc.getInfoTypeForString("COLOR_YELLOW"))
		if (bRedraw):
			screen.addListBoxGFC(self.UNIT_LIST_ID, "", self.X_TEXT + self.MAP_MARGIN, self.Y_TEXT + self.MAP_MARGIN + 15, self.W_TEXT - 2 * self.MAP_MARGIN, self.H_TEXT - 2 * self.MAP_MARGIN - 15, TableStyles.TABLE_STYLE_STANDARD)
			screen.enableSelect(self.UNIT_LIST_ID, False)
			screen.setStyle(self.UNIT_LIST_ID, "Table_StandardCiv_Style")
			screen.appendListBoxString(self.UNIT_LIST_ID, szText, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY)
		else:
			screen.setListBoxStringGFC(self.UNIT_LIST_ID, 0, szText, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY)
		
#		for grouping in self.stats.itergroupings():
#			for group in grouping.itergroups():
#				BugUtil.debug("%s / %s : %d (%d)" % (grouping.grouping.title, group.group.title, group.size(), group.isEmpty()))
		
		eYellow = gc.getInfoTypeForString("COLOR_YELLOW")
		eRed = gc.getInfoTypeForString("COLOR_RED")
		eWhite = gc.getInfoTypeForString("COLOR_WHITE")
		grouping1 = self.stats.getGrouping(self.groupingKeys[0])
		grouping2 = self.stats.getGrouping(self.groupingKeys[1])
		BugUtil.debug("Grouping 1 is %s" % grouping1.grouping.title)
		BugUtil.debug("Grouping 2 is %s" % grouping2.grouping.title)
		self.timer.start()
		iItem = 1
		for group1 in grouping1.itergroups():
			if (group1.isEmpty()):
				continue
			units1 = group1.units
			iGroupID += 1
			bGroup1Selected = iGroupID in self.selectedGroups
			szDescription = group1.group.title.upper() + u" (%d)" % len(units1)
			if (bGroup1Selected):
				szDescription = u"   <u>" + szDescription + u"</u>"
			else:
				szDescription = u"   " + szDescription
			if (bGroup1Selected or bAllSelected):
				szDescription = localText.changeTextColor(szDescription, eYellow)
			if (bRedraw):
				screen.appendListBoxString(self.UNIT_LIST_ID, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY)
			else:
				screen.setListBoxStringGFC(self.UNIT_LIST_ID, iItem, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY)
			iItem += 1
			bGroup1Selected = bGroup1Selected or bAllSelected
			for group2 in grouping2.itergroups():
				units2 = group2.units & units1
				if (not units2):
					continue
				iGroupID += 1
				bGroup2Selected = iGroupID in self.selectedGroups
				szDescription = group2.group.title + u" (%d)" % len(units2)
				if (bGroup2Selected):
					szDescription = u"      <u>" + szDescription + u"</u>"
				else:
					szDescription = u"      " + szDescription
				if (bGroup2Selected or bGroup1Selected):
					szDescription = localText.changeTextColor(szDescription, eYellow)
				if (bRedraw):
					screen.appendListBoxString(self.UNIT_LIST_ID, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY)
				else:
					screen.setListBoxStringGFC(self.UNIT_LIST_ID, iItem, szDescription, WidgetTypes.WIDGET_MINIMAP_HIGHLIGHT, 1, iGroupID, CvUtil.FONT_LEFT_JUSTIFY)
				iItem += 1
				
				bGroup2Selected = bGroup2Selected or bGroup1Selected
				for unit in units2:
#.........這裏部分代碼省略.........
開發者ID:Imperator-Knoedel,項目名稱:RFC-Dawn-of-Knoedel,代碼行數:103,代碼來源:CvBUGMilitaryAdvisor.py

示例10: settingsOK

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import players [as 別名]
def settingsOK():
	"""
	Returns True if BUFFY is active and all game/map settings and CRCs are acceptable, 
	on Mac, or it's an XOTM game.
	"""
	game = gc.getGame()
	map = gc.getMap()
	
	# xOTM games are always okay
	# EF: Mac only?
	if isXOTMScenario():
		return True
	
	if not Buffy.isActive():
		return False

	if not Buffy.isDllInCorrectPath():
		return False
	
	if game.getWarningStatus() == 1:
		return False

	# Check that the map script used is a valid one
	if not isMapScriptOK():
		return False

	# Don't allow the balanced option
	if getBalanced():
		return False

	# Check that the world wrap setting is OK
	if not getWorldWrapSettingOK():
		return False

	# Check that all victory conditions are enabled
	for iVCLoop in range(gc.getNumVictoryInfos()):
		if not game.isVictoryValid(iVCLoop):
			return False

	# Ensure the game is single player
	if game.isGameMultiPlayer():
		return False

	# Check the options
	if len(getInvalidGameOptions()) > 0:
		return False

	opponentCount = -1
	seenLeaders = set()
	for player in PlayerUtil.players(barbarian=False, minor=False):
		opponentCount += 1
		iLeader = player.getLeaderType()
		if iLeader >= 0:
			if iLeader in seenLeaders:
				return False
			seenLeaders.add(iLeader)

	if not isOpponentCountOK(opponentCount):
		return False

	if game.isTeamGame():
		return False

	if crcResult != 0:
		return False

	return True
開發者ID:DC123456789,項目名稱:Dawn-of-Civilization,代碼行數:69,代碼來源:GameSetUpCheck.py


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