예제 #1
0
def given_stamina_1108(data, player):
    response = CommonResponse()
    response.result = True
    response.result_no = 0
    request = friend_pb2.FriendCommon()
    request.ParseFromString(data)

    request = friend_pb2.FriendCommon()
    request.ParseFromString(data)
    target_id = request.target_ids[0]

    player_data = tb_character_info.getObjData(target_id)
    open_receive = player_data.get('stamina').get('open_receive')

    if not player.friends.given_stamina(target_id, if_present=open_receive):
        response.result = False
        response.result_no = 1  # fail
        return response.SerializePartialToString()  # fail

    player.friends.save_data()

    lively_event = CountEvent.create_event(EventType.PRESENT, 1, ifadd=True)
    tstatus = player.tasks.check_inter(lively_event)
    if tstatus:
        task_data = task_status(player)
        remote_gate.push_object_remote(1234, task_data, [player.dynamic_id])
    return response.SerializePartialToString()  # fail
예제 #2
0
def find_friend_request_1107(data, player):
    request = friend_pb2.FindFriendRequest()
    request.ParseFromString(data)

    response = friend_pb2.FindFriendResponse()
    response.id = 0
    response.nickname = 'none'
    response.atk = 111
    response.hero_no = 11
    response.gift = datetime.datetime.now().day

    if request.id_or_nickname.isdigit():
        player_data = tb_character_info.getObjData(request.id_or_nickname)

    else:
        prere = dict(nickname=request.id_or_nickname)
        player_data = util.GetOneRecordInfo('tb_character_info', prere)

    if player_data:
        response.id = player_data.get('id')
        response.nickname = player_data.get('nickname')

        # 添加好友主将的属性
        _with_battle_info(response, player_data.get('id'))

    return response.SerializePartialToString()
예제 #3
0
def get_player_friend_list_1106(data, player):
    response = friend_pb2.GetPlayerFriendsResponse()
    response.open_receive = player.stamina._open_receive

    for pid in player.friends.friends + [player.base_info.id]:
        player_data = tb_character_info.getObjData(pid)
        if player_data:
            response_friend_add = response.friends.add()
            response_friend_add.id = pid
            response_friend_add.nickname = player_data.get('nickname')
            response_friend_add.gift = player.friends.last_present_times(pid)

            # 添加好友主将的属性
            _with_battle_info(response_friend_add, pid)
        else:
            logger.error('friend_list, cant find player id:%d' % pid)
            player.friends.friends.remove(pid)

    for pid in player.friends.blacklist:
        player_data = tb_character_info.getObjData(pid)
        if player_data:
            response_blacklist_add = response.blacklist.add()
            response_blacklist_add.id = pid
            response_blacklist_add.nickname = player_data.get('nickname')
            response_blacklist_add.gift = 0

            # 添加好友主将的属性
            _with_battle_info(response_blacklist_add, pid)
        else:
            logger.error('black_list cant find player id:%d' % pid)
            player.friends.blacklist.remove(pid)

    for pid in player.friends.applicant_list:
        player_data = tb_character_info.getObjData(pid)
        if player_data:
            response_applicant_list_add = response.applicant_list.add()
            response_applicant_list_add.id = pid
            response_applicant_list_add.nickname = player_data.get('nickname')
            response_applicant_list_add.gift = 0

            # 添加好友主将的属性
            _with_battle_info(response_applicant_list_add, pid)
        else:
            logger.error('applicant_list, cant find player id:%d' % pid)
            player.friends.applicant_list.remove(pid)

    return response.SerializePartialToString()
예제 #4
0
    def is_new_character(self):
        """is new character or not"""
        pid = self.base_info.id

        character_info = tb_character_info.getObjData(pid)
        # print 'character info:', character_info
        if character_info:
            return False
        return True
예제 #5
0
def get_role_list_811(data, player):
    """角色列表 """
    response = GuildRoleListProto()
    m_g_id = player.guild.g_id
    if m_g_id == 0:
        response.result = False
        response.message = "没有公会"
        return response.SerializeToString()

    data1 = tb_guild_info.getObjData(m_g_id)
    if not data1:
        response.result = False
        response.message = "公会ID错误"
        return response.SerializeToString()

    guild_obj = Guild()
    guild_obj.init_data(data1)

    guild_p_list = guild_obj.p_list
    if guild_p_list.values():
        for p_list in guild_p_list.values():
            for role_id in p_list:
                character_guild = tb_character_guild.getObjData(role_id)
                character_info = tb_character_info.getObjData(role_id)
                if character_info and character_guild:
                    guild_info = character_guild.get("info")
                    role_info = response.role_info.add()
                    role_info.p_id = role_id

                    if character_info.get('nickname'):
                        role_info.name = character_info['nickname']
                    else:
                        role_info.name = u'无名'
                    role_info.level = character_info['level']

                    role_info.position = guild_info.get("position")
                    role_info.all_contribution = guild_info.get(
                        "all_contribution")
                    role_info.k_num = guild_info.get("k_num")

        response.result = True
        return response.SerializeToString()
