本文整理汇总了Python中Player.getBots方法的典型用法代码示例。如果您正苦于以下问题:Python Player.getBots方法的具体用法?Python Player.getBots怎么用?Python Player.getBots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.getBots方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CheckResult
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getBots [as 别名]
def CheckResult(self, not_voted="dont_count", not_voted_spec=None, min_needed=51, only_sure=False):
if not_voted not in {"dont_count","yes","no"}:
raise ValueError("Invalid value of argument not_voted")
if not_voted_spec == None:
not_voted_spec=not_voted
elif not_voted_spec not in {"dont_count","yes","no"}:
raise ValueError("Invalid value of argument not_voted_spec")
if min_needed>100:
min_needed=100
elif min_needed<0:
min_needed=0
yes_count=len(self.__players_voted_yes)
no_count=len(self.__players_voted_no)
voted_players=self.__players_voted_yes + self.__players_voted_no
bots=Player.getBots()
cur_mode=None
for player in Player.players:
if player in bots or Player.players[player].ip in voted_players:
continue
if Player.players[player].getTeam()==None: # Player is spectating
cur_mode=not_voted_spec
else:
cur_mode=not_voted
if cur_mode == "yes":
yes_count=yes_count+1
elif cur_mode == "no":
no_count=no_count+1
else:
pass
num_allowed=len(Player.players)-len(Player.getBots())
if not spec_allowed:
num_allowed=num_allowed-len([i for i in Player.players.values() if i.getTeam()==None])
if yes_count+no_count==0 or num_allowed==0:
percent_yes=0
percent_no=0
elif only_sure==False:
percent_yes=yes_count/(yes_count+no_count)*100
percent_no=100-percent_yes
else:
percent_yes=yes_count/num_allowed*100
percent_no=no_count/num_allowed*100
if num_allowed==1:
percent_yes=100
percent_no=0
if percent_yes >= min_needed:
log.info("Poll for {0} successed.".format(self.target) )
Armagetronad.SendCommand("CONSOLE_MESSAGE "+Messages.PollSuccessed.format(target=self.target) )
self.action()
elif percent_no>(100-min_needed):
log.info("Poll for {0} failed.".format(self.target) )
Armagetronad.SendCommand("CONSOLE_MESSAGE "+Messages.PollFailed.format(target=self.target) )
else:
return False
global current_poll
current_poll=None
return True
示例2: NewRound
# 需要导入模块: import Player [as 别名]
# 或者: from Player import getBots [as 别名]
def NewRound(date, time, timezone):
global roundStarted
# Flush bot list (NEEDED because no PlayerLeft is called for bots)
bots=Player.getBots()
for bot in bots:
Player.Remove(bot)
roundStarted=True
Armagetronad.SendCommand("WAIT_FOR_EXTERNAL_SCRIPT 1")
log.debug("## New round started ##")