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/utils/hackify.ts
Views: 723
1
import { TODO } from "../../../typings/util"; // Import Prodigy Util typings
2
import { _ } from "../utils/util"; // Import Prodigy typings and VERY_LARGE_NUMBER
3
import { Swal, Toast } from "../utils/swal"; // Import Swal, Toast, Confirm, Input, and NumberInput from swal
4
5
6
7
8
// Exports
9
10
11
// Item Categories
12
export const names : string[] = ["Boots", "Buddies", "Fossils", "Hats", "Items", "Key Items", "Tower Town Frames", "Tower Town Interiors", "Mounts", "Outfits", "Relics", "Weapons", "Currencies"];
13
14
15
// Item Category IDs
16
export const ids : string[] = ["boots", "follow", "fossil", "hat", "item", "key", "mathTownFrame", "mathTownInterior", "mount", "outfit", "spellRelic", "weapon", "currency"];
17
18
19
// Convert item to Item ID map
20
// @ts-expect-error
21
export const itemify = (item: Item[], amount: number) =>
22
item.map(x => ({
23
ID: x.ID,
24
N: amount
25
})).filter(v => v !== undefined);
26
27
28
// Convert rune to Rune ID map
29
// @ts-expect-error
30
export const runeify = (item, amount) =>
31
// @ts-expect-error
32
item.map(x => ({
33
ID: x.ID,
34
quantity: amount
35
// @ts-expect-error
36
})).filter(v => v !== undefined);
37
38
39
// Get member module
40
export function getMemberModule () {
41
return _.player.hasMembership.toString().split("\"")[1];
42
}
43
44
45
46
47
48
// Begin toHouse function
49
export function toHouse (userID: number) {
50
if (_.player.userID !== userID) {
51
const friendCount = _.instance.prodigy.friendsListNetworkHandler.friendsList.length;
52
const classMates = _.instance.prodigy.friendsListNetworkHandler.classList.length;
53
54
_.instance.prodigy.gameContainer.get("2e1-e659")
55
.create("house-visit", "click", "hub", friendCount, classMates, null, null, userID)
56
.broadcast();
57
}
58
const zone = _.instance.prodigy.world.getZone(_.instance.prodigy.world.getCurrentZone());
59
if (!zone) return Swal.fire({ title: "Error", text: "You are not in a zone!", icon: "error" });
60
return zone.handleLeaving(2, () => teleportToHouse(userID));
61
}
62
// End toHouse function
63
64
65
66
67
68
// Begin teleportToHouse function
69
export function teleportToHouse (userID: number) {
70
_.instance.prodigy.loading(true);
71
72
const responseCallback = (data: any) => {
73
const playerData = data !== null && data !== undefined ? data[userID] : null;
74
75
if (playerData !== null && playerData.house !== undefined && playerData.house !== null) {
76
_.instance.prodigy.loading(false);
77
const house = _.cloneDeep(_.player.house);
78
house.setItems(playerData.house);
79
if (!(playerData.data.allowsHouseVisitors !== undefined && playerData.data.allowsHouseVisitors !== null ? playerData.data.allowsHouseVisitors : false)) {
80
return Swal.fire(`Teleporting to ${userID} is not allowed.`, "Try another user.", "error");
81
}
82
return _.instance.prodigy.world._("house", null, null, { house, getAllowsHouseVisitors: () => playerData.data.allowsHouseVisitors !== undefined && playerData.data.allowsHouseVisitors !== null ? playerData.data.allowsHouseVisitors : false, setAllowsHouseVisitors: (v: boolean) => { playerData.data.allowsHouseVisitors = v; } });
83
}
84
};
85
86
_.network.getCharData(userID.toString(), ["house", "data"], responseCallback, responseCallback);
87
return Toast.fire("Teleported to house", "You have been teleported to the house!", "success");
88
}
89
// End teleportToHouse function
90
91
92
93
94
// Get pet from GUI popup
95
export const getPet = async (text: string): Promise<number | undefined> => {
96
const pet = await Swal.fire({
97
input: "select",
98
inputOptions: new Map(
99
_.player.kennel.data.map((x: TODO, i: number) => [
100
i.toString(),
101
// @ts-expect-error
102
`Level ${x.level} - ${x.nickname ?? _.gameData.pet.find(y => +y.ID === +x.ID)?.data.name ?? "Unknown"}`
103
]) as [string, string][]
104
),
105
title: "Choose Pet",
106
text: text
107
});
108
return pet.value;
109
};
110