30 lines of Python code to brush the king's glory gold coins

principle

There is a challenge mode in the adventure mode of King Glory. The first time you pass the level, you can get more gold coins, and you will still get a small amount of gold coins after re-challenging.

Recommended level: Fallen Abandoned City - Memories of the Witch

This level uses pure output heroes to fight BOSS in about 20 seconds, and it can be cleared in about 50 seconds. Each time you clear the level repeatedly, you can get 19 gold coins as a reward. Before opening and hanging, it is recommended that you manually clear the customs to experience it. This is the principle of the game.

Briefly, the following steps are required:

  1. The interface opens to the challenge level: Fallen Abandoned City - Memories of the Witch [Click Next]
  2. Enter the lineup adjustment interface and arrange the lineup in advance. 【Click to break through】
  3. Enter the challenge interface. [Click on the upper right corner - Auto - Wait for the challenge to end]
  4. Enter the challenge completion interface. 【Click the screen to continue】
  5. Enter the level reward interface. 【Click to challenge again】
  6. Enter the lineup adjustment interface, loop to step 1 or step 2 [it seems to depend on the game area and version]

As long as you can simulate screen clicks, you can complete the script for brushing gold coins. The easiest way to click on the Android simulation interface is to use ADB to send commands, which does not require rooting the phone or installing third-party software, which is convenient and fast. ADB command Click on screen coordinates [x, y] to use the command:

adb shell input tap x y

Whether there are similar tools and commands for IOS, I don't know, if there is, it is very simple to automatically brush gold coins.

Prepare

  • This script is suitable for the Android game area and requires a real Android phone.
  • The phone needs to open the USB debugging mode to allow the computer to debug.
  • The computer needs to have the Android driver installed. Generally, Pea Pod or various housekeepers can automatically install it for you.
  • The computer needs to have the ADB toolset, which can be obtained in many ways.
  • The ADB tool needs to be added to the environment variable PATH so that it can be called at any time.
  • Python needs to be installed on the computer as this is my scripting language of choice.

If you just want to brush gold coins, you only need to install the driver and ADB tools.

step

If everything is in place, the steps are very simple.

environmental test

  1. Connect the phone with USB, if a warning pops up, please allow the computer to debug the phone.
  2. Use the command to adb devicesverify adb and phone status are ready.
$ adb devices
List of devices attached
b******4        device

To simulate clicking on the screen, for example, you can open the paint software and run the command:

adb shell input tap 500 500

If everything is ok, then you will see that the paint software has a point at coordinates (500,500).

Code

The position of the screen that needs to be clicked to clear the level is fixed, and with comments, we can complete it in less than 30 lines of code.

def tap_screen(x, y):
    os.system('adb shell input tap {} {}'.format(x, y))

def do_money_work():
    print('#0 start the game')
    tap_screen(1600, 970)
    sleep(3)

    print('#1 ready, go!!!')
    tap_screen(1450, 910)
    sleep(15)

    print('#2 auto power on!')
    tap_screen(1780, 40)

    for i in range(25):
        tap_screen(1000, 500)
        sleep(1)

    print('#3 do it again...\n')
    tap_screen(1430, 980)
    sleep(3)

Then we write a main function to cycle the money.

if __name__ == '__main__':
    for i in range(repeat_times):
        print('round #{}'.format(i + 1))
        do_money_work()

Then:

  1. Download the in the project kog.pyto local.
  2. Open the game, enter the challenge mode, witch memories, lineup adjustment interface.
  3. kog.pyAdjust the parameters according to the performance and resolution of the mobile phone . (Mobile phone resolution, number of credits, etc.)
  4. Run the following command to view the real-time running effect on your mobile phone.
python kog.py

Notice:

  1. The weekly gold limit is 4200, which takes nearly 4 hours. It is not recommended to fill up at one time. Both the phone and you have to rest.
  2. Inscriptions, mobile phone performance, and hero selection will all affect the speed of customs clearance, so you can fine-tune the waiting time yourself.
  3. If you don't want to be tethered to a USB cable.

statement

This script is purely for entertainment and exploration. If you are banned for violating the rules of the game, I will not be responsible.

At the end, I will also give you a python spree [Jiajun Yang: 419693945] to help you learn better!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324341840&siteId=291194637