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
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