AxelBjork / Rush-Royale-Bot

Python based bot for Rush Royale
MIT License
29 stars 19 forks source link

Problem with restarting PVE #56

Open Hilonion opened 1 year ago

Hilonion commented 1 year ago

Hello, the bot has a problem. When you start the game and the bot, everything goes fine. The bot enters the PVE menu, scrolls to the very top and searches for the specified floor. However, after the bot finishes the round, and remains on the PVE page, it does not search for the desired floor, and does not scroll to the beginning of the list of floors. It tries to launch the lowest level on the screen that has not been passed yet. After he tries to launch an inaccessible level 40 times, he restarts the game, finds himself on the PVE page again and the same problem occurs.

Lindzei commented 1 year ago

Hey, I can confirm that it is an issue due to the fact that you've unlocked another chapter than chapter 2. The problem indeed occur only when you've finished one lap of pve. I'm not a python expert but I am currently trying to make it loop only on the pve section (i.e : removind ad watching, shop and other menus)

Lindzei commented 1 year ago

Okay so short update, one cool thing that we can do is reduce the time to wait before the restart. on the bot_handler.py line 141 you can change "if wait > 40:" to "if wait > 3:"

This will reduce by A LOT the time wasted before the restart. Also having a restart every time the loop goes again is a good thing for the RAM of your computer, it will avoid crash because of stored memory and cache.

Lindzei commented 1 year ago

Alright here is the full fix that you can do :

On bot_handler.py you can comment these lines around 135 :

elif output[1] == 'home' and watch_ad:

    #    [bot.watch_ads() for i in range(3)]
    #    watch_ad = False

Then around 141 here what you can do : if wait > 3: wait = 0 bot.logger.info('TRYING TO GO HOME AND RESTART A GAME') bot.restart_RR() output = bot.battle_screen(start=True, pve=user_pve, floor=user_floor)

bot.logger.info('RESTARTING')

            #

This fix will restart the game and try to restart the bot by himself. I had to comment these lines above because bot.watch_ads didn't existed in the context. I believe it's because I restarted the game but I'm not sure about it.

I don't recommend to change the if wait under 3 because sometimes the bot can lag a little bit and it will cause to close the game without receiving the money.

Here is the result in the GUI : image