Exemple #1
0
    def gm_add_ally_members(self, a_name, p_name, num):
        """添加同盟成员的数目"""
        if p_name:
            return self._add_member_by_p_name(a_name, p_name)

        try:
            rpc_store = self.player._game.rpc_store
            ally_mgr = Game.instance.rpc_ally_mgr
            sum_num = 0  #通过GM命令加入同盟的总数
            lev_in_num = PlayerData.count({FN_PLAYER_LEVEL: {
                FOP_GTE: 1
            }})  #达到等级条件的总数
            us_list = []  #本次使用到了的pid
            #每个段的起始和结束pid[(s1,e1), (s2,e2))]
            section_list = [(i * SECTION, (i + 1) * SECTION)
                            for i in xrange(lev_in_num / SECTION)]
            start_time = time.time()
            shuffle(section_list)
            if not ally_mgr.set_gm_ally_by_name(a_name):
                self.log(u'公会名字不存在')
                return
            for start_pid, end_pid in section_list:
                us_list.append((start_pid, end_pid))
                for pid in xrange(start_pid, end_pid):
                    if sum_num >= num:
                        self.log(u'申请添加%s个满足等级条件的%s个实际添加%s个成员', num,
                                 lev_in_num, sum_num)
                        ally_mgr.clear_gm_ally()
                        return
                    if not rpc_store.has("player", pid):
                        log.info("table player has no pid:%s", pid)
                        continue
                    sum_num += ally_mgr.gm_add_ally(pid)
        except:
            log.log_except()
Exemple #2
0
 def _auto_start(self):
     global arena_auto_start, arena_level
     sleep_times = 60 * 5
     log.info('arena auto_start(%s) running', arena_auto_start)
     while 1:
         sleep(sleep_times)
         c = PlayerData.count({FN_PLAYER_LEVEL: {FOP_GTE: arena_level}})
         if c >= arena_auto_start:
             log.info('arena auto start:%d', c)
             self.init()
             self.is_start = True
             self.start()
             self._auto_start_task = None
             return