예제 #1
0
def parse_rune_data(rune_data, owner):
    com2us_id = rune_data.get('rune_id')

    rune = RuneInstance.objects.filter(com2us_id=com2us_id,
                                       owner=owner).first()

    if not rune:
        rune = RuneInstance()

    # Firstly, info that may say if rune has changed or not
    substats = rune_data.get('sec_eff', [])
    temp_substats = []
    temp_substat_values = []
    temp_substats_enchanted = []
    temp_substats_grind_value = []

    for substat in substats:
        substat_type = RuneInstance.COM2US_STAT_MAP[substat[0]]
        substat_value = substat[1]
        enchanted = substat[2] == 1 if len(substat) >= 3 else 0
        grind_value = substat[3] if len(substat) >= 4 else 0

        temp_substats.append(substat_type)
        temp_substat_values.append(substat_value)
        temp_substats_enchanted.append(enchanted)
        temp_substats_grind_value.append(grind_value)

    # Basic rune info
    rune.type = RuneInstance.COM2US_TYPE_MAP[rune_data['set_id']]
    rune.com2us_id = com2us_id
    rune.value = rune_data.get('sell_value')
    rune.slot = rune_data.get('slot_no')
    stars = rune_data.get('class')
    if stars > 10:
        stars -= 10
        rune.ancient = True
    rune.stars = stars
    rune.level = rune_data.get('upgrade_curr')
    rune.original_quality = RuneInstance.COM2US_QUALITY_MAP.get(
        rune_data.get('extra'))

    # Rune stats
    main_stat = rune_data.get('pri_eff')
    if main_stat:
        rune.main_stat = RuneInstance.COM2US_STAT_MAP[main_stat[0]]
        rune.main_stat_value = main_stat[1]

    innate_stat = rune_data.get('prefix_eff')
    if innate_stat:
        rune.innate_stat = RuneInstance.COM2US_STAT_MAP.get(innate_stat[0])
        rune.innate_stat_value = innate_stat[1]

    rune.substats = temp_substats
    rune.substat_values = temp_substat_values
    rune.substats_enchanted = temp_substats_enchanted
    rune.substats_grind_value = temp_substats_grind_value

    rune.owner = owner

    return rune
예제 #2
0
def parse_rune_data(rune_data, owner):
    com2us_id = rune_data.get('rune_id')

    rune = RuneInstance.objects.filter(com2us_id=com2us_id,
                                       owner=owner).first()

    if not rune:
        rune = RuneInstance()

    # Basic rune info
    rune.type = com2us_mapping.rune_set_map.get(rune_data.get('set_id'))

    rune.com2us_id = com2us_id
    rune.value = rune_data.get('sell_value')
    rune.slot = rune_data.get('slot_no')
    stars = rune_data.get('class')
    if stars > 10:
        stars -= 10
        rune.ancient = True
    rune.stars = stars
    rune.level = rune_data.get('upgrade_curr')
    original_quality = rune_data.get('extra')

    if original_quality:
        if original_quality > 10:
            original_quality -= 10

        rune.original_quality = com2us_mapping.rune_quality_map[
            original_quality]

    # Rune stats
    main_stat = rune_data.get('pri_eff')
    if main_stat:
        rune.main_stat = com2us_mapping.rune_stat_type_map.get(main_stat[0])
        rune.main_stat_value = main_stat[1]

    innate_stat = rune_data.get('prefix_eff')
    if innate_stat:
        rune.innate_stat = com2us_mapping.rune_stat_type_map.get(
            innate_stat[0])
        rune.innate_stat_value = innate_stat[1]

    substats = rune_data.get('sec_eff', [])
    rune.substats = []
    rune.substat_values = []
    rune.substats_enchanted = []
    rune.substats_grind_value = []

    for substat in substats:
        substat_type = com2us_mapping.rune_stat_type_map.get(substat[0])
        substat_value = substat[1]
        enchanted = substat[2] == 1
        grind_value = substat[3]

        rune.substats.append(substat_type)
        rune.substat_values.append(substat_value)
        rune.substats_enchanted.append(enchanted)
        rune.substats_grind_value.append(grind_value)

    return rune
예제 #3
0
def parse_rune_data(rune_data, owner):
    com2us_id = rune_data.get('rune_id')

    rune = RuneInstance.objects.filter(com2us_id=com2us_id, owner=owner).first()

    if not rune:
        rune = RuneInstance()

    # Make sure it's saved as a new instance and marked as an import
    rune.pk = None
    rune.uncommitted = True

    # Basic rune info
    rune.type = rune_set_map.get(rune_data.get('set_id'))

    rune.com2us_id = com2us_id
    rune.value = rune_data.get('sell_value')
    rune.slot = rune_data.get('slot_no')
    rune.stars = rune_data.get('class')
    rune.level = rune_data.get('upgrade_curr')

    # Rune stats
    main_stat = rune_data.get('pri_eff')
    if main_stat:
        rune.main_stat = rune_stat_type_map.get(main_stat[0])
        rune.main_stat_value = main_stat[1]

    innate_stat = rune_data.get('prefix_eff')
    if innate_stat:
        rune.innate_stat = rune_stat_type_map.get(innate_stat[0])
        rune.innate_stat_value = innate_stat[1]

    substats = rune_data.get('sec_eff', [])
    if len(substats) >= 1:
        rune.substat_1 = rune_stat_type_map.get(substats[0][0])
        rune.substat_1_value = substats[0][1] + substats[0][3]
        if substats[0][3]:
            rune.substat_1_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[0][2]:
            rune.substat_1_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 2:
        rune.substat_2 = rune_stat_type_map.get(substats[1][0])
        rune.substat_2_value = substats[1][1] + substats[1][3]
        if substats[1][3]:
            rune.substat_2_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[1][2]:
            rune.substat_2_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 3:
        rune.substat_3 = rune_stat_type_map.get(substats[2][0])
        rune.substat_3_value = substats[2][1] + substats[2][3]
        if substats[2][3]:
            rune.substat_3_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[2][2]:
            rune.substat_3_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 4:
        rune.substat_4 = rune_stat_type_map.get(substats[3][0])
        rune.substat_4_value = substats[3][1] + substats[3][3]
        if substats[3][3]:
            rune.substat_4_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[3][2]:
            rune.substat_4_craft = RuneInstance.CRAFT_ENCHANT_GEM

    return rune
