AxelBjork / Rush-Royale-Bot

Python based bot for Rush Royale
MIT License
32 stars 21 forks source link

auto leave in PVP #18

Closed rand0mka closed 2 years ago

rand0mka commented 2 years ago

Idea for PVP mode - leave if opponent has cultist (variable) and battle continues more than 2 bosses.

T9es commented 2 years ago

You're going too far. The bot is only meant to farm coins for upgrades, not fully play the game for you automatically. Unnecessary strain on the dev.

rand0mka commented 2 years ago

@T9es Ok, that's your opinion, but I think that it can increase speed of farming gold cards in pvp - so much gold in coop

AxelBjork commented 2 years ago

I have thought about adding something like an auto leave based on your opponent/partner's units. Initially I wanted the bot to play support on like floor 10, and whenever you get a shaman mirror you pretty much always want to instantly leave. I haven't looked at it much because just having the bot solo floor 5 or 7 has been working well for me.

I think it would be relatively simple with a cropped icon of maybe just cultist/shaman in the opponents deck. Basically this region, 8b79b2ed9099fccefc2af4765f715fbc

Just dropping that image in the icons folder should get the bot to scan for it every 8th merge loop and could exit the game then.

https://github.com/AxelBjork/Rush-Royale-Bot/blob/a859d5e59f49f877513dde0c8de15d25e8159da3/Src/bot_handler.py#L112

This is the part which restarts the game if the bot gets stuck in combat (or another user logs in). I don't know how exactly the 50 loops translates into time but if someone wants the bot to wait longer before trying to login again it can definitely be added to the config options. If you want to auto leave after a duration it would be just adding,

if combat>VALUE:
    bot.restart_RR(quick_disconnect=True)
    combat = 0
    continue

After adding cultist to icons it should also be possible to add (output[0] == 'cultist.png').any(axis=None) and add that to the if statement.

I'll look into adding this when I have time.

AxelBjork commented 2 years ago

I added a limit version of this in this commit

https://github.com/AxelBjork/Rush-Royale-Bot/commit/5e65be193fb01f79fd77ff2d6d8c5e59bbc29f8f

Setting require_shaman to true in config.ini will make the bot autoleave any coop game where the opponent doesn't have shaman. max_loops also allows you to increase/decrease the max number of loops in combat before leaving the game.

The rest is too niche of a use imo. Feel free to make your own modifications.