Ephenia / Pokeclicker-Scripts

Various scripts & enhancements for the game Pokéclicker.
https://github.com/Ephenia/Pokeclicker-Scripts
GNU General Public License v3.0
195 stars 261 forks source link

Debug Cheat Tools on desktop app #403

Open GammaRex opened 4 months ago

GammaRex commented 4 months ago

in the desktop app, when using the scripts app.asar file, the debug cheat tool crashes when its on and you cant use the pokedex or held items inside the cheat tools.

image_2024-07-12_193939003

ajthompson commented 2 months ago

This is reproducible in browser as well.

The held items crash seems to be because the return value of HeldItem().getSortedHeldItems() was changed to be a structure splitting the items into several dictionaries.

The snipped loading the held items at line 437 can be replaced with this to make the held items functionality work.

    // heldItems
    HeldItem.getSortedHeldItems().attack.items.forEach((itm, idx) => {
        const itmPretty = itm.name.replaceAll('_', ' ');
        modalBody.querySelector('#heldItems').innerHTML += `
            <div class="btn btn-primary col-2 item-bag-item" onclick="HeldItem.getSortedHeldItems().attack.items[${idx}].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0))">
                <img title="${itmPretty}" src="assets/images/items/heldItems/${itm.name}.png" height="25px">
                <div>${itmPretty}</div>
            </div>
        `;
    });
    HeldItem.getSortedHeldItems().typeRestricted.items.forEach((itm, idx) => {
        const itmPretty = itm.name.replaceAll('_', ' ');
        modalBody.querySelector('#heldItems').innerHTML += `
            <div class="btn btn-primary col-2 item-bag-item" onclick="HeldItem.getSortedHeldItems().typeRestricted.items[${idx}].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0))">
                <img title="${itmPretty}" src="assets/images/items/heldItems/${itm.name}.png" height="25px">
                <div>${itmPretty}</div>
            </div>
        `;
    });
    HeldItem.getSortedHeldItems().ev.items.forEach((itm, idx) => {
        const itmPretty = itm.name.replaceAll('_', ' ');
        modalBody.querySelector('#heldItems').innerHTML += `
            <div class="btn btn-primary col-2 item-bag-item" onclick="HeldItem.getSortedHeldItems().ev.items[${idx}].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0))">
                <img title="${itmPretty}" src="assets/images/items/heldItems/${itm.name}.png" height="25px">
                <div>${itmPretty}</div>
            </div>
        `;
    });
    HeldItem.getSortedHeldItems().exp.items.forEach((itm, idx) => {
        const itmPretty = itm.name.replaceAll('_', ' ');
        modalBody.querySelector('#heldItems').innerHTML += `
            <div class="btn btn-primary col-2 item-bag-item" onclick="HeldItem.getSortedHeldItems().exp.items[${idx}].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0))">
                <img title="${itmPretty}" src="assets/images/items/heldItems/${itm.name}.png" height="25px">
                <div>${itmPretty}</div>
            </div>
        `;
    });
    HeldItem.getSortedHeldItems().other.items.forEach((itm, idx) => {
        const itmPretty = itm.name.replaceAll('_', ' ');
        modalBody.querySelector('#heldItems').innerHTML += `
            <div class="btn btn-primary col-2 item-bag-item" onclick="HeldItem.getSortedHeldItems().other.items[${idx}].gain(parseInt(document.getElementById('inputAddHeldItems').value || 0))">
                <img title="${itmPretty}" src="assets/images/items/heldItems/${itm.name}.png" height="25px">
                <div>${itmPretty}</div>
            </div>
        `;
    });

There's also some issues with the onclick() functions showing up as undefined for loading or filtering quests or pokemon in those tabs, but that gets into front-end web dev stuff and I'm clueless about how that works.

GammaRex commented 2 months ago

Do you know if the issue with the pokedex setting can be fixed? Thank you for the help on this :)

Xantriix commented 1 week ago

i have changes the Script and it dosnt help.. any other options to fix this Script?