예제 #4
0
def parse_rune_data(rune_data, owner):
    com2us_id = rune_data.get('rune_id')

    rune = RuneInstance.objects.filter(com2us_id=com2us_id,
                                       owner=owner).first()

    if not rune:
        rune = RuneInstance()

    # Basic rune info
    rune.type = rune_set_map.get(rune_data.get('set_id'))

    rune.com2us_id = com2us_id
    rune.value = rune_data.get('sell_value')
    rune.slot = rune_data.get('slot_no')
    rune.stars = rune_data.get('class')
    rune.level = rune_data.get('upgrade_curr')
    original_quality = rune_data.get('extra')

    if original_quality:
        rune.original_quality = rune_quality_map[original_quality]

    # Rune stats
    main_stat = rune_data.get('pri_eff')
    if main_stat:
        rune.main_stat = rune_stat_type_map.get(main_stat[0])
        rune.main_stat_value = main_stat[1]

    innate_stat = rune_data.get('prefix_eff')
    if innate_stat:
        rune.innate_stat = rune_stat_type_map.get(innate_stat[0])
        rune.innate_stat_value = innate_stat[1]

    substats = rune_data.get('sec_eff', [])
    if len(substats) >= 1:
        rune.substat_1 = rune_stat_type_map.get(substats[0][0])
        rune.substat_1_value = substats[0][1] + substats[0][3]
        if substats[0][3]:
            rune.substat_1_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[0][2]:
            rune.substat_1_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 2:
        rune.substat_2 = rune_stat_type_map.get(substats[1][0])
        rune.substat_2_value = substats[1][1] + substats[1][3]
        if substats[1][3]:
            rune.substat_2_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[1][2]:
            rune.substat_2_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 3:
        rune.substat_3 = rune_stat_type_map.get(substats[2][0])
        rune.substat_3_value = substats[2][1] + substats[2][3]
        if substats[2][3]:
            rune.substat_3_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[2][2]:
            rune.substat_3_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 4:
        rune.substat_4 = rune_stat_type_map.get(substats[3][0])
        rune.substat_4_value = substats[3][1] + substats[3][3]
        if substats[3][3]:
            rune.substat_4_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[3][2]:
            rune.substat_4_craft = RuneInstance.CRAFT_ENCHANT_GEM

    return rune
예제 #5
0
def parse_rune_data(rune_data, owner):
    com2us_id = rune_data.get('rune_id')

    rune = RuneInstance.objects.filter(com2us_id=com2us_id, owner=owner).first()

    if not rune:
        rune = RuneInstance()

    # Make sure it's saved as a new instance and marked as an import
    rune.pk = None
    rune.uncommitted = True

    # Basic rune info
    rune.type = rune_set_map.get(rune_data.get('set_id'))

    rune.com2us_id = com2us_id
    rune.value = rune_data.get('sell_value')
    rune.slot = rune_data.get('slot_no')
    rune.stars = rune_data.get('class')
    rune.level = rune_data.get('upgrade_curr')

    # Rune stats
    main_stat = rune_data.get('pri_eff')
    if main_stat:
        rune.main_stat = rune_stat_type_map.get(main_stat[0])
        rune.main_stat_value = main_stat[1]

    innate_stat = rune_data.get('prefix_eff')
    if innate_stat:
        rune.innate_stat = rune_stat_type_map.get(innate_stat[0])
        rune.innate_stat_value = innate_stat[1]

    substats = rune_data.get('sec_eff', [])
    if len(substats) >= 1:
        rune.substat_1 = rune_stat_type_map.get(substats[0][0])
        rune.substat_1_value = substats[0][1] + substats[0][3]
        if substats[0][3]:
            rune.substat_1_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[0][2]:
            rune.substat_1_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 2:
        rune.substat_2 = rune_stat_type_map.get(substats[1][0])
        rune.substat_2_value = substats[1][1] + substats[1][3]
        if substats[1][3]:
            rune.substat_2_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[1][2]:
            rune.substat_2_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 3:
        rune.substat_3 = rune_stat_type_map.get(substats[2][0])
        rune.substat_3_value = substats[2][1] + substats[2][3]
        if substats[2][3]:
            rune.substat_3_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[2][2]:
            rune.substat_3_craft = RuneInstance.CRAFT_ENCHANT_GEM

    if len(substats) >= 4:
        rune.substat_4 = rune_stat_type_map.get(substats[3][0])
        rune.substat_4_value = substats[3][1] + substats[3][3]
        if substats[3][3]:
            rune.substat_4_craft = RuneInstance.CRAFT_GRINDSTONE
        elif substats[3][2]:
            rune.substat_4_craft = RuneInstance.CRAFT_ENCHANT_GEM

    return rune