import { EViewType, IView, ViewManager } from "./index.ts";

export class ViewLevels implements IView {
    private _div: string;
    private _buttonGame: HTMLButtonElement | null = null;
    private _viewManager: ViewManager;

    constructor(div: string, viewManager: ViewManager) {
        this._div = div;
        this._viewManager = viewManager;
        this.buttonGameClicked = this.buttonGameClicked.bind(this);
    }

    public get div(): string {
        return this._div;
    }

    public activate() {
        this._buttonGame = document.getElementById("btn-game") as HTMLButtonElement;
        if (!!this._buttonGame) {
            this._buttonGame.addEventListener("click", this.buttonGameClicked);
        }
    }

    public deactivate() {
        this._buttonGame?.removeEventListener("click", this.buttonGameClicked);
    }

    private buttonGameClicked() {
        this._viewManager.showView(EViewType.Game);
    }
}