本文整理汇总了Python中RoleConstants.willRoleSwitch方法的典型用法代码示例。如果您正苦于以下问题:Python RoleConstants.willRoleSwitch方法的具体用法?Python RoleConstants.willRoleSwitch怎么用?Python RoleConstants.willRoleSwitch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleConstants
的用法示例。
在下文中一共展示了RoleConstants.willRoleSwitch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chaserIsOut
# 需要导入模块: import RoleConstants [as 别名]
# 或者: from RoleConstants import willRoleSwitch [as 别名]
def chaserIsOut(player):
"""
There is a chaser spot ready to be filled.
"""
if not player.roleSwitching or player.brain.gameController.penalized:
return False
if not player.gameState == "gamePlaying":
return False
checkForConsistency(player)
if constants.canRoleSwitchTo(player.role):
return False
openPositions = ()
positions = [False, False, False, False]
for mate in player.brain.teamMembers:
if mate.role <= 1:
continue
if mate.frameSinceActive < 30:
positions[mate.role - 2] = True
if mate.playerNumber == player.brain.playerNumber:
continue
if constants.canRoleSwitchTo(mate.role) and mate.frameSinceActive > 30:
openPositions += (mate.role,)
if (
constants.willRoleSwitch(mate.role)
and mate.playerNumber > player.brain.playerNumber
and (mate.frameSinceActive < 30 or not mate.active)
):
return False # Active, higher numbered player takes precedence
for pos in openPositions:
if not positions[pos - 2]:
player.openChaser = pos
print "Switching to role: ", pos
return True
return False