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


Python PlayerUtil.playerUnits方法代碼示例

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


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

示例1: onCityBuilt

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerUnits [as 別名]
	def onCityBuilt(self, argsList):
		"""
		If this is the first city founded, apply naming to each unit without a name.
		"""
		pCity = argsList[0]
		pPlayer = gc.getPlayer(pCity.getOwner())
		if not (pCity.isCapital() 
		and pPlayer.getNumCities() == 1
		and pCity.getOwner() == PlayerUtil.getActivePlayerID() 
		and UnitNamingOpt.isEnabled()):
			return
		lUnitReName = UnitReName()
		zsEra = gc.getEraInfo(pPlayer.getCurrentEra()).getType()
		for pUnit in PlayerUtil.playerUnits(pPlayer):
			if pUnit.getNameNoDesc() == "":
				zsUnitCombat = lUnitReName.getUnitCombat(pUnit)
				zsUnitClass = gc.getUnitClassInfo(pUnit.getUnitClassType()).getType()
				zsUnitNameConv = lUnitReName.getUnitNameConvFromIniFile(zsEra, zsUnitClass, zsUnitCombat)
				zsUnitName = lUnitReName.getUnitName(zsUnitNameConv, pUnit, pCity, True)
				if zsUnitName:
					pUnit.setName(zsUnitName)
開發者ID:markourm,項目名稱:fall,代碼行數:23,代碼來源:UnitNameEventManager.py

示例2: drawHelpInfo

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerUnits [as 別名]

#.........這裏部分代碼省略.........
            cityList = iPlayer.getCityList()
            # BUG - start
            iCities = [0] * self.NUM_RELIGIONS
            iTemple = [0] * self.NUM_RELIGIONS
            iMonastery = [0] * self.NUM_RELIGIONS
            iMissionaries_Active = [0] * self.NUM_RELIGIONS
            iMissionaries_Construct = [0] * self.NUM_RELIGIONS

            for pLoopCity in cityList:
                lHolyCity = pLoopCity.getHolyCity()
                lReligions = pLoopCity.getReligions()

                for iRel in self.RELIGIONS:
                    # count the number of cities
                    if iRel in lReligions:
                        iCities[iRel] += 1

                        # count the number of temples
                    iBldg = ReligionUtil.getBuilding(iRel, ReligionUtil.BUILDING_TEMPLE)
                    if self.calculateBuilding(pLoopCity, iBldg) == self.objectHave:
                        iTemple[iRel] += 1

                        # count the number of monasteries
                    iBldg = ReligionUtil.getBuilding(iRel, ReligionUtil.BUILDING_MONASTERY)
                    if self.calculateBuilding(pLoopCity, iBldg) == self.objectHave:
                        iMonastery[iRel] += 1

                        # count the number of missionaries under construction
                    iUnit = ReligionUtil.getUnit(iRel, ReligionUtil.UNIT_MISSIONARY)
                    if pLoopCity.GetCy().getFirstUnitOrder(iUnit) != -1:
                        iMissionaries_Construct[iRel] += 1

                        # count the number of active missionaries
            for iUnit in PlayerUtil.playerUnits(self.iActivePlayer):
                for iRel in self.RELIGIONS:
                    if iUnit.getUnitType() == ReligionUtil.getUnit(iRel, ReligionUtil.UNIT_MISSIONARY):
                        iMissionaries_Active[iRel] += 1

                        # number of cities...
            iY = self.Y_INFLUENCE + 20
            sCities = "%s [%i]:" % (self.szCities, len(cityList))
            screen.setLabelAt(
                "",
                szArea,
                sCities,
                CvUtil.FONT_LEFT_JUSTIFY,
                self.LEFT_EDGE_TEXT,
                iY,
                self.DZ,
                FontTypes.SMALL_FONT,
                WidgetTypes.WIDGET_GENERAL,
                -1,
                -1,
            )

            xLoop = self.X_RELIGION_START
            for iRel in self.RELIGIONS:
                if gc.getGame().getReligionGameTurnFounded(iRel) >= 0:
                    szFounded = "%i" % (iCities[iRel])
                    screen.setLabelAt(
                        "",
                        szArea,
                        szFounded,
                        CvUtil.FONT_CENTER_JUSTIFY,
                        xLoop,
                        iY,
開發者ID:AP-ML,項目名稱:DTM,代碼行數:70,代碼來源:CvReligionScreen.py

示例3: UL_refreshUnitSelection

# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerUnits [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


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