def overheal_cdf(source, character_name, spell_id=None, path=None, **kwargs): # make sure directories exist if path is None: path = "figs/cdf" os.makedirs(path, exist_ok=True) heal_lines, periodic_lines, absorbs = read_heals(source, character_name=character_name, **kwargs) # Group lines heal_lines = group_processed_lines(heal_lines, False, spell_id=spell_id) periodic_lines = group_processed_lines(periodic_lines, False, spell_id=spell_id) if spell_id: lines = [] # Only one will be populated if spell_id in heal_lines: lines = heal_lines[spell_id] elif spell_id in periodic_lines: lines = periodic_lines[spell_id] else: print(f"Could not find casts of spell [{spell_id}]") exit(1) process_spell(character_name, spell_id, lines, **kwargs) else: for spell_id, lines in heal_lines.items(): process_spell(character_name, spell_id, lines, show=False, path=path, **kwargs) for spell_id, lines in periodic_lines.items(): process_spell(character_name, spell_id, lines, show=False, path=path, **kwargs)
def process_log(source, character_name=None, ignore_crit=False, encounter=None, **kwargs): processor = readers.get_processor(source, character_name=character_name) encounter = processor.select_encounter(encounter=encounter) processor.process(encounter=encounter) heal_lines = processor.heals heal_lines = group_processed_lines(heal_lines, ignore_crit) # periodic_lines = group_processed_lines(periodic_lines, ignore_crit) # Aggregate and display data print() if encounter: print(f" {encounter.boss}:") total_data, data_list = aggregate_lines(heal_lines, **kwargs) display_lines(total_data, data_list, "Spell") # print() # total_data, data_list = aggregate_lines(periodic_lines, **kwargs) # display_lines(total_data, data_list, "Periodic") print()
def overheal_crit(source, character_name, spell_id=None, encounter=None): processor = readers.get_processor(source, character_name=character_name) encounter = processor.select_encounter(encounter=encounter) processor.process(encounter=encounter) heal_lines = processor.direct_heals # only care about direct heals (periodics cannot crit) # Group lines heal_lines = group_processed_lines(heal_lines, False, spell_id=spell_id) data = [] if spell_id: lines = [] # Only one will be populated if spell_id in heal_lines: lines = heal_lines[spell_id] else: print(f"Could not find casts of spell [{spell_id}]") exit(1) data.append(process_spell(spell_id, lines)) else: for spell_id, lines in heal_lines.items(): data.append(process_spell(spell_id, lines)) print_results(data)
def overheal_plot(source, character_name, ignore_crit=False, spell_id=None, spell_power=None, path=None, encounter=None, **kwargs): processor = readers.get_processor(source, character_name=character_name) encounter = processor.select_encounter(encounter=encounter) processor.process(encounter=encounter) heal_lines = processor.heals # Group lines heal_lines = group_processed_lines(heal_lines, ignore_crit, spell_id=spell_id) if spell_power is None: sp_neg = 400.0 sp_shift = 0.0 sp_extrap = 200.0 else: sp_neg = spell_power sp_shift = spell_power sp_extrap = 1000.0 - spell_power if sp_extrap < 0: sp_extrap = 1500.0 - spell_power spell_powers = np.linspace(0, -sp_neg, int(sp_neg) + 1) for spell_id, lines in heal_lines.items(): out = group_lines_for_spell(spell_id, lines, spell_powers) plot_overheal( character_name, spell_powers, spell_id, out, sp_shift=sp_shift, sp_extrap=sp_extrap, path=path, encounter=encounter, )
def overheal_probability(source, character_name, spell_power=500, ignore_crit=False, spell_id=None, path=None, **kwargs): heals, periodics, absorbs = read_heals(source, character_name=character_name, **kwargs) # Group lines heal_lines = group_processed_lines(heals + periodics, ignore_crit, spell_id=spell_id) for spell_id, lines in heal_lines.items(): spell_overheal_probability(character_name, spell_id, lines, spell_power, path=path)
def overheal_summary(source, character_name, spell_power, path=None, show=False, encounter=None): # log_lines = raw.get_lines(log_file) # heal_lines, periodic_lines, _ = read_heals(source, character_name=character_name) processor = readers.get_processor(source, character_name=character_name) encounter = processor.select_encounter(encounter=encounter) processor.process(encounter=encounter) heal_lines = processor.heals if path is None: path = "figs" os.makedirs(path, exist_ok=True) # Group lines heal_lines = group_processed_lines(heal_lines, False) # periodic_lines = group_processed_lines(periodic_lines, False) labels = [] nn_underheal = [] nn_overheal = [] nn_downrank = [] nn_drop_h = [] for spell_id, lines in heal_lines.items(): labels.append(sd.spell_name(spell_id)) data = process_spell(spell_id, lines, spell_power) if not data: continue n_heal, n_underheal, n_overheal, n_downrank, n_drop_h = data nn_underheal.append(n_underheal / n_heal) nn_overheal.append(n_overheal / n_heal) nn_downrank.append(n_downrank / n_heal) nn_drop_h.append(n_drop_h / n_heal) # for spell_id, lines in periodic_lines.items(): # labels.append(sd.spell_name(spell_id)) # data = process_spell(spell_id, lines, spell_power) # # if not data: # continue # # n_heal, n_underheal, n_overheal, n_downrank, n_drop_h = data # # nn_underheal.append(n_underheal / n_heal) # nn_overheal.append(n_overheal / n_heal) # nn_downrank.append(n_downrank / n_heal) # nn_drop_h.append(n_drop_h / n_heal) ii = np.argsort(nn_underheal) labels = np.array(labels)[ii] nn_overheal = np.array(nn_overheal)[ii] nn_underheal = np.array(nn_underheal)[ii] nn_downrank = np.array(nn_downrank)[ii] nn_drop_h = np.array(nn_drop_h)[ii] b0 = nn_underheal b1 = b0 + nn_drop_h b2 = b1 + nn_downrank plt.figure(figsize=(8, 6), constrained_layout=True) plt.bar(labels, nn_underheal, color="green", label="Underheal") plt.bar(labels, nn_drop_h, color="yellow", bottom=b0, label="Partial OH, less than +heal") plt.bar(labels, nn_downrank, color="orange", bottom=b1, label="Partial OH, more than +heal") plt.bar(labels, nn_overheal, color="red", bottom=b2, label="Full overheal") if encounter: title = f"{character_name}: {encounter.boss}" else: title = character_name plt.title(title) plt.ylabel("Fraction of casts") plt.xticks(rotation=90) plt.legend(loc="center left", bbox_to_anchor=(1, 0.5)) plt.savefig(f"{path}/{character_name}_summary.png") if show: plt.show() plt.close()
def estimate_spell_power(source, character_name, spell_id=None, spiritual_healing=0, improved_renew=0, **kwargs): heal_lines, periodic_lines, _ = read_heals(source, character_name=character_name, spell_id=spell_id, **kwargs) if spiritual_healing > 5: spiritual_healing = 5 if improved_renew > 3: improved_renew = 3 # Group lines heal_lines = group_processed_lines(heal_lines, False, spell_id=spell_id) periodic_lines = group_processed_lines(periodic_lines, False, spell_id=spell_id) print() print(f" Spiritual Healing: {spiritual_healing:d} / 5") print(f" Improved Renew: {improved_renew:d} / 3") print() print( f" {'id':>5s} {'name':>26s} {'#':>3s} {'base H':>7s} {'mean H':>7s} {'extr H':>6s} {'Est.+H':>7s}" f" {'Crit':>5s}") print() if spell_id: # only one will be populated lines = heal_lines + periodic_lines process_spell(spell_id, lines[spell_id]) else: spell_inc = 0.02 * spiritual_healing nn_heals = 0 nn_crits = 0 estimates = [] for spell_id, lines in heal_lines.items(): est_plus_heal, n_heals, n_crits = process_spell( spell_id, lines, heal_increase=spell_inc) nn_heals += n_heals nn_crits += n_crits estimates.append(est_plus_heal) print() renew_inc = 0.05 * improved_renew for spell_id, lines in periodic_lines.items(): if spell_id == "22009": # 8t2 does not benefit from talent healing increases process_spell(spell_id, lines, heal_increase=0) else: process_spell(spell_id, lines, heal_increase=spell_inc + renew_inc) print() print(f" Estimated Spell crit: {nn_crits / nn_heals:.1%}") print()