<commit_before>import { l } from "./ui/Localization";
import { NewAddon, AceModule } from "@wowts/tsaddon";
import aceEvent from "@wowts/ace_event-3.0";
import { ipairs, wipe, LuaArray, LuaObj, _G } from "@wowts/lua";
import { UnitClass, UnitGUID, ClassId } from "@wowts/wow-mock";
import { huge } from "@wowts/math";
import { Library } from "@wowts/tslib";
import { clearOneTimeMessages } from "./tools/tools";

const maxRefreshIntervals = 500;
const refreshIntervals: LuaArray<number> = {};
let refreshIndex = 1;

export type Constructor<T> = new (...args: any[]) => T;

const name = "Ovale";

const ovaleBase = NewAddon(name, aceEvent);
export const messagePrefix = name;

export class OvaleClass extends ovaleBase {
    playerClass: ClassId = "WARRIOR";
    playerGUID = "";
    refreshNeeded: LuaObj<boolean> = {};

    constructor() {
        super();
        _G["BINDING_HEADER_OVALE"] = "Ovale";
        const toggleCheckBox = l["check_box_tooltip"];
        _G["BINDING_NAME_OVALE_CHECKBOX0"] = `${toggleCheckBox}(1)`;
        _G["BINDING_NAME_OVALE_CHECKBOX1"] = `${toggleCheckBox}(2)`;
        _G["BINDING_NAME_OVALE_CHECKBOX2"] = `${toggleCheckBox}(3)`;
        _G["BINDING_NAME_OVALE_CHECKBOX3"] = `${toggleCheckBox}(4)`;
        _G["BINDING_NAME_OVALE_CHECKBOX4"] = `${toggleCheckBox}(5)`;
    }

    // OnDisable() {
    //     this.UnregisterEvent("PLAYER_ENTERING_WORLD");
    //     this.UnregisterEvent("PLAYER_TARGET_CHANGED");
    //     this.UnregisterMessage("Ovale_CombatEnded");
    //     this.UnregisterMessage("Ovale_OptionChanged");
    //     this.frame.Hide();
    // }
    handleInitialize() {
        this.playerGUID = UnitGUID("player") || "error";
        const [, classId] = UnitClass("player");
        this.playerClass = classId || "WARRIOR";
        wipe(refreshIntervals);
        refreshIndex = 1;
        clearOneTimeMessages();
    }

    needRefresh() {
        if (this.playerGUID) {
            this.refreshNeeded[this.playerGUID] = true;
        }
    }

    addRefreshInterval(milliseconds: number) {
        if (milliseconds < huge) {
            refreshIntervals[refreshIndex] = milliseconds;
            refreshIndex =
                (refreshIndex < maxRefreshIntervals && refreshIndex + 1) || 1;
        }
    }
    getRefreshIntervalStatistics() {
        let [sumRefresh, minRefresh, maxRefresh, count] = [0, huge, 0, 0];
        for (const [, v] of ipairs(refreshIntervals)) {<commit_msg>chore: fix unit test<commit_after>import { l } from "./ui/Localization";
import { NewAddon, AceModule } from "@wowts/tsaddon";
import aceEvent from "@wowts/ace_event-3.0";
import { ipairs, wipe, LuaArray, LuaObj, _G } from "@wowts/lua";
import { UnitClass, UnitGUID, ClassId } from "@wowts/wow-mock";
import { huge } from "@wowts/math";
import { Library } from "@wowts/tslib";
import { clearOneTimeMessages } from "./tools/tools";

const maxRefreshIntervals = 500;
const refreshIntervals: LuaArray<number> = {};
let refreshIndex = 1;

export type Constructor<T> = new (...args: any[]) => T;

const name = "Ovale";

const ovaleBase = NewAddon(name, aceEvent);
export const messagePrefix = name;

export class OvaleClass extends ovaleBase {
    playerClass: ClassId = "WARRIOR";
    playerGUID = "";
    refreshNeeded: LuaObj<boolean> = {};

    constructor() {
        super();
        _G["BINDING_HEADER_OVALE"] = "Ovale";
        const toggleCheckBox = l["check_box_tooltip"];
        _G["BINDING_NAME_OVALE_CHECKBOX0"] = `${toggleCheckBox}(1)`;
        _G["BINDING_NAME_OVALE_CHECKBOX1"] = `${toggleCheckBox}(2)`;
        _G["BINDING_NAME_OVALE_CHECKBOX2"] = `${toggleCheckBox}(3)`;
        _G["BINDING_NAME_OVALE_CHECKBOX3"] = `${toggleCheckBox}(4)`;
        _G["BINDING_NAME_OVALE_CHECKBOX4"] = `${toggleCheckBox}(5)`;
    }

    // OnDisable() {
    //     this.UnregisterEvent("PLAYER_ENTERING_WORLD");
    //     this.UnregisterEvent("PLAYER_TARGET_CHANGED");
    //     this.UnregisterMessage("Ovale_CombatEnded");
    //     this.UnregisterMessage("Ovale_OptionChanged");
    //     this.frame.Hide();
    // }
    // eslint-disable-next-line @typescript-eslint/naming-convention
    OnInitialize() {
        this.playerGUID = UnitGUID("player") || "error";
        const [, classId] = UnitClass("player");
        this.playerClass = classId || "WARRIOR";
        wipe(refreshIntervals);
        refreshIndex = 1;
        clearOneTimeMessages();
    }

    needRefresh() {
        if (this.playerGUID) {
            this.refreshNeeded[this.playerGUID] = true;
        }
    }

    addRefreshInterval(milliseconds: number) {
        if (milliseconds < huge) {
            refreshIntervals[refreshIndex] = milliseconds;
            refreshIndex =
                (refreshIndex < maxRefreshIntervals && refreshIndex + 1) || 1;
        }
    }
    getRefreshIntervalStatistics() {
        let [sumRefresh, minRefresh, maxRefresh, count] = [0, huge, 0, 0];
        for (const [, v] of ipairs(refreshIntervals)) {
{'fraction_non_alphanumeric': 0.14556451612903226, 'fraction_numerical': 0.008870967741935484, 'mean_word_length': 3.193575655114117, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6108020', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1638, 'n_words': 299}