Python realizes automatic gold coin brushing for King Pesticide

I want to write an auxiliary script (or plug-in?) for a game for a long time. In the past few days, the work and exams have been almost completed, and I have time to write a script of the glory of the king for your reference.

principle

Many people learn python and don't know where to start.
Many people learn python and after mastering the basic grammar, they don't know where to find cases to get started.
Many people who have done case studies do not know how to learn more advanced knowledge.
For these three types of people, I will provide you with a good learning platform, free to receive video tutorials, e-books, and course source code! ??¤
QQ group: 232030553

I think that the scripts of the game should be the same. The flow of our game is like this:

Then use the script to play the game, you can completely omit the intermediate steps:

So all we need is: press the button at a specific moment, at a specific location, and that's it.

Environment configuration

1. ADB tool (let the computer use the mobile phone)

Download address: https://adbshell.com/downloads/

If it’s slow, find other resources

I won’t go into details about the download configuration... Finally, it will appear similar to the figure below.

2. Python and IDE

I won’t go into details about the download configuration... Finally, it will appear similar to the figure below.

Steps of swiping gold coins

1. Connect the data cable to the computer and enter the mobile phone developer mode

2. Start adb

Error 1: Port 5037 is occupied, just close the corresponding process

netstat -ano | findstr "5037"
taskkill /pid (进程号) -f

Error 2: Lack of DLL, or did not enter the developer mode, just move the DLL

可选(0.找到下载adb的目录,把adb.exe,AdbWinApi.dll放到C:\WINDOWS\System32下)

1.将本机C:\WINDOWS\System32下的adb.exe文件复制到C:\Windows\SysWOW64下。
 
2.将本机C:\WINDOWS\System32下的AdbWinApi.dll文件复制到C:\Windows\SysWOW64下。

3. Open the Glory of Kings ( if you are not a developer, go to 5  ), cut a bunch of pictures, and check the pixels

You can see the Vientiane Tiangong pixels (1755, 793), click on the Vientiane Tiangong through the adb shell input tap 1755 793 command.

The same is true for the following:

Pixels (211, 275)

Pixels (1231, 557)

Pixels (800, 567) (1393, 475) (1677, 675) (1791, 939)

Pixels (1697, 861)

Pixels (2175, 45)

Click Automatic (2117, 39)

(No picture)

Wait for 60s, skip (2175, 45)

(No picture)

Wait 10s and click the screen to continue (1000, 500)

Challenge again (2001, 1011)

Just keep looping.

4. The code is as follows:

# -*- coding: utf-8 -*-
# @Author  : daruida
# @Time    : 2021/1/8 15:38
import os
from time import sleep


# 点击方法
def click_screen(x, y):
    os.system('adb shell input tap {} {}'.format(x, y))


def repeat(zidong):
    print('开始挑战')
    # 闯关
    click_screen(1697, 861)
    sleep(10)

    # 跳过
    print('点击跳过')
    click_screen(2175, 45)
    sleep(1)

    # 自动
    if zidong == 0:
        print('点击自动')
        click_screen(2117, 39)
        zidong = 1

    # 打完
    sleep(60)
    print('打完了')

    # 跳过
    click_screen(2175, 45)
    sleep(10)

    # 挑战完成
    print('挑战完成\n\n')
    click_screen(1000, 500)
    sleep(1)

    # 再次挑战
    print('再次挑战\n\n')
    click_screen(2001, 1011)
    sleep(1)
    repeat(zidong)

if __name__ == '__main__':
    zidong = 0
    print('刷金币初始化....')
    click_screen(1755, 793)  # 万象天宫
    sleep(1)
    click_screen(211, 275)   # 冒险玩法
    sleep(1)
    click_screen(1231, 557)  # 挑战
    sleep(2)
    print('通天塔\n')
    click_screen(1393, 475)  # 通天塔
    sleep(1)
    click_screen(1677, 675)  # 大师级别
    sleep(1)
    click_screen(1791, 939)  # 下一步
    print('刷金币重复阶段...')
    repeat(zidong)

Of course... if the mobile phone network is fast, or the call speed is fast, you can shorten the sleep time...

4. Package as exe

pyinstaller -F xxxx.py

5. After linking the phone, open to the king initialization interface and run exe

(If something goes wrong, just run it again)

test

My combination: Ben Sun + Crazy Tie + Xiao Jin Jin...

Automatically finish playing in 1min...1000+ gold coins in 1h

Of course, if you play other combinations for too long, you can discuss with me that it might go wrong.

It’s not beautiful to swipe gold coins while sleeping, or swipe gold coins while watching station B~

Guess you like

Origin blog.csdn.net/Python_sn/article/details/113108559