Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/cheatGUI/src/hacks/inventory.ts
Views: 723
// Inventory Hacks1234// BEGIN IMPORTS5import { category } from "../index"; // Import the Cheat GUI bases.6import Hack from "../class/Hack";7import { Swal, Toast, Confirm, NumberInput } from "../utils/swal"; // Import Swal, Toast, NumberInput, and Confirm from swal8import { _, saveCharacter, VERY_LARGE_NUMBER, player } from "../utils/util"; // Import Prodigy typings9import { names, ids, itemify } from "../utils/hackify"; // Import some conversion functions and arrays10// END IMPORTS1112131415// BEGIN INVENTORY HACKS16171819// Begin Item Stacker20new Hack(category.inventory, "Item stacker").setClick(async () => {21const num = await NumberInput.fire("Amount", "How many of every item would you like?", "question");22if (!num.value) return;23if (!(await Confirm.fire("Are you sure you want to get all items in the game?")).value) return;24ids.forEach(id => {25// @ts-expect-error26player.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);27});28// @ts-expect-error29_.gameData.dorm.forEach(x =>30player.house.data.items[x.ID] = {31A: [],32N: num.value33}34);3536// Remove bounty notes... because they're very spammy37// @ts-expect-error38const bountyIndex = () => player.backpack.data.item.findIndex(v => v.ID === 84 || v.ID === 85 || v.ID === 86);39while (bountyIndex() > -1) player.backpack.data.item.splice(bountyIndex(), 1);4041return Toast.fire("Success!", "All items added!", "success");42});43// End Item Stacker444546474849// Begin Clear Inventory50new Hack(category.inventory, "Clear inventory").setClick(async () => {51if (!(await Confirm.fire("Are you sure you want to clear your inventory?")).value) return;52Object.keys(player.backpack.data).forEach(d => player.backpack.data[d] = [])53Toast.fire("Success!", "Inventory cleared.", "success");54});55// End Clear Inventory565758596061// Begin Selector (Basic)62new Hack(category.inventory, "Selector (Basic)").setClick(async () => {63// @ts-ignore64const val = await Swal.fire({65title: "What would you like to obtain?",66input: "select",67inputOptions: names,68inputPlaceholder: "Select...",69// @ts-expect-error70inputValidator: res => res ? "" : "Please select which you'd like to obtain.",71showCancelButton: true72}).then(async val => {73const num = parseInt(val.value);74const name = names[num];75const id = ids[num];76if (!name) return;77const amt = await NumberInput.fire("Amount", "How many each object would you like?", "question");78if (!amt.value) return;79if (!(await Confirm.fire(`Are you sure you want to get all ${name.toLowerCase()}?`)).value) return;80// @ts-expect-error81player.backpack.data[id] = itemify(_.gameData[id].filter(a => {82return id === 'follow' ? ![125, 126, 127, 128, 129, 134, 135, 136, 137].includes(a.ID) : a83}), amt.value);84Toast.fire(85`${name} Added!`,86`All ${name.toLowerCase()} have been added to your inventory!`,87"success"88);89saveCharacter();90});91});92// End Selector (Basic)93949596979899100// Begin Selector (Advanced)101new Hack(category.inventory, "Selector (Advanced)", "Choose a specific object and quantity to obtain.").setClick(async () => {102// @ts-expect-error103const val = await Swal.fire({104title: "What would you like to obtain?",105input: "select",106inputOptions: names,107inputPlaceholder: "Select...",108// @ts-expect-error109inputValidator: res => res ? "" : "Please select which you'd like to obtain.",110showCancelButton: true111}).then(async val => {112if (!_.gameData[ids[val.value]]) return;113const objs: [] = [];114// @ts-expect-error115_.gameData[ids[val.value]].forEach(elem => { objs.push(elem.data.name); });116// @ts-expect-error117const spec = await Swal.fire({118title: `What specific object categorized as ${names[val.value].toLowerCase()} would you like to get?`,119input: "select",120inputOptions: objs,121inputPlaceholder: "Select...",122// @ts-expect-error123inputValidator: res => res ? "" : "Please select which you'd like to get.",124showCancelButton: true125}).then(async spec => {126const correct = parseInt(spec.value);127if (!_.gameData[ids[val.value]][correct]) return;128const amt = await NumberInput.fire("Amount", "How many of the object would you like?", "question");129if (!amt.value) return;130// @ts-expect-error131if (player.backpack.data[ids[val.value]].findIndex(e => e.ID === _.gameData[ids[val.value]][correct].ID) === -1) {132player.backpack.data[ids[val.value]].push({133ID: _.gameData[ids[val.value]][correct].ID,134N: amt.value135});136137} else {138// @ts-expect-error139const num = player.backpack.data[ids[val.value]].findIndex(e => e.ID === _.gameData[ids[val.value]][correct].ID);140}141142console.log(_.gameData[ids[val.value]][correct].ID);143144saveCharacter();145return Toast.fire(`${names[val.value]} Added!`, `Your selected ${names[val.value].toLowerCase()} have been added.`, "success");146});147});148});149// End Selector (Advanced)150151152153// Begin Obtain All Furniture154new Hack(category.inventory, "Obtain All Furniture").setClick(async () => {155const amt = await NumberInput.fire("Amount", "How many of each piece of furniture would you like?", "question");156if (!amt.value) return;157if (!(await Confirm.fire("Are you sure you want to get all furniture?")).value) return;158// @ts-expect-error159_.gameData.dorm.forEach(x =>160player.house.data.items[x.ID] = {161A: [],162N: amt.value163}164);165return Toast.fire("Furniture Added!", "All furniture has been added to your inventory!", "success");166});167// End Obtain All Furniture168169170171// Begin Obtain All Mounts172new Hack(category.inventory, "Obtain All Mounts", "This gives you all of the mounts in the game.").setClick(async () => {173player.backpack.data.mount = itemify(_.gameData.mount, 1);174return Toast.fire("Mounts Added!", "All mounts have been added to your inventory!");175});176// End Obtain All Mounts177178179180181// Begin Remove Item182new Hack(category.inventory, "Remove item").setClick(async () => {183// @ts-expect-error184const category = await Swal.fire({185title: "What category would you like to remove an item from?",186input: "select",187inputOptions: names,188inputPlaceholder: "Select...",189// @ts-expect-error190inputValidator: res => res ? "" : "Please select which you'd like to obtain.",191showCancelButton: true192});193if (!_.gameData[ids[category.value]]) return;194// @ts-expect-error195const objs = _.gameData[ids[category.value]].map(elem => elem.data.name);196let item = await Swal.fire({197title: `What specific object categorized as ${names[category.value].toLowerCase()} would you like to remove?`,198input: "select",199inputOptions: objs,200inputPlaceholder: "Select...",201inputValidator: res => res ? "" : "Please select which you'd like to get.",202showCancelButton: true203});204// @ts-expect-error205item = parseInt(item.value);206if (!_.gameData[ids[category.value]][item]) return;207const amt = await NumberInput.fire("Amount", "How many of the object would you like to remove?", "question");208if (!amt.value) return;209// @ts-expect-error210if (player.backpack.data[ids[category.value]].findIndex(e => e.ID === _.gameData[ids[category.value]][item].ID) === -1) {211await Swal.fire("Item Does Not Exist", `You do not have any ${_.gameData[ids[category.value]][item].name}.`, "error");212return;213}214// @ts-expect-error215const num = player.backpack.data[ids[category.value]].findIndex(e => e.ID === _.gameData[ids[category.value]][item].ID);216player.backpack.data[ids[category.value]][num].N -= parseInt(amt.value);217if (player.backpack.data[ids[category.value]][num].N <= 0) {218player.backpack.data[ids[category.value]].splice(num, 1); // if the amount is 0 or below then the item should not exist219}220221saveCharacter();222return Toast.fire("Removed!", `Successfully removed ${amt.value} ${_.gameData[ids[category.value]][item].name}!`, "success");223});224// End Remove Item225226227228229230231232// Begin Obtain All Furniture233new Hack(category.inventory, "Obtain All Furniture").setClick(async () => {234if (!(await Confirm.fire("Are you sure you want to get all furniture?")).value) {235return console.log("Cancelled.");236} else {237// @ts-expect-error238_.gameData.dorm.forEach(x =>239player.house.data.items[x.ID] = {240A: [],241N: VERY_LARGE_NUMBER242}243);244}245return Toast.fire("Furniture Added!", "All furniture have been added to your inventory!", "success");246});247// End Obtain All Furniture248249250251252253// END INVENTORY HACKS254255256