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/hacks/inventory.ts
Views: 723
1
// Inventory Hacks
2
3
4
5
// BEGIN IMPORTS
6
import { category } from "../index"; // Import the Cheat GUI bases.
7
import Hack from "../class/Hack";
8
import { Swal, Toast, Confirm, NumberInput } from "../utils/swal"; // Import Swal, Toast, NumberInput, and Confirm from swal
9
import { _, saveCharacter, VERY_LARGE_NUMBER, player } from "../utils/util"; // Import Prodigy typings
10
import { names, ids, itemify } from "../utils/hackify"; // Import some conversion functions and arrays
11
// END IMPORTS
12
13
14
15
16
// BEGIN INVENTORY HACKS
17
18
19
20
// Begin Item Stacker
21
new Hack(category.inventory, "Item stacker").setClick(async () => {
22
const num = await NumberInput.fire("Amount", "How many of every item would you like?", "question");
23
if (!num.value) return;
24
if (!(await Confirm.fire("Are you sure you want to get all items in the game?")).value) return;
25
ids.forEach(id => {
26
// @ts-expect-error
27
player.backpack.data[id] = itemify(_.gameData[id].filter(l => id === "follow" ? ![125, 126, 127, 128, 129, 134, 135, 136, 137].includes(l.ID) : l), num.value);
28
});
29
// @ts-expect-error
30
_.gameData.dorm.forEach(x =>
31
player.house.data.items[x.ID] = {
32
A: [],
33
N: num.value
34
}
35
);
36
37
// Remove bounty notes... because they're very spammy
38
// @ts-expect-error
39
const bountyIndex = () => player.backpack.data.item.findIndex(v => v.ID === 84 || v.ID === 85 || v.ID === 86);
40
while (bountyIndex() > -1) player.backpack.data.item.splice(bountyIndex(), 1);
41
42
return Toast.fire("Success!", "All items added!", "success");
43
});
44
// End Item Stacker
45
46
47
48
49
50
// Begin Clear Inventory
51
new Hack(category.inventory, "Clear inventory").setClick(async () => {
52
if (!(await Confirm.fire("Are you sure you want to clear your inventory?")).value) return;
53
Object.keys(player.backpack.data).forEach(d => player.backpack.data[d] = [])
54
Toast.fire("Success!", "Inventory cleared.", "success");
55
});
56
// End Clear Inventory
57
58
59
60
61
62
// Begin Selector (Basic)
63
new Hack(category.inventory, "Selector (Basic)").setClick(async () => {
64
// @ts-ignore
65
const val = await Swal.fire({
66
title: "What would you like to obtain?",
67
input: "select",
68
inputOptions: names,
69
inputPlaceholder: "Select...",
70
// @ts-expect-error
71
inputValidator: res => res ? "" : "Please select which you'd like to obtain.",
72
showCancelButton: true
73
}).then(async val => {
74
const num = parseInt(val.value);
75
const name = names[num];
76
const id = ids[num];
77
if (!name) return;
78
const amt = await NumberInput.fire("Amount", "How many each object would you like?", "question");
79
if (!amt.value) return;
80
if (!(await Confirm.fire(`Are you sure you want to get all ${name.toLowerCase()}?`)).value) return;
81
// @ts-expect-error
82
player.backpack.data[id] = itemify(_.gameData[id].filter(a => {
83
return id === 'follow' ? ![125, 126, 127, 128, 129, 134, 135, 136, 137].includes(a.ID) : a
84
}), amt.value);
85
Toast.fire(
86
`${name} Added!`,
87
`All ${name.toLowerCase()} have been added to your inventory!`,
88
"success"
89
);
90
saveCharacter();
91
});
92
});
93
// End Selector (Basic)
94
95
96
97
98
99
100
101
// Begin Selector (Advanced)
102
new Hack(category.inventory, "Selector (Advanced)", "Choose a specific object and quantity to obtain.").setClick(async () => {
103
// @ts-expect-error
104
const val = await Swal.fire({
105
title: "What would you like to obtain?",
106
input: "select",
107
inputOptions: names,
108
inputPlaceholder: "Select...",
109
// @ts-expect-error
110
inputValidator: res => res ? "" : "Please select which you'd like to obtain.",
111
showCancelButton: true
112
}).then(async val => {
113
if (!_.gameData[ids[val.value]]) return;
114
const objs: [] = [];
115
// @ts-expect-error
116
_.gameData[ids[val.value]].forEach(elem => { objs.push(elem.data.name); });
117
// @ts-expect-error
118
const spec = await Swal.fire({
119
title: `What specific object categorized as ${names[val.value].toLowerCase()} would you like to get?`,
120
input: "select",
121
inputOptions: objs,
122
inputPlaceholder: "Select...",
123
// @ts-expect-error
124
inputValidator: res => res ? "" : "Please select which you'd like to get.",
125
showCancelButton: true
126
}).then(async spec => {
127
const correct = parseInt(spec.value);
128
if (!_.gameData[ids[val.value]][correct]) return;
129
const amt = await NumberInput.fire("Amount", "How many of the object would you like?", "question");
130
if (!amt.value) return;
131
// @ts-expect-error
132
if (player.backpack.data[ids[val.value]].findIndex(e => e.ID === _.gameData[ids[val.value]][correct].ID) === -1) {
133
player.backpack.data[ids[val.value]].push({
134
ID: _.gameData[ids[val.value]][correct].ID,
135
N: amt.value
136
});
137
138
} else {
139
// @ts-expect-error
140
const num = player.backpack.data[ids[val.value]].findIndex(e => e.ID === _.gameData[ids[val.value]][correct].ID);
141
}
142
143
console.log(_.gameData[ids[val.value]][correct].ID);
144
145
saveCharacter();
146
return Toast.fire(`${names[val.value]} Added!`, `Your selected ${names[val.value].toLowerCase()} have been added.`, "success");
147
});
148
});
149
});
150
// End Selector (Advanced)
151
152
153
154
// Begin Obtain All Furniture
155
new Hack(category.inventory, "Obtain All Furniture").setClick(async () => {
156
const amt = await NumberInput.fire("Amount", "How many of each piece of furniture would you like?", "question");
157
if (!amt.value) return;
158
if (!(await Confirm.fire("Are you sure you want to get all furniture?")).value) return;
159
// @ts-expect-error
160
_.gameData.dorm.forEach(x =>
161
player.house.data.items[x.ID] = {
162
A: [],
163
N: amt.value
164
}
165
);
166
return Toast.fire("Furniture Added!", "All furniture has been added to your inventory!", "success");
167
});
168
// End Obtain All Furniture
169
170
171
172
// Begin Obtain All Mounts
173
new Hack(category.inventory, "Obtain All Mounts", "This gives you all of the mounts in the game.").setClick(async () => {
174
player.backpack.data.mount = itemify(_.gameData.mount, 1);
175
return Toast.fire("Mounts Added!", "All mounts have been added to your inventory!");
176
});
177
// End Obtain All Mounts
178
179
180
181
182
// Begin Remove Item
183
new Hack(category.inventory, "Remove item").setClick(async () => {
184
// @ts-expect-error
185
const category = await Swal.fire({
186
title: "What category would you like to remove an item from?",
187
input: "select",
188
inputOptions: names,
189
inputPlaceholder: "Select...",
190
// @ts-expect-error
191
inputValidator: res => res ? "" : "Please select which you'd like to obtain.",
192
showCancelButton: true
193
});
194
if (!_.gameData[ids[category.value]]) return;
195
// @ts-expect-error
196
const objs = _.gameData[ids[category.value]].map(elem => elem.data.name);
197
let item = await Swal.fire({
198
title: `What specific object categorized as ${names[category.value].toLowerCase()} would you like to remove?`,
199
input: "select",
200
inputOptions: objs,
201
inputPlaceholder: "Select...",
202
inputValidator: res => res ? "" : "Please select which you'd like to get.",
203
showCancelButton: true
204
});
205
// @ts-expect-error
206
item = parseInt(item.value);
207
if (!_.gameData[ids[category.value]][item]) return;
208
const amt = await NumberInput.fire("Amount", "How many of the object would you like to remove?", "question");
209
if (!amt.value) return;
210
// @ts-expect-error
211
if (player.backpack.data[ids[category.value]].findIndex(e => e.ID === _.gameData[ids[category.value]][item].ID) === -1) {
212
await Swal.fire("Item Does Not Exist", `You do not have any ${_.gameData[ids[category.value]][item].name}.`, "error");
213
return;
214
}
215
// @ts-expect-error
216
const num = player.backpack.data[ids[category.value]].findIndex(e => e.ID === _.gameData[ids[category.value]][item].ID);
217
player.backpack.data[ids[category.value]][num].N -= parseInt(amt.value);
218
if (player.backpack.data[ids[category.value]][num].N <= 0) {
219
player.backpack.data[ids[category.value]].splice(num, 1); // if the amount is 0 or below then the item should not exist
220
}
221
222
saveCharacter();
223
return Toast.fire("Removed!", `Successfully removed ${amt.value} ${_.gameData[ids[category.value]][item].name}!`, "success");
224
});
225
// End Remove Item
226
227
228
229
230
231
232
233
// Begin Obtain All Furniture
234
new Hack(category.inventory, "Obtain All Furniture").setClick(async () => {
235
if (!(await Confirm.fire("Are you sure you want to get all furniture?")).value) {
236
return console.log("Cancelled.");
237
} else {
238
// @ts-expect-error
239
_.gameData.dorm.forEach(x =>
240
player.house.data.items[x.ID] = {
241
A: [],
242
N: VERY_LARGE_NUMBER
243
}
244
);
245
}
246
return Toast.fire("Furniture Added!", "All furniture have been added to your inventory!", "success");
247
});
248
// End Obtain All Furniture
249
250
251
252
253
254
// END INVENTORY HACKS
255
256