本文整理匯總了Python中PlayerUtil.getPlayerCities方法的典型用法代碼示例。如果您正苦於以下問題:Python PlayerUtil.getPlayerCities方法的具體用法?Python PlayerUtil.getPlayerCities怎麽用?Python PlayerUtil.getPlayerCities使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PlayerUtil
的用法示例。
在下文中一共展示了PlayerUtil.getPlayerCities方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getTrainableAndUntrainableUnits
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import getPlayerCities [as 別名]
def getTrainableAndUntrainableUnits(playerOrID, knowableUnits, military=None):
player, team = PlayerUtil.getPlayerAndTeam(playerOrID)
cities = PlayerUtil.getPlayerCities(player)
# separate units into two groups: yes and no
units = getTrainableUnits(playerOrID, knowableUnits, False, military)
yesUnits = set()
noUnits = set()
BugUtil.debug("-----------------------")
for eUnit in units:
if canAnyCityBuildUnit(eUnit, cities, -1, True):
BugUtil.debug(" yes %s", gc.getUnitInfo(eUnit).getDescription())
yesUnits.add(eUnit)
else:
BugUtil.debug(" no %s", gc.getUnitInfo(eUnit).getDescription())
noUnits.add(eUnit)
return yesUnits, noUnits
示例2: getKnownTrainableUnits
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import getPlayerCities [as 別名]
def getKnownTrainableUnits(playerOrID, askingPlayerOrID, knowableUnits, bonuses, military=None):
player, team = PlayerUtil.getPlayerAndTeam(playerOrID)
askingPlayer = PlayerUtil.getPlayer(askingPlayerOrID)
eAskingTeam, askingTeam = PlayerUtil.getPlayerTeamAndID(askingPlayer)
# trade = player.canTradeNetworkWith(askingPlayer.getID())
cities = PlayerUtil.getPlayerCities(player, lambda city: city.isRevealed(eAskingTeam, False))
# separate units into two groups: yes and maybe
units = getTrainableUnits(playerOrID, knowableUnits, False, military)
yesUnits = set()
maybeUnits = set()
BugUtil.debug("-----------------------")
for eUnit in units:
if not canAnyCityBuildUnit(eUnit, cities, eAskingTeam, False):
BugUtil.debug(" no %s", gc.getUnitInfo(eUnit).getDescription())
elif hasBonusesForUnit(eUnit, bonuses):
BugUtil.debug(" yes %s", gc.getUnitInfo(eUnit).getDescription())
yesUnits.add(eUnit)
elif bonuses is None:
BugUtil.debug(" maybe %s", gc.getUnitInfo(eUnit).getDescription())
maybeUnits.add(eUnit)
return yesUnits, maybeUnits
示例3: getTrainableUnits
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import getPlayerCities [as 別名]
def getTrainableUnits(playerOrID, knowableUnits, checkCities=True, military=None):
"""
Returns the set of all units the player can train, including obsolete ones.
"""
game = CyGame()
player, team = PlayerUtil.getPlayerAndTeam(playerOrID)
civInfo = gc.getCivilizationInfo(player.getCivilizationType())
if checkCities:
cities = PlayerUtil.getPlayerCities(player)
else:
cities = None
units = set()
BugUtil.debug("%s =========", player.getName())
for eClass in range(NUM_CLASSES):
eUnit = civInfo.getCivilizationUnits(eClass)
if eUnit == -1 or eUnit not in knowableUnits:
#BugUtil.debug(" %s -> unknowable", gc.getUnitClassInfo(eClass).getDescription())
continue
unitInfo = gc.getUnitInfo(eUnit)
# not buildable
eCost = unitInfo.getProductionCost()
if (eCost == -1):
BugUtil.debug(" %s -> not a buildable unit", unitInfo.getDescription())
continue
# military
if military is not None:
combat = (unitInfo.getUnitCombatType() > 0 or unitInfo.getNukeRange() != -1
or unitInfo.getAirCombat() > 0)
if military != combat:
#BugUtil.debug(" %s -> combat is %s", unitInfo.getDescription(), combat)
continue
# OCC and Settlers
if game.isOption(GameOptionTypes.GAMEOPTION_ONE_CITY_CHALLENGE) and unitInfo.isFound():
BugUtil.debug(" %s -> no founding units in OCC", unitInfo.getDescription())
continue
# techs
for eTech in unitTechs[eUnit]:
if not team.isHasTech(eTech):
BugUtil.debug(" %s -> doesn't know %s", unitInfo.getDescription(),
gc.getTechInfo(eTech).getDescription())
missing = True
break
else:
missing = False
if missing:
continue
# civ specific
ePrereqCiv = unitInfo.getPrereqCiv()
if ePrereqCiv != -1 and player.getCivilizationType() != ePrereqCiv:
BugUtil.debug(" %s -> wrong civilization", unitInfo.getDescription())
continue
# state religion
eReligion = unitInfo.getStateReligion()
if eReligion != -1 and player.getStateReligion() != eReligion:
BugUtil.debug(" %s -> wrong state religion", unitInfo.getDescription())
continue
# nukes
if (game.isNoNukes() or not game.isNukesValid()) and unitInfo.getNukeRange() != -1:
BugUtil.debug(" %s -> no nukes", unitInfo.getDescription())
continue
# getSpecialUnitType, game.isSpecialUnitValid
eSpecialType = unitInfo.getSpecialUnitType()
if eSpecialType != -1 and not game.isSpecialUnitValid(eSpecialType):
BugUtil.debug(" %s -> special unit type %s invalid", unitInfo.getDescription(),
gc.getSpecialUnitInfo(eSpecialType).getDescription())
continue
# cities
if cities and not canAnyCityBuildUnit(eUnit, cities, -1, True):
BugUtil.debug(" %s -> no city can train unit", unitInfo.getDescription())
continue
BugUtil.debug(" %s", unitInfo.getDescription())
units.add(eUnit)
return units