本文整理匯總了Python中PlayerUtil.teams方法的典型用法代碼示例。如果您正苦於以下問題:Python PlayerUtil.teams方法的具體用法?Python PlayerUtil.teams怎麽用?Python PlayerUtil.teams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PlayerUtil
的用法示例。
在下文中一共展示了PlayerUtil.teams方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: getWorstEnemyTeams
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import teams [as 別名]
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
示例2: getCurrentValuesByTeam
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import teams [as 別名]
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
示例3: getSpending
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import teams [as 別名]
def getSpending(playerOrID, ActiveplayerOrID=None):
if ActiveplayerOrID != None:
pActiveTeam = PlayerUtil.getPlayerTeam(ActiveplayerOrID)
iTotal = 0
for targetTeam in PlayerUtil.teams(True, None, False):
if ActiveplayerOrID == None or pActiveTeam.isHasMet(targetTeam.getID()):
iTotal += getDifferenceByTeam(PlayerUtil.getPlayerTeam(playerOrID), targetTeam.getID())
return iTotal
示例4: getWorstEnemyTeam
# 需要導入模塊: import PlayerUtil [as 別名]
# 或者: from PlayerUtil import teams [as 別名]
def getWorstEnemyTeam(playerOrID):
"""
Returns the team ID that is the worst enemy of <player>'s team.
If <player>'s team has no worst enemy, returns -1.
"""
player, team = PlayerUtil.getPlayerAndTeam(playerOrID)
if not team.isHuman():
worstEnemyName = player.getWorstEnemyName()
if worstEnemyName:
for team in PlayerUtil.teams(alive=True, barbarian=False):
if team.getName() == worstEnemyName:
return team.getID()
return -1