Beispiel #1
0
 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
Beispiel #2
0
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 ##")