aboutsummaryrefslogtreecommitdiff
path: root/bot.py
blob: 42cb0706a573e279153aa9ea870c1ee2c32cefe4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import time

import mss
import pyautogui as pg
from numpy import array, uint8
from pynput.keyboard import Key, Controller

keyboard = Controller()


def begin():
    pg.click(440, 900, 2)


TREE = uint8([56, 116, 161])

# from left to right
posY = [360, 460]
# from bottom to up
posX = [640, 540, 440, 340, 240, 140]


def is_tree(c1):
    if c1[0] == TREE[0] and c1[1] == TREE[1] and c1[2] == TREE[2]:
        return True
    else:
        return False


with mss.mss() as sct:
    screen = sct.monitors[1]
    screen["width"] = screen["width"] / 2.0
    begin()

    while True:
        img = array(sct.grab(screen))
        moves = list()
        left = [img[x, posY[0]] for x in posX]
        for i in range(6):
            if is_tree(left[i]):
                keyboard.press(Key.right)
                keyboard.release(Key.right)
                time.sleep(0.014)
                keyboard.press(Key.right)
                keyboard.release(Key.right)
            else:
                keyboard.press(Key.left)
                keyboard.release(Key.left)
                time.sleep(0.014)
                keyboard.press(Key.left)
                keyboard.release(Key.left)
        time.sleep(0.17)
Powered by cgit v1.2.3 (git 2.41.0)