def _convert_gepl(self, gepl, multipliers, is_support): r = { "required_level": gepl["LevelRequirement"], } if gepl["Cooldown"] > 0: r["cooldown"] = gepl["Cooldown"] cooldown_bypass_type = CooldownBypassType(gepl["CooldownBypassType"]) if cooldown_bypass_type is not CooldownBypassType.none: r["cooldown_bypass_type"] = cooldown_bypass_type.name if gepl["StoredUses"] > 0: r["stored_uses"] = gepl["StoredUses"] if is_support: r["mana_multiplier"] = gepl["ManaMultiplier"] else: r["mana_cost"] = gepl["ManaCost"] if gepl["DamageEffectiveness"] != 0: r["damage_effectiveness"] = gepl["DamageEffectiveness"] if gepl["DamageMultiplier"] != 0: r["damage_multiplier"] = gepl["DamageMultiplier"] if gepl["CriticalStrikeChance"] > 0: r["crit_chance"] = gepl["CriticalStrikeChance"] if gepl["AttackSpeedMultiplier"] != 0: r["attack_speed_multiplier"] = gepl["AttackSpeedMultiplier"] if gepl["VaalSouls"] > 0: r["vaal"] = {"souls": gepl["VaalSouls"], "stored_uses": gepl["VaalStoredUses"]} mana_reservation_override = gepl["ManaReservationOverride"] if mana_reservation_override > 0: r["mana_reservation_override"] = mana_reservation_override stats = [] for k, v in gepl["Stats"]: stats.append({"id": k["Id"], "value": v}) for k in gepl["StatsKeys2"]: stats.append({"id": k["Id"], "value": 1}) r["stats"] = stats q_stats = [] for k, v in gepl["QualityStats"]: q_stats.append({"id": k["Id"], "value": v}) r["quality_stats"] = q_stats if multipliers is not None: stat_requirements = {} gtype = GemTypes.support if is_support else GemTypes.active for stat_type, multi in multipliers.items(): if multi == 0 or multi == 33 or multi == 34 or multi == 50: # 33 and 34 are from white gems (Portal, Vaal Breach, Detonate Mine), which have no requirements req = 0 elif multi == 50: # 50 is from SupportTutorial ("Lesser Reduced Mana Cost Support"), for which I # have no idea what the requirements are. print("Unknown multiplier (50) for " + gepl["GrantedEffectsKey"]["Id"]) req = 0 else: req = gem_stat_requirement(gepl["LevelRequirement"], gtype, multi) stat_requirements[stat_type] = req r["stat_requirements"] = stat_requirements return r
def test_stat_requirement_invalid_multi(): with pytest.raises(ValueError): formula.gem_stat_requirement(1, formula.GemTypes.active, -1)
def test_stat_requirement_invalid_gtype(): with pytest.raises(ValueError): formula.gem_stat_requirement(1, 5, 100)
def test_stat_requirement(lvl, gtype, multi, result): r = formula.gem_stat_requirement(level=lvl, gtype=gtype, multi=multi) assert r == result, 'Result mismatch "%s" vs expected "%s"' % (r, result)
def _convert_gepl(self, gepl, multipliers, is_support): r = { "required_level": gepl["LevelRequirement"], } if gepl["Cooldown"] > 0: r["cooldown"] = gepl["Cooldown"] if gepl["CooldownBypassType"] is not CooldownBypassTypes.NONE: r["cooldown_bypass_type"] = gepl[ "CooldownBypassType"].name.lower() if gepl["StoredUses"] > 0: r["stored_uses"] = gepl["StoredUses"] if is_support: r["cost_multiplier"] = gepl["CostMultiplier"] else: r["costs"] = {} for cost_type, cost_amount in gepl["Costs"]: r["costs"][cost_type["Id"]] = cost_amount if gepl["DamageEffectiveness"] != 0: r["damage_effectiveness"] = gepl["DamageEffectiveness"] if gepl["DamageMultiplier"] != 0: r["damage_multiplier"] = gepl["DamageMultiplier"] if gepl["CriticalStrikeChance"] > 0: r["crit_chance"] = gepl["CriticalStrikeChance"] if gepl["AttackSpeedMultiplier"] != 0: r["attack_speed_multiplier"] = gepl["AttackSpeedMultiplier"] if gepl["VaalSouls"] > 0: r["vaal"] = { "souls": gepl["VaalSouls"], "stored_uses": gepl["VaalStoredUses"] } r["reservations"] = self._convert_reservations(gepl) stats = [] for k, v in gepl["Stats"]: stats.append({"id": k["Id"], "value": v}) for k in gepl["StatsKeys2"]: stats.append({"id": k["Id"], "value": 1}) r["stats"] = stats q_stats = [] if gepl["GrantedEffectsKey"][ "Id"] in self.granted_effect_quality_stats: for geq in self.granted_effect_quality_stats[ gepl["GrantedEffectsKey"]["Id"]]: for k, v in zip(geq["StatsKeys"], geq["StatsValuesPermille"]): q_stats.append({ "id": k["Id"], "value": v, "set": geq["SetId"] }) r["quality_stats"] = q_stats if multipliers is not None: stat_requirements = {} gtype = GemTypes.support if is_support else GemTypes.active for stat_type, multi in multipliers.items(): if multi == 0 or multi == 33 or multi == 34 or multi == 50: # 33 and 34 are from white gems (Portal, Vaal Breach, Detonate Mine), which have no requirements req = 0 elif multi == 50: # 50 is from SupportTutorial ("Lesser Reduced Mana Cost Support"), for which I # have no idea what the requirements are. print("Unknown multiplier (50) for " + gepl["GrantedEffectsKey"]["Id"]) req = 0 else: req = gem_stat_requirement(gepl["LevelRequirement"], gtype, multi) stat_requirements[stat_type] = req r["stat_requirements"] = stat_requirements return r
def _convert_gepl(self, gepl, multipliers, is_support): r = { 'required_level': gepl['LevelRequirement'], } if gepl['Cooldown'] > 0: r['cooldown'] = gepl['Cooldown'] cooldown_bypass_type = CooldownBypassType(gepl['CooldownBypassType']) if cooldown_bypass_type is not CooldownBypassType.none: r['cooldown_bypass_type'] = cooldown_bypass_type.name if gepl['StoredUses'] > 0: r['stored_uses'] = gepl['StoredUses'] if is_support: r['mana_multiplier'] = gepl['ManaMultiplier'] else: r['mana_cost'] = gepl['ManaCost'] if gepl['DamageEffectiveness'] != 0: r['damage_effectiveness'] = gepl['DamageEffectiveness'] if gepl['DamageMultiplier'] != 0: r['damage_multiplier'] = gepl['DamageMultiplier'] if gepl['CriticalStrikeChance'] > 0: r['crit_chance'] = gepl['CriticalStrikeChance'] if gepl['VaalSouls'] > 0: r['vaal'] = { 'souls': gepl['VaalSouls'], 'stored_uses': gepl['VaalStoredUses'] } mana_reservation_override = gepl['ManaReservationOverride'] if mana_reservation_override > 0: r['mana_reservation_override'] = mana_reservation_override stats = [] for k, v in gepl['Stats']: stats.append({ 'id': k['Id'], 'value': v }) for k in gepl['StatsKeys2']: stats.append({ 'id': k['Id'], 'value': 1 }) r['stats'] = stats q_stats = [] for k, v in gepl['QualityStats']: q_stats.append({ 'id': k['Id'], 'value': v }) r['quality_stats'] = q_stats if multipliers is not None: stat_requirements = {} gtype = GemTypes.support if is_support else GemTypes.active for stat_type, multi in multipliers.items(): if multi == 0 or multi == 33 or multi == 34 or multi == 50: # 33 and 34 are from white gems (Portal, Vaal Breach, Detonate Mine), which have no requirements req = 0 elif multi == 50: # 50 is from SupportTutorial ("Lesser Reduced Mana Cost Support"), for which I # have no idea what the requirements are. print("Unknown multiplier (50) for " + gepl['GrantedEffectsKey']['Id']) req = 0 else: req = gem_stat_requirement(gepl['LevelRequirement'], gtype, multi) stat_requirements[stat_type] = req r['stat_requirements'] = stat_requirements return r