Giter Club home page Giter Club logo

py-clash-bot's Introduction

py-clash-bot

Build windows package GitHub Python Tests CodeFactor Discord

py-clash-bot is an open-source application that allows users to automate their Clash Royale gameplay on Windows using an emulated Android phone. The bot uses a combination of image recognition, mouse control, and Android emulation to perform a variety of tasks without user intervention.

Join the Discord server!

Features

  • Automated level-up, clan wars, card requesting, card mastery, card upgrade, chest opening, and MORE!
  • Runs in the background without using mouse or keyboard input.
  • This link has a complete list of each task with descriptions.

Installation

  1. Download and install the latest version of MEmu to emulate Android.
  2. Download and run the latest Windows installer for py-clash-bot here.

Usage

  1. Run the py-clash-bot shortcut on the desktop.
  2. Click the start button to create a new emulator. Wait for the emulator to load.
  3. py-clash-bot will detect that Clash Royale is not installed. You must manually install Clash Royale on the new emulator.
  4. Start Clash Royale and complete the tutorial (takes 30 seconds). Then sign into your account using the SuperCell ID login (or use the fresh account).
  5. Set the game language to English.
  6. Restart the bot, select the desired jobs to perform, then click the Start button.
  7. Enjoy the benefits of always-on farming with the py-clash-bot taking care of the heavy lifting for you.

Demo

Game DemoGUI Demo

Contribute

We welcome contributions to the py-clash-bot project. If you have an idea for a new feature or have found a bug, please open an issue on the issues tab or check out how to contribute directly.

py-clash-bot's People

Contributors

dependabot[bot] avatar hasanalt avatar martinmiglio avatar matthewmiglio avatar packetsss avatar stredy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py-clash-bot's Issues

Image recognition broken

Image recognition broken in implementation in request state.

Image recognition methods are successfully implemented in src/pyclashbot/bot/card_detection.py but fail elsewhere.

broken code:

def find_request_button(vm_index):
    folder_str = "request_button"

    img = screenshot(vm_index)

    size = get_file_count(folder_str)

    names = make_reference_image_list(size)

    locations: list[list[int] | None] = find_references(
        image=img, folder=folder_str, names=names, tolerance=0.97
    )

    print(locations)

Associated images:
1

Fix bare exception

fix bare exceptions at pyclashbot\client.py:79 and pyclashbot\client.py:84

Save job list

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

MEmu failing to reopen after restart

Describe the bug
When a falure occurs the bot closes MEmu to restart it, but it gets stuck "closing all things MEmu related"

To Reproduce
Steps to reproduce the behavior:

  1. Start up Bot
  2. Run bot for about an hour
  3. Mouse gets stuck or another issue happens that requires a reset
  4. Py-clashbot stays stuck on "closing all things MEmu related"

Expected behavior
I expect the bot to reopen the virtual MEmu client so that it can continue playing the game, but it just gets stuck.

Desktop (please complete the following information):

  • OS: Windows 11
  • Display resolution: 1366 x 768
  • Version: 10.0.22000 Build 22000

Additional context
After the recent update the bot crashes whenever it's about to enable a 2v2 match, could that be because of new graphics?

Resolution and scaling support

The program currently has issues on:

Resolution Scaling
4k 150%

Tested working settings:

Resolution Scaling
2k 100%
1080p 100%
1080p Vertical 100%

Add replies to this issue with additions to these lists, I will edit them in.

Clashbot will not function when i log in with my supercell ID

Describe the bug
Clashbot goes into a loop, clicking the corner of the clash royale app while trying to identify if its in the main menu of clash royale. (only starts happening after i connect to my supercell ID)

To Reproduce
Steps to reproduce the behavior:

  1. Open up clashbot as per the usual instruction
  2. It will trigger an instance for memu and open up clash royale.
  3. Clashbot will get stuck in a loop trying to identify when clash royale's main menu has loaded.
  4. It will consistently click on the corner of the app where there are no buttons.
  5. After multiple tries, clashbot will attempt to reboot another instance of Memu and the same actions from 2. - 4. repeats endlessly.

Expected behavior
A clear and concise description of what you expected to happen.
Clashbot would have identified that it is already in the main menu of clash royale and start operating as per the jobs ticked. (It works if i do not log in my supercell ID, meaning just the base game as a new account)

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version py-clash-bot-v1.1.0-win64.msi

Additional context
Sorry, i am extremely new to this community, and I am trying to give as much details as I can. Please pardon me if I'm missing out any key details you might need to identify any errors.

