Use Python to write king of Glory brush gold script

  • 2020-06-19 10:41:35
  • OfStack

King of Glory many friends want to buy scripts and hang, want to more easily obtain gold can buy heroes in the game, etc., today we play the advantage of programmers to teach you to use Python language to write their own script can brush gold, the following is the full content.

There is a challenge mode in the king of Glory adventure mode. You can get more gold in the first pass, and then you can get a small amount of gold in the next challenge. This is not bug.

Recommended level: fallen scrap capital - devil recall

This level USES pure output hero around 20 seconds can play BOSS, around 50 seconds can be cleared, each repeated clearance can be awarded 19 gold COINS. It is recommended that you experience 1 of customs clearance manually before opening. This is the game principle.

In simple terms, you need to perform the following steps:

The interface opens to challenge level: Fallen scrap capital - Demon Recall [Click next step]

Enter the lineup adjustment interface, arrange the lineup in advance. 【 Click enter pass 】

Enter the challenge screen. [Click top right - Auto - Wait for the Challenge to end]

Enter the challenge completion interface. [Click the screen to continue]

Enter the level reward interface. [Click challenge again]

Enter the lineup adjustment screen and loop to Step 1 or Step 2.

As long as you can simulate the screen click, you can complete the script of swiping gold COINS. The easiest way to click on the Android simulation interface is to use ADB to send commands. There is no need for root phone, and no need to install the third party software. ADB Command Click the screen coordinates [x, y] to use the command:


adb shell input tap x y

I don't know if IOS has similar tools and commands, but if so, it would be easy to automatically brush gold COINS.

To prepare

This script is applicable to the Android game area and requires a real Android phone.

The USB mode should be turned on to allow computer debugging.

Install an Android driver on your computer, and a common pea pod or various butlers will automatically install it for you.

The computer needs to have the ADB toolset, which is available in many ways.

The ADB tool needs to be added to the environment variable PATH for easy invocation at any time.

Python needs to be installed on your computer because this is the scripting language of my choice.

Professional developers and testers can also refer to my other two blogs:

Set up Appium + Android automated test environment under Windows

Configure the Appium+Android automated test environment on Mac OSX

Just install the driver and the ADB tool to swipe the gold.

steps

If everything is there, the steps are simple.

Environmental testing

Use the USB to connect the phone. If a warning pops up, allow the computer to debug the phone.

Use the command adb devices to verify that the adb and phone status are ready.


$ adb devices
List of devices attached
b******4    device

Simulate clicking on the screen. For example, you can open the drawing software and run the command:


adb shell input tap 500 500

If you cut OK 1, you will see that the drawing software has 1 point at the coordinate (500,500).

Code implementation

The location of the screen to be clicked for clearance is fixed, and with annotations we need less than 30 lines of code to complete.


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)

And then we're going to write a main function to recycle the money.


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

And then:

Download kog.py from the project to local.

Open the game, enter the challenge mode, magic recall, lineup adjustment interface.

Adjust the parameters in ES131en.py according to the phone's performance and resolution. (Phone resolution, swiping times, etc.)

Run the following command to see the live action on your phone.

python kog.py

Note:

The weekly gold coin limit is 4,200, which needs nearly 4 hours. It is not recommended to fill it up once. Both the phone and you should take a rest.

Inscriptions, phone performance, hero selection will all affect the clearance speed, you can adjust the waiting time.

If you don't want to be tied down to the USB cable, consider using a wireless connection to the Android real machine.


Related articles: