import { Player } from "../Player";
import { Exploit } from "./Exploit";

(function () {
  function clickTheUnclickable(event: MouseEvent): void {
    if (!event.target || !(event.target instanceof Element)) return;
    const display = window.getComputedStyle(event.target as Element).display;
    if (display === "none" && event.isTrusted) Player.giveExploit(Exploit.Unclickable);
  }

  function targetElement(): void {
    const elem = document.getElementById("unclickable");
    if (elem == null) {
      console.error("Could not find the unclickable elem for the related exploit.");
      return;
    }
    elem.addEventListener("click", clickTheUnclickable);
    document.removeEventListener("DOMContentLoaded", targetElement);
  }

  document.addEventListener("DOMContentLoaded", targetElement);
})();
