Exemplo n.º 1
0
    def _query_battle_score_ranking_succeed(self, proxy, user_id, req,
                                            self_ranking, self_battlescore,
                                            player_scores, player_rankings,
                                            timer):
        users = proxy.get_all_result("user")
        if len(users) != len(player_scores) and len(users) != (
                len(player_scores) + 1):
            raise Exception("Ranking players num error")
        logger.debug('len users [%d]' % len(users))

        res = ranking_pb2.QueryRankingRes()
        res.status = 0

        for i, user in enumerate(users):
            if user.id == user_id:
                pack.pack_ranking_info_of_user(user,
                                               self_battlescore, self_ranking,
                                               res.rankings.add())
            else:
                pack.pack_ranking_info_of_user(user,
                                               player_scores[user.id].score,
                                               player_rankings[user.id] + 1,
                                               res.rankings.add())

        response = res.SerializeToString()
        log = log_formater.output2(user_id,
                                   "Query battle score ranking succeed", req,
                                   res, timer.count_ms())
        logger.notice(log)
        return response
Exemplo n.º 2
0
    def _query_melee_ranking_succeed(self, proxy, user_id, self_arena,
                                     self_ranking, all_arenas, all_arenas_rank,
                                     req, timer):

        users = proxy.get_all_result("user")

        res = ranking_pb2.QueryRankingRes()
        res.status = 0

        for i, user in enumerate(users):
            if user.id == user_id:
                pack.pack_ranking_info_of_user(
                    user, MeleeInfo.get_real_score(self_arena.score),
                    self_ranking, res.rankings.add())

            else:
                pack.pack_ranking_info_of_user(
                    user, MeleeInfo.get_real_score(all_arenas[user.id].score),
                    all_arenas_rank[user.id], res.rankings.add())

        response = res.SerializeToString()
        log = log_formater.output2(user_id, "Query melee ranking succeed", req,
                                   res, timer.count_ms())
        logger.notice(log)
        return response
Exemplo n.º 3
0
    def _query_ranking_player_powerful_teams_succeed(self, proxy,
                                                     technology_basic_ids, req,
                                                     timer, teams):
        heroes = proxy.get_all_result("hero")

        res = ranking_pb2.QueryRankingPlayerPowerfulTeamsRes()
        res.status = 0

        i = 0
        for team in teams:
            team_res = res.teams.add()
            pack.pack_team_info(team, team_res)
            team_res.index = i
            i += 1
            for team_hero_res in team_res.heroes:
                if team_hero_res.basic_id == 0:
                    continue

                for hero in heroes:
                    if hero.basic_id == team_hero_res.basic_id:
                        pack.pack_hero_info(hero, team_hero_res, timer.now)

        for basic_id in technology_basic_ids:
            res.battle_tech_ids.append(basic_id)

        response = res.SerializeToString()
        log = log_formater.output2(
            req.user_id, "Query ranking player powerful teams succeed", req,
            res, timer.count_ms())
        logger.notice(log)
        return response
Exemplo n.º 4
0
    def _query_official_position_ranking_succeed(self, proxy, user_id,
                                                 self_arena, all_arenas,
                                                 all_arenas_rank, req, timer):

        users = proxy.get_all_result("user")

        res = ranking_pb2.QueryRankingRes()
        res.status = 0

        for i, user in enumerate(users):
            #官职榜不用ranking值
            if user.id == user_id:
                if user.id not in all_arenas_rank:
                    pack.pack_ranking_info_of_user(
                        user, self_arena.calc_arena_title_level(0), 0,
                        res.rankings.add())
                else:
                    pack.pack_ranking_info_of_user(
                        user,
                        self_arena.calc_arena_title_level(
                            all_arenas_rank[user.id]), 0, res.rankings.add())
            else:
                pack.pack_ranking_info_of_user(
                    user, all_arenas[user.id].calc_arena_title_level(
                        all_arenas_rank[user.id]), 0, res.rankings.add())

        response = res.SerializeToString()
        log = log_formater.output2(user_id,
                                   "Query official position ranking succeed",
                                   req, res, timer.count_ms())
        logger.notice(log)
        return response
Exemplo n.º 5
0
 def _add_mail_succeed(self, data, req, timer):
     res = internal_pb2.AddMailRes()
     res.status = 0
     response = res.SerializeToString()
     log = log_formater.output2(req.user_id, "Add mail succeed", req, res,
                                timer.count_ms())
     logger.notice(log)
     return response
Exemplo n.º 6
0
    def _query_ranking_player_from_pve(self, req, timer):
        """从pve中查询机器人"""
        enemy = PVEEnemyPool().get_by_id(req.target_user_id)

        res = ranking_pb2.QueryRankingPlayerPowerfulTeamsRes()
        res.status = 0

        index = 0
        for i in xrange(3):
            if enemy.teamInfo[index] == 0:
                continue
            team = res.teams.add()
            team.index = i
            for j in xrange(3):
                if enemy.teamInfo[index] == 0:
                    continue
                hero = team.heroes.add()

                hero.basic_id = enemy.teamInfo[index]
                hero.level = enemy.heroLevel[index] if index < len(
                    enemy.heroLevel) else 1
                hero.star_level = enemy.heroStarLevel[index] if index < len(
                    enemy.heroStarLevel) else 1

                if index < len(enemy.soldierBasicId):
                    hero.soldier_basic_id = enemy.soldierBasicId[index]
                hero.soldier_level = enemy.soldierLevel[index] if index < len(
                    enemy.soldierLevel) else 1

                if index * 3 < len(enemy.heroEquipmentId):
                    hero.equipment_weapon_id = enemy.heroEquipmentId[index * 3]
                if index * 3 + 1 < len(enemy.heroEquipmentId):
                    hero.equipment_armor_id = enemy.heroEquipmentId[index * 3 +
                                                                    1]
                if index * 3 + 2 < len(enemy.heroEquipmentId):
                    hero.equipment_treasure_id = enemy.heroEquipmentId[index *
                                                                       3 + 2]

                hero.evolution_level = enemy.heroEvolutionLevel[
                    index] if index < len(enemy.heroEvolutionLevel) else 1

                index += 1

        response = res.SerializeToString()
        log = log_formater.output2(
            req.user_id, "Query ranking robot powerful teams succeed", req,
            res, timer.count_ms())
        logger.notice(log)
        return response