// Pet Hacks // BEGIN IMPORTS import { Swal, Toast, NumberInput, Confirm } from "../utils/swal"; // Import Swal, Toast, Confirm, Input, and NumberInput from swal import { category } from "../index"; // Import the Cheat GUI bases. import Hack from "../class/Hack"; import { _, VERY_LARGE_NUMBER, player } from "../utils/util"; // Import Prodigy typings and VERY_LARGE_NUMBER import { getPet } from "../utils/hackify"; // Import getPet // END IMPORTS // BEGIN PET HACKS // Begin Get All Pets new Hack(category.pets, "Get All Pets").setClick(async () => { if (!(await Confirm.fire("Would you like to add all pets to your pets?")).value) { return console.log("Cancelled"); } // add pets // @ts-expect-error _.gameData.pet.forEach(x => { player.kennel.addPet(x.ID.toString(), VERY_LARGE_NUMBER, 26376, 100); }); // add encounter info player.kennel._encounterInfo._data.pets = []; _.gameData.pet.map((pet: { ID: number }) => { player.kennel._encounterInfo._data.pets.push({ firstSeenDate: Date.now(), ID: pet.ID, timesBattled: 1, timesRescued: 1 }); }); // Fix broken pets // @ts-expect-error player.kennel.petTeam.forEach(v => { if (v && (v as any).assignRandomSpells)(v as any).assignRandomSpells(); }); return Toast.fire("Success!", "All pets have been added!", "success"); }); // End Get All Pets // Begin Get ALl Legacy Epics new Hack(category.pets, "Get All Legacy Epics").setClick(async () => { if (!(await Confirm.fire("This may damage your account.", "Attempting to add legacy epics may damage your account. Would you still like to add all legacy epics to your team?", "warning")).value) { return console.log("Cancelled"); } // @ts-expect-error const epics = _.gameData.pet.filter(x => [125, 126, 127, 128, 129, 130, 131, 132, 133].includes(x.ID)); // @ts-expect-error epics.forEach(x => { player.kennel.addPet(x.ID.toString(), VERY_LARGE_NUMBER, 26376, 100); }); // Fix broken pets // @ts-expect-error player.kennel.petTeam.forEach(v => { if (v && (v as any).assignRandomSpells)(v as any).assignRandomSpells(); }); return Toast.fire("Success!", "All legacy epics have been added!", "success"); }); // End Get ALl Legacy Epics // Begin Get All Mythical Epics new Hack(category.pets, "Get All Mythical Epics").setClick(async () => { if (!(await Confirm.fire("Would you like to add all mythical epics to your pets?")).value) { return console.log("Cancelled"); } // @ts-expect-error const epics = _.gameData.pet.filter(x => [ 158, // Magmayhem 164, // Blast Star 165, // Vegabloom 166, // Arcturion 167, // Aquadile 168, // Shiver & Scorch 169, // Riptide 170, // Lumanight 171, // Nebula 189, // B.F. Magmayhem ].includes(x.ID)); // @ts-expect-error epics.forEach(x => { player.kennel.addPet(x.ID.toString(), VERY_LARGE_NUMBER, 26376, 100); }); // Fix broken pets player.kennel.petTeam.forEach((v: any) => { if (v && (v as any).assignRandomSpells) (v as any).assignRandomSpells(); }); return Toast.fire("Success!", "All mythical epics have been added!", "success"); }); // btw this hack was made by gemsvidø (afkvido on github) // End Get ALl Mythical Epics // Begin Clear Pets new Hack(category.pets, "Clear Pets").setClick(async () => { if (!(await Confirm.fire("Would you like to delete all of your pets?")).value) { return console.log("Cancelled"); } player.kennel.data.length = 0; return Toast.fire("Success!", "Your pets have been cleared!", "success"); }); // End Clear Pets // Begin Add Pet new Hack(category.pets, "Add Pet", "Adds a pet from a list.").setClick(async () => { // @ts-expect-error const pet = await Swal.fire({ input: "select", // @ts-expect-error inputOptions: new Map(_.gameData.pet.map(x => [x.ID.toString(), `${x.ID}: ${x.data.name}`])), title: "Choose Pet", text: "Which pet do you want to obtain?" }); if (pet.value === undefined) return; player.kennel.addPet(pet.value); // add encounter data player.kennel._encounterInfo._data.pets.push({ firstSeenDate: Date.now(), ID: pet.value, timesBattled: 1, timesRescued: 1 }); return Toast.fire("Success!", "Your chosen pet has been added to your pets!", "success"); }); // End Add Pet // Begin Uncap pet level new Hack(category.pets, "Uncap pet level [Client Side]", "Change your pet's level to anything, even over 100. This hack won't save when you reload Prodigy.").setClick(async () => { const petTeam = player.kennel.petTeam.slice(0); petTeam.shift(); // @ts-expect-error const names = petTeam.map(pet => pet.getName()); const pet = await Swal.fire({ title: "Which pet would you like to edit?", input: "select", inputOptions: names, inputPlaceholder: "Select...", inputValidator: res => res ? "" : "Please select which you'd like to obtain.", showCancelButton: true }); const amt = await NumberInput.fire("Level", "What would you like to set your pet's level to? (Can be set over 100)", "question"); if (!amt.value) return; const num = amt.value; // sorry in advance eval(`player.kennel.petTeam[parseInt(${pet.value})+1].getLevel = () => {return ${num}}`); return Toast.fire("Updated!", "The level of your pet was successfully updated. Note: this hack is client-side.", "success"); }); // End Uncap pet level // Begin Delete Pet new Hack(category.pets, "Delete Pet", "Delete a pet.").setClick(async () => { const pet = await getPet("Which pet do you wish to delete?"); if (pet === undefined) return; player.kennel.data.splice(pet, 1); return Toast.fire("Successfully deleted!", "The selected pet was deleted successfully.", "success"); }); // End Delete Pet // END PET HACKS
Write, Run & Share Typescript code online using OneCompiler's Typescript online compiler for free. It's one of the robust, feature-rich online compilers for Typescript language. Getting started with the OneCompiler's Typescript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Typescript and start coding.
Typescript(JS) is a strongly typed programming language that builds on JavaScript, developed and maintained by Microsoft.
Keyword | Description | Scope |
---|---|---|
var | Var is used to declare variables(old way of declaring variables) | Function or global scope |
let | let is also used to declare variables(new way) | Global or block Scope |
const | const is used to declare const values. Once the value is assigned it can not be modified | Global or block Scope |
Operator | Description |
---|---|
?? | nullish coalescing |
?. | optional chaining |
! | null assertion |
&&= | used to assign value only if current value is truthy |
||= | used to assign value only if current value is falsy |
??= | used to assign value if current value is null or undefined |
IF is used to execute a block of code based on a condition.
if(condition){
// code
}
Else part is used to execute the block of code when the condition fails.
if(condition){
// code
} else {
// code
}
Switch is used to replace nested If-Else statements.
switch(condition){
case 'value1' :
//code
break;
case 'value2' :
//code
break;
.......
default :
//code
break;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
let arr = [1, 2, 3, 4, 5];
for (let ele of arr) {
// code
}
for (let index in arr) {
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.
() => expression
const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
.map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);
Typescript provides function overloading where multiple functions with the same name but different parameter types and return type is possible. But, the number of parameters should be the same.
function Addition(a:string, b:string):string;
function Addition(a:number, b:number): number;
function Addition(a: any, b:any): any {
return a + b;
}
Addition("Hello ","foo"); // outputs Hello foo
Addition(2,3); //outpus 5