Path: blob/master/cheatGUI/src/class/Hack.ts
2563 views
import { saveCharacter } from "../utils/util";1234export default class Hack {5public element: HTMLButtonElement;6public name: string;7// @ts-expect-error8private description: String;910constructor(11public parent: HTMLDivElement,12name?: string,13description?: string14) {15this.name = "";16this.description = "";17this.element = document.createElement("button");18this.element.classList.add("menu-hack");19this.parent.append(this.element);2021if (name)22this.setName(name);23if (description)24this.setDesc(description);25}2627setName(name: string) {28this.element.innerText = name;29this.name = name;30return this;31}3233setClick(event: () => unknown) {34this.element.onclick = async () => {35await event();36saveCharacter();37console.log(`Triggered ${this.name}.`);38};39return this;40}4142setDesc(desc: string) {43this.element.title = desc;44this.description = desc;45return this;46}47}484950