예제 #6
0
def get_guild_rank_810(data, player):
    """获取公会排行 """
    response = GuildRankProto()

    # 得到公会排行
    ranks = remote_gate.get_guild_rank_remote()
    rank_num = 1
    for rank in ranks:
        data1 = tb_guild_info.getObjData(rank[0])
        if data1 and rank != 0:
            guild_obj = Guild()
            guild_obj.init_data(data1)
            guild_rank = response.guild_rank.add()
            guild_rank.g_id = guild_obj.g_id
            guild_rank.rank = rank_num
            rank_num += 1
            guild_rank.name = guild_obj.name
            guild_rank.level = guild_obj.level

            president_id = guild_obj.p_list.get(1)[0]
            player_data = tb_character_info.getObjData(president_id)
            if player_data:
                if player_data.get('nickname'):
                    guild_rank.president = player_data.get('nickname')
                else:
                    logger.info('guild rank ,president name is null,id:%s',
                                president_id)
                    guild_rank.president = u'无名'
            else:
                guild_rank.president = u'错误'
                logger.error('guild rank, president player not fond,id:%s',
                             president_id)

            guild_rank.p_num = guild_obj.p_num
            guild_rank.record = guild_obj.record

    response.result = True
    return response.SerializeToString()
예제 #7
0
def get_apply_list_813(data, player):
    """获取申请列表 """
    response = ApplyListProto()
    m_g_id = player.guild.g_id
    if m_g_id == 0:
        response.result = False
        response.message = "没有公会"
        return response.SerializeToString()

    data1 = tb_guild_info.getObjData(m_g_id)
    if not data1:
        response.result = False
        response.message = "公会ID错误"
        return response.SerializeToString()

    guild_obj = Guild()
    guild_obj.init_data(data1)

    guild_apply = guild_obj.apply

    for role_id in guild_apply:
        # TODO 获取玩家 战斗力
        character_info = tb_character_info.getObjData(role_id)
        if character_info:
            role_info = response.role_info.add()
            role_info.p_id = role_id
            if character_info['nickname']:
                role_info.name = character_info['nickname']
            else:
                role_info.name = u'无名'
            role_info.level = character_info['level']
            role_info.vip_level = character_info['vip_level']
            role_info.fight_power = 1

    response.result = True
    return response.SerializeToString()
예제 #8
0
    def init_player_info(self):
        """初始化角色信息
        """
        pid = self.base_info.id
        character_info = tb_character_info.getObjData(pid)
        # ------------角色信息表数据---------------
        nickname = character_info['nickname']
        coin = character_info['coin']
        gold = character_info['gold']
        hero_soul = character_info['hero_soul']
        level = character_info['level']
        exp = character_info['exp']
        junior_stone = character_info['junior_stone']
        middle_stone = character_info['middle_stone']
        high_stone = character_info['high_stone']
        fine_hero_last_pick_time = character_info['fine_hero_last_pick_time']
        excellent_hero_last_pick_time =\
            character_info['excellent_hero_last_pick_time']
        fine_equipment_last_pick_time =\
            character_info['fine_equipment_last_pick_time']
        excellent_equipment_last_pick_time =\
            character_info['excellent_equipment_last_pick_time']
        pvp_times = character_info['pvp_times']
        vip_level = character_info['vip_level']

        # ------------初始化角色基础信息组件---------
        self.base_info.base_name = nickname  # 角色昵称

        # ------------初始化角色货币信息------------
        self._finance.coin = coin
        self._finance.gold = gold
        self._finance.hero_soul = hero_soul
        self._finance.junior_stone = junior_stone
        self._finance.middle_stone = middle_stone
        self._finance.high_stone = high_stone

        # ------------初始化上次抽取信息------------
        self._last_pick_time.fine_hero = fine_hero_last_pick_time
        self._last_pick_time.excellent_hero = excellent_hero_last_pick_time
        self._last_pick_time.fine_equipment = fine_equipment_last_pick_time
        self._last_pick_time.excellent_equipment =\
            excellent_equipment_last_pick_time

        # ------------初始化角色等级信息------------
        self._level.level = level
        self._level.exp = exp

        # ------------初始化角色其他组件------------
        self._hero_component.init_heros()  # 初始化武将列表
        self._item_package.init_data()
        self._line_up.init_data()
        self._equipment.init_data()
        self._equipment_chip.init_data()
        self._hero_chip_component.init_hero_chips()  # 初始化武将碎片
        self._mail.init_data()  # 初始化邮箱
        self._friends.init_data()
        self._guild.init_data()
        self._stage.init_data()

        self._pvp_times = pvp_times
        self._sign_in.init_sign_in()
        self._online_gift.init_data()
        self._level_gift.init_data()
        self._feast.init_feast()
        self._login_gift.init_data()
        self._world_boss.init_data()
        self._vip.init_vip(vip_level)
        self._stamina.init_stamina(character_info.get('stamina'))
        self._soul_shop.init_soul_shop(character_info.get('soul_shop'))
        self._arena_shop.init_arena_shop(character_info.get('arena_shop'))
        self._brew.init_data()
        self._travel.init_data()