Trophy road or Path of Legends feature

Since only Trophy Road and Path of Legends are the only game modes that give chests to unlock, I think it would be great to provide an option for the bot to play that game mode. Also, if the bot can be taught to play on meta decks like royal giant, etc... That'd be great to up the chances of winning and receiving a chest to unlock.

Describe the solution you'd like
Provide an option for the bot to play Trophy Road or Path of Legends.

Describe alternatives you've considered
Adding instructions for the bot to play other on meta decks like royal giant or lavahound, etc...

Additional context
That's all folks.

Canty make Bot to work Help Needed !!

When I tried both Windows and with PIP. the bot install and I followed the instruction to configure MEMU emulator, but I get the below message, Screenshot|:

image

I tick the fight, 1 account , and Giant card, when I hit start, I get error as shown in the screenshot above. Let me know if am missing any steps.

Auto update fails with no network connection

Handle following exception when there is not network connection on autoupdate:

Checking for new version to install...
Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connection.py", line 174, in _new_conn
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\util\connection.py", line 72, in create_connection
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\socket.py", line 955, in getaddrinfo
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connectionpool.py", line 703, in urlopen
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connectionpool.py", line 386, in _make_request
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connectionpool.py", line 1040, in _validate_conn
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connection.py", line 358, in connect
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connection.py", line 186, in _new_conn
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x0000027C3B7F9810>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\requests\adapters.py", line 489, in send
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\urllib3\util\retry.py", line 592, in increment
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/matthewmiglio/py-clash-bot/releases/latest (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000027C3B7F9810>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 120, in run
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\Lib\site-packages\cx_Freeze\initscripts\Console.py", line 16, in run
  File "pyclashbot\__main__.py", line 351, in <module>
  File "pyclashbot\__main__.py", line 318, in main_loop
  File "D:\a\py-clash-bot\py-clash-bot\pyclashbot\auto_update.py", line 164, in auto_update
  File "D:\a\py-clash-bot\py-clash-bot\pyclashbot\auto_update.py", line 139, in install_latest_release
  File "D:\a\py-clash-bot\py-clash-bot\pyclashbot\auto_update.py", line 70, in get_asset_info
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\requests\api.py", line 73, in get
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\requests\api.py", line 59, in request
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\requests\sessions.py", line 587, in request
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\requests\sessions.py", line 701, in send
  File "C:\hostedtoolcache\windows\Python\3.10.5\x64\lib\site-packages\requests\adapters.py", line 565, in send
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/matthewmiglio/py-clash-bot/releases/latest (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000027C3B7F9810>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

Fix 'Unexpected duplicate selector &quot;html body[for=&quot;html-export&quot;]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul&quot;, first used at line 749 (no-duplicate-selectors)' issue in docs\src\index.css

CodeFactor found an issue: Unexpected duplicate selector "html body[for="html-export"]:not([data-presentation-mode])[html-show-sidebar-toc] .md-sidebar-toc ul", first used at line 749 (no-duplicate-selectors)

It's currently on:
docs\src\index.css:758
Commit 52360be

Bot keep stopping

Expected behavior
The bot keeps stopping.

Desktop (please complete the following information):

  • OS: Windows 10
  • Display resolution: 720x1280
  • Version 9.0

Fix thread termination

Thread does not stop when expected
Expected behavior
WorkerThread should stop on button press.

Desktop (please complete the following information):

  • OS: Windows 10
  • Display resolution: 4k
  • Version 2.0.0-12

ERROR: 'AHK' object has no attribute 'minimize_window'

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Fix documentation site routing

Directly linking to a routed component on the documentation site is met with a 404 error from Github

Links to routed components, like the contributing page, lead to a 404, whereas navigating to them through links on the page functions properly.

This problem lies in the single-page routing of react-router-dom.

Possible fix for issue described here.

Implement 1v1 mode

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Card Mastery Collection is broken, failure getting to battle deck page

Describe the bug
Card Mastery Collection is broken, failure getting to battle deck page

INFO:2023-06-22 17:35:48,584 Start Button Event
INFO:2023-06-22 17:35:48,585 Running first startup sequence.
INFO:2023-06-22 17:35:48,585 Running first startup sequence.
INFO:2023-06-22 17:35:48,597 Restarting
INFO:2023-06-22 17:35:48,598 Closing everything Memu related. . .
INFO:2023-06-22 17:35:53,235 Configuring VM
INFO:2023-06-22 17:36:09,212 Starting emulator...
INFO:2023-06-22 17:36:48,242 Clash Royale started
INFO:2023-06-22 17:36:58,252 Waiting for clash main menu in Launcher
INFO:2023-06-22 17:37:26,081 Done waiting for clash main menu
INFO:2023-06-22 17:37:31,082 Switching accounts. . .
INFO:2023-06-22 17:37:31,082 Checking if there are card mastery rewards to collect
INFO:2023-06-22 17:37:31,082 Getting to card collection tab...
INFO:2023-06-22 17:37:32,626 Getting to battle deck page...
INFO:2023-06-22 17:38:11,354 Stopping
INFO:2023-06-22 17:38:42,243 failure with get_to_battle_deck_page()
INFO:2023-06-22 17:38:42,243 Failed to get to card page while collecting card mastery rewards
INFO:2023-06-22 17:38:42,243 Failed when checking if has card mastery rewards

To Reproduce
Steps to reproduce the behavior:

  1. Select Card Mastery Collection job
  2. Start bot
  3. Failure

Account switching is not working

Describe the bug
Account switching is not working

To Reproduce

  1. Start the bot with more than one supercell id logged in
  2. When the bot opens up the accounts screen (while doing f"Switching accounts to account number {str(account_number)}"), it crashes with:
    Error: [Errno 2] No such file or directory: 'C:\\Users\\matmi\\OneDrive\\Desktop\\ssid_account_index_log.txt'

Desktop (please complete the following information):

  • OS: Windows 10
  • Display resolution: 1366x768 and tried with 1400x900 same results
  • 1.1.2

cant start

C:\Users\Tim\Desktop\bot>pyclashbot
Traceback (most recent call last):
File "c:\users\tim\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "c:\users\tim\appdata\local\programs\python\python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\Tim\AppData\Local\Programs\Python\Python38\Scripts\pyclashbot.exe_main
.py", line 4, in
File "c:\users\tim\appdata\local\programs\python\python38\lib\site-packages\pyclashbot_main
.py", line 9, in
from pyclashbot.battlepass import check_if_can_collect_bp, collect_bp
File "c:\users\tim\appdata\local\programs\python\python38\lib\site-packages\pyclashbot\battlepass.py", line 4, in
from pyclashbot.client import check_quit_key_press, click, screenshot, scroll_down, scroll_down_fast, scroll_up_fast
File "c:\users\tim\appdata\local\programs\python\python38\lib\site-packages\pyclashbot\client.py", line 9, in
from pyclashbot.image_rec import check_for_location, find_references, get_first_location
File "c:\users\tim\appdata\local\programs\python\python38\lib\site-packages\pyclashbot\image_rec.py", line 12, in
def get_first_location(locations: list[Union[list[int], None]], flip=False):
TypeError: 'type' object is not subscriptable

make fight loop

just make loop for fights. it takes alot of time to check clan / upgrade cards etc.

Not working

Hello, I have followed all the steps you mention in the guide, still not working

Could you please do a video-tutorial about how to install & make it working?

After following steps appears a CMD window that automatically closes

Thank you

"Waiting for clash main menu"

After it started clash royale, nothing happens. in the logs it says:"
[start] Successfully initialized Clash app
INFO:2023-09-13 22:20:53,243 Successfully initialized Clash app
INFO:2023-09-13 22:20:57,244 [start] Manually waiting for clash main page. 4.0/10
INFO:2023-09-13 22:21:01,245 [start] Manually waiting for clash main page. 8.0/10
INFO:2023-09-13 22:21:05,246 [start] Manually waiting for clash main page. 12./10
INFO:2023-09-13 22:21:05,246 [start] Waiting for clash main menu
INFO:2023-09-13 22:21:40,550 [start] Stopping"

( i manually stopped the bot. )

just nothing happens in the main menu. and when i manually press play, it says over and over i dont have a card selected, if i select a card in the bar, it gets placed like 0.5 secounds after selecting, on the left side of the left tower.

Incorrect fireball/rocket placement in 2V2

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go in a 2v2 match
  2. run bot and wait until it places a fireball or rocket

Expected behavior
It should miss the tower

Screenshots

Desktop (please complete the following information):

  • OS: Windows 11
  • Display resolution: [1920x1080
  • Version V2.0.0

Additional context

not working

the bot does the same thing over and over again. closing memu, opening memu, closing memu, opening memu.... endless

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.