Beispiel #1
0
def pack_mail_info(mail, message, now):
    message.index = MailInfo.get_index(mail.id)
    message.type = mail.type
    message.state = mail.status
    message.passed_time = now - mail.time
    message.delete_after_used = mail.delete_after_used

    message.reward_resource.money = mail.reward_money
    message.reward_resource.food = mail.reward_food
    message.reward_resource.gold = mail.reward_gold

    for (basic_id, num) in mail.get_reward_items():
        item_message = message.reward_items.add()
        item_message.basic_id = basic_id
        item_message.num = num

    message.lost_resource.money = mail.lost_money
    message.lost_resource.food = mail.lost_food
    message.lost_resource.gold = mail.lost_gold
    message.lost_resource.soldier = mail.lost_soldier

    if mail.related_node_id != 0:
        message.node_id = NodeInfo.get_basic_id(mail.related_node_id)

    if mail.related_exploitation_type != 0:
        message.exploitation_type = mail.related_exploitation_type
        message.exploitation_level = mail.related_exploitation_level
        message.exploitation_progress = mail.related_exploitation_progress

    if mail.related_enemy_type != 0:
        message.enemy_type = mail.related_enemy_type
        message.enemy_name = mail.get_readable_enemy_name()
        message.battle_win = mail.related_battle_win

    message.basic_id = mail.basic_id
    #if not mail.is_content_empty():
    #    message.subject = mail.subject
    #    message.sender = mail.sender
    #    message.content = mail.content
    if mail.subject != '':
        message.subject = mail.subject
    if mail.sender != '':
        message.sender = mail.sender
    if mail.content != '':
        message.content = mail.content

    if mail.arena_title_level != 0:
        message.arena_title_level = mail.arena_title_level
    if mail.arena_coin != 0:
        message.arena_coin = mail.arena_coin

    if mail.legendcity_id != 0:
        message.legendcity_id = mail.legendcity_id
        message.legendcity_position = mail.legendcity_position
Beispiel #2
0
def pack_hero_info(info, message, now, with_skill = True, with_detail = True):
    message.basic_id = info.basic_id
    message.level = info.level
    message.evolution_level = info.evolution_level
    message.exp = info.exp
    message.star_level = info.star
    message.soldier_basic_id = info.soldier_basic_id
    message.soldier_level = info.soldier_level

    if with_detail == False:
        return 

    if with_skill:
        #与客户端约定,不传skill,客户端会按照当前英雄等级升满技能
        skills = utils.split_to_int(info.skills_id)
        message.first_skill_id = skills[0]
        message.second_skill_id = skills[1]
        message.third_skill_id = skills[2]
        message.fourth_skill_id = skills[3]

    message.equipment_weapon_id = info.get_equipment(info.EQUIPMENT_TYPE_WEAPON)
    message.equipment_armor_id = info.get_equipment(info.EQUIPMENT_TYPE_ARMOR)
    message.equipment_treasure_id = info.get_equipment(info.EQUIPMENT_TYPE_TREASURE)

    for stone in info.get_equipment_stones(info.EQUIPMENT_TYPE_WEAPON):
        message.stone_weapon.append(stone)
    for stone in info.get_equipment_stones(info.EQUIPMENT_TYPE_ARMOR):
        message.stone_armor.append(stone)
    for stone in info.get_equipment_stones(info.EQUIPMENT_TYPE_TREASURE):
        message.stone_treasure.append(stone)

    if info.place_type == info.PLACE_TYPE_BUILDING:
        message.building_basic_id = BuildingInfo.get_basic_id(info.place_id)
        message.city_basic_id = BuildingInfo.get_city_basic_id(info.place_id)
        message.location_index = BuildingInfo.get_location_index(info.place_id)
        message.garrison_passed_time = now - info.update_time
    elif info.place_type == info.PLACE_TYPE_NODE:
        message.node_id = NodeInfo.get_basic_id(info.place_id)
        message.garrison_passed_time = now - info.update_time

    message.battle_node_id = info.battle_node_basic_id

    for star_id in info.get_herostars():
        message.hero_star.append(star_id)
    
    message.hero_awakening = info.is_awaken
    
    refine_types = info.REFINE_TYPES
    refine_values = info.get_refine_values()
    _, refine_limits = info.refine_value_limits()
    
    assert len(refine_values) == len(refine_types)
    for i in xrange(len(refine_types)):
        attribute = message.hero_refine_attributes.add()
        attribute.type = getattr(attribute, refine_types[i])
        attribute.value = refine_values[i]

    assert len(refine_limits) == len(refine_types)
    for i in xrange(len(refine_types)):
        attribute = message.hero_refine_limits.add()
        attribute.type = getattr(attribute, refine_types[i])
        attribute.value = refine_limits[i]

    is_full = 1
    for i in xrange(len(refine_types)):
        if refine_values < refine_limits:
            is_full = 0

    message.hero_refine_info.refineLv = info.refine_level
    message.hero_refine_info.refineState = is_full