import json import math MAINSTAT = json.loads(""" { "mainstat": { "1": { "max": { "1": 804, "2": 1092, "3": 1380, "4": 1704, "5": 2088, "6": 2448 } }, "2": { "max": { "1": 18, "2": 20, "3": 38, "4": 43, "5": 51, "6": 63 } }, "3": { "max": { "1": 54, "2": 74, "3": 93, "4": 113, "5": 135, "6": 160 } }, "4": { "max": { "1": 18, "2": 20, "3": 38, "4": 43, "5": 51, "6": 63 } }, "5": { "max": { "1": 54, "2": 74, "3": 93, "4": 113, "5": 135, "6": 160 } }, "6": { "max": { "1": 18, "2": 20, "3": 38, "4": 43, "5": 51, "6": 63 } }, "8": { "max": { "1": 18, "2": 19, "3": 25, "4": 30, "5": 39, "6": 42 } }, "9": { "max": { "1": 18, "2": 20, "3": 37, "4": 41, "5": 47, "6": 58 } }, "10": { "max": { "1": 20, "2": 37, "3": 43, "4": 58, "5": 65, "6": 80 } }, "11": { "max": { "1": 18, "2": 20, "3": 38, "4": 44, "5": 51, "6": 64 } }, "12": { "max": { "1": 18, "2": 20, "3": 38, "4": 44, "5": 51, "6": 64 } } }, "substat": { "1": { "max": { "1": 300, "2": 525, "3": 825, "4": 1125, "5": 1500, "6": 1875 } }, "2": { "max": { "1": 10, "2": 15, "3": 25, "4": 30, "5": 35, "6": 40 } }, "3": { "max": { "1": 20, "2": 25, "3": 40, "4": 50, "5": 75, "6": 100 } }, "4": { "max": { "1": 10, "2": 15, "3": 25, "4": 30, "5": 35, "6": 40 } }, "5": { "max": { "1": 20, "2": 25, "3": 40, "4": 50, "5": 75, "6": 100 } }, "6": { "max": { "1": 10, "2": 15, "3": 25, "4": 30, "5": 35, "6": 40 } }, "8": { "max": { "1": 5, "2": 10, "3": 15, "4": 20, "5": 25, "6": 30 } }, "9": { "max": { "1": 5, "2": 10, "3": 15, "4": 20, "5": 25, "6": 30 } }, "10": { "max": { "1": 10, "2": 15, "3": 20, "4": 25, "5": 25, "6": 35 } }, "11": { "max": { "1": 10, "2": 15, "3": 20, "4": 25, "5": 35, "6": 40 } }, "12": { "max": { "1": 10, "2": 15, "3": 20, "4": 25, "5": 35, "6": 40 } } } } """) SUBSTAT = json.loads(""" { "substat": { "1": { "max": { "1": 300, "2": 525, "3": 825, "4": 1125, "5": 1500, "6": 1875 } }, "2": { "max": { "1": 10, "2": 15, "3": 25, "4": 30, "5": 35, "6": 40 } }, "3": { "max": { "1": 20, "2": 25, "3": 40, "4": 50, "5": 75, "6": 100 } }, "4": { "max": { "1": 10, "2": 15, "3": 25, "4": 30, "5": 35, "6": 40 } }, "5": { "max": { "1": 20, "2": 25, "3": 40, "4": 50, "5": 75, "6": 100 } }, "6": { "max": { "1": 10, "2": 15, "3": 25, "4": 30, "5": 35, "6": 40 } }, "8": { "max": { "1": 5, "2": 10, "3": 15, "4": 20, "5": 25, "6": 30 } }, "9": { "max": { "1": 5, "2": 10, "3": 15, "4": 20, "5": 25, "6": 30 } }, "10": { "max": { "1": 10, "2": 15, "3": 20, "4": 25, "5": 25, "6": 35 } }, "11": { "max": { "1": 10, "2": 15, "3": 20, "4": 25, "5": 35, "6": 40 } }, "12": { "max": { "1": 10, "2": 15, "3": 20, "4": 25, "5": 35, "6": 40 } } } } """) """ Calculates a rune current and max efficiency. :param rune: JSON woth rune info. :return: current, max efficiency. """ def calculate_efficiency(rune): #getRuneEfficiency(rune, toFixed = 2) { ratio = 0.0; # Get actual stars (ancient are +10) r_class = rune["class"] if r_class > 10: r_class -= 10 r_class = str(r_class) # Main stat ratio += MAINSTAT["mainstat"][str(rune["pri_eff"][0])]["max"][r_class] / MAINSTAT["mainstat"][str(rune["pri_eff"][0])]["max"]["6"] # Innate stat if (rune["prefix_eff"] and rune["prefix_eff"][0] > 0): ratio += rune["prefix_eff"][1] / SUBSTAT["substat"][str(rune["prefix_eff"][0])]["max"]["6"]; # Sub stats for substat in rune["sec_eff"]: value = substat[1] if "3" in substat and substat[3] > 0: value += substat[3] ratio += (value / SUBSTAT["substat"][str(substat[0])]["max"]["6"]) efficiency = (ratio / 2.8) * 100; return ((ratio / 2.8) * 100), (efficiency + ((max(math.ceil((12 - rune["upgrade_curr"]) / 3.0), 0) * 0.2) / 2.8) * 100)