本文整理匯總了Python中PlayerUtil.playerCities方法的典型用法代碼示例。如果您正苦於以下問題:Python PlayerUtil.playerCities方法的具體用法?Python PlayerUtil.playerCities怎麽用?Python PlayerUtil.playerCities使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PlayerUtil
的用法示例。
在下文中一共展示了PlayerUtil.playerCities方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: drawContents
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
#.........這裏部分代碼省略.........
szExpensePanel,
u"",
"",
True,
True,
self.X_EXPENSES,
self.Y_LOCATION,
self.PANE_WIDTH,
self.PANE_HEIGHT,
PanelStyles.PANEL_STYLE_MAIN,
)
screen.setLabel(
self.getNextWidgetName(),
"Background",
u"<font=3>" + localText.getText("TXT_KEY_FINANCIAL_ADVISOR_EXPENSES_HEADER", ()).upper() + u"</font>",
CvUtil.FONT_CENTER_JUSTIFY,
self.X_EXPENSES + self.PANE_WIDTH / 2,
self.Y_LOCATION + self.TEXT_MARGIN,
self.Z_CONTROLS + self.DZ,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
)
# Commerce
yLocation = self.Y_LOCATION
iCommerce = 0
# sum all worked tiles' commerce yields for player
# move to MapUtil?
iWorkedTileCount = 0
iWorkedTiles = 0
for city in PlayerUtil.playerCities(player):
if not city.isDisorder():
for i in range(gc.getNUM_CITY_PLOTS()):
plot = city.getCityIndexPlot(i)
if plot and not plot.isNone() and plot.hasYield():
if city.isWorkingPlot(plot):
iWorkedTileCount += 1
iWorkedTiles += plot.getYield(YieldTypes.YIELD_COMMERCE)
yLocation += 1.5 * self.Y_SPACING
screen.setLabel(
self.getNextWidgetName(),
"Background",
u"<font=3>" + localText.getText("TXT_KEY_CONCEPT_WORKED_TILES", (iWorkedTileCount,)) + "</font>",
CvUtil.FONT_LEFT_JUSTIFY,
self.X_SLIDERS + self.TEXT_MARGIN,
yLocation + self.TEXT_MARGIN,
self.Z_CONTROLS + self.DZ,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
-1,
-1,
)
screen.setLabel(
self.getNextWidgetName(),
"Background",
u"<font=3>" + unicode(iWorkedTiles) + "</font>",
CvUtil.FONT_RIGHT_JUSTIFY,
self.X_SLIDERS + self.PANE_WIDTH - self.TEXT_MARGIN,
yLocation + self.TEXT_MARGIN,
self.Z_CONTROLS + self.DZ,
FontTypes.GAME_FONT,
WidgetTypes.WIDGET_GENERAL,
示例2: reset
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def reset(self):
"Clears state kept for each city."
#DLP
if CyGame().isPitbossHost():
return
self._beforeReset()
player = PlayerUtil.getActivePlayer()
for city in PlayerUtil.playerCities(player):
self.resetCity(city)
示例3: checkAllActivePlayerCities
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def checkAllActivePlayerCities(self):
"Loops over active player's cities, telling each alert to perform its check."
#DLP
if CyGame().isPitbossHost():
return
ePlayer, player = PlayerUtil.getActivePlayerAndID()
for city in PlayerUtil.playerCities(player):
for alert in self.alerts:
alert.checkCity(getCityId(city), city, ePlayer, player)
示例4: findMaxCity
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def findMaxCity():
iMaxProgress = 0
player = gc.getPlayer(gc.getGame().getActivePlayer())
bestCity = None
for city in PlayerUtil.playerCities(player):
iProgress = city.getGreatPeopleProgress()
if (iProgress > iMaxProgress):
iMaxProgress = iProgress
bestCity = city
return (bestCity, iMaxProgress)
示例5: findNextCity
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def findNextCity():
iMinTurns = None
iTurns = 0
player = gc.getPlayer(gc.getGame().getActivePlayer())
iThreshold = player.greatPeopleThreshold(False)
bestCity = None
for city in PlayerUtil.playerCities(player):
iRate = city.getGreatPeopleRate()
if (iRate > 0):
iProgress = city.getGreatPeopleProgress()
iTurns = (iThreshold - iProgress + iRate - 1) / iRate
if (iMinTurns is None or iTurns < iMinTurns):
iMinTurns = iTurns
bestCity = city
return (bestCity, iMinTurns)
示例6: calculateTradeRoutes
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [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
示例7: reset
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def reset(self):
"Clears state kept for each city."
self._beforeReset()
player = PlayerUtil.getActivePlayer()
for city in PlayerUtil.playerCities(player):
self.resetCity(city)
示例8: checkAllActivePlayerCities
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def checkAllActivePlayerCities(self):
"Loops over active player's cities, telling each alert to perform its check."
ePlayer, player = PlayerUtil.getActivePlayerAndID()
for city in PlayerUtil.playerCities(player):
for alert in self.alerts:
alert.checkCity(getCityId(city), city, ePlayer, player)
示例9: getCanTrainUnits
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import playerCities [as 別名]
def getCanTrainUnits(playerOrID, askingPlayerOrID=None, military=None):
"""
Returns the set of all units the player can train.
Searches all of the player's cities to find which units can be trained.
If askingPlayerOrID is given, only cities they have seen are checked, and
only units whose prerequisite techs they know or can research are returned.
Also, if the two players' trade networks are not connected, units that
require resources to train are returned in a second set.
If military is provided, only military or civilian units are checked
depending on its value, True or False, respectively.
*** OBSOLETE ***
"""
player, team = PlayerUtil.getPlayerAndTeam(playerOrID)
askingPlayer = PlayerUtil.getPlayer(askingPlayerOrID)
if askingPlayer:
eAskingTeam, askingTeam = PlayerUtil.getPlayerTeamAndID(askingPlayer)
trade = player.canTradeNetworkWith(askingPlayer.getID())
civInfo = gc.getCivilizationInfo(player.getCivilizationType())
units = set()
maybeUnits = set()
for eClass in range(NUM_CLASSES):
eUnit = civInfo.getCivilizationUnits(eClass)
if eUnit == -1:
classInfo = gc.getUnitClassInfo(eClass)
BugUtil.debug("%s doesn't have %s", civInfo.getDescription(), classInfo.getDescription())
eUnit = classInfo.getDefaultUnitIndex()
unitInfo = gc.getUnitInfo(eUnit)
if unitInfo:
if ((military == True and unitInfo.getUnitCombatType() <= 0)
or (military == False and unitInfo.getUnitCombatType() > 0)):
BugUtil.debug("skipping (non-)military %s", unitInfo.getDescription())
continue
if askingPlayer:
for eTech in unitTechs[eUnit]:
if not (askingTeam.isHasTech(eTech) or askingPlayer.canResearch(eTech, False)):
BugUtil.debug("%s doesn't comprehend %s", askingPlayer.getName(), gc.getTechInfo(eTech).getDescription())
skip = True
break
else:
skip = False
if skip:
BugUtil.debug("skipping unknowable %s", unitInfo.getDescription())
continue
for city in PlayerUtil.playerCities(player):
if askingPlayer:
if not city.isRevealed(eAskingTeam, False):
continue
if city.canTrain(eUnit, False, not trade):
if eUnit in unitsWithBonuses:
maybeUnits.add(eUnit)
else:
units.add(eUnit)
break
else:
if city.canTrain(eUnit, False, False):
units.add(eUnit)
break
BugUtil.debug("%s can train:", player.getName())
for eUnit in units:
unitInfo = gc.getUnitInfo(eUnit)
BugUtil.debug(" %s", unitInfo.getDescription())
if askingPlayer:
BugUtil.debug("%s can maybe train:", player.getName())
for eUnit in maybeUnits:
unitInfo = gc.getUnitInfo(eUnit)
BugUtil.debug(" %s", unitInfo.getDescription())
return units, maybeUnits
else:
return units