CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
ProdigyPNP

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: ProdigyPNP/ProdigyMathGameHacking
Path: blob/master/cheatGUI/src/class/Hack.ts
Views: 723
1
import { saveCharacter } from "../utils/util";
2
3
4
5
export default class Hack {
6
public element: HTMLButtonElement;
7
public name: string;
8
// @ts-expect-error
9
private description: String;
10
11
constructor(
12
public parent: HTMLDivElement,
13
name?: string,
14
description?: string
15
) {
16
this.name = "";
17
this.description = "";
18
this.element = document.createElement("button");
19
this.element.classList.add("menu-hack");
20
this.parent.append(this.element);
21
22
if (name)
23
this.setName(name);
24
if (description)
25
this.setDesc(description);
26
}
27
28
setName(name: string) {
29
this.element.innerText = name;
30
this.name = name;
31
return this;
32
}
33
34
setClick(event: () => unknown) {
35
this.element.onclick = async () => {
36
await event();
37
saveCharacter();
38
console.log(`Triggered ${this.name}.`);
39
};
40
return this;
41
}
42
43
setDesc(desc: string) {
44
this.element.title = desc;
45
this.description = desc;
46
return this;
47
}
48
}
49
50