Esempio n. 1
0
class ShuiLu():
    def __init__(self):
        self.transform = TransForm()
        self.common = Common()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.mouse = Mouse()

    def task_start(self):
        self.screen.find_ele_picture('game\\system\\zidong')
        time.sleep(5)
        for i in range(5):
            self.keyboard.press_key('f7')
            if i is 0:
                self.mouse.click_element(198, 338, times=1)
            else:
                pyautogui.click()
            pyautogui.click()
            self.keyboard.press_shortcut_key('alt', '8')
            self.common.change_teamer(0.3)
Esempio n. 2
0
class DiGong():
    def __init__(self):
        self.transform = TransForm()
        self.common = Common()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.mouse = Mouse()

    def make_sure(self):
        self.common.get_focus()
        for i in range(3):
            self.mouse.click_element(311, 490)
            self.common.change_teamer()
        self.common.get_focus()

    def game_over(self):
        endtime = time.time() + int(300)
        while time.time() < endtime:
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            result_ = self.screen.get_location_picture(
                "D:\\dh2\\game\\system\\zidong.png", num=0.8)
            if result_ is 0:
                return True
        return False

    def operate(self, level):
        self.common.get_focus()
        self.keyboard.press_shortcut_key('alt', '2')
        self.mouse.click_element(539, 386)
        time.sleep(2)
        self.mouse.click_element(618, 463)
        time.sleep(10)
        # 寻找NPC 185,380
        self.screen.find_ele_picture('yitiao\\digong\\begin')
        self.mouse.click_element(185, 380, times=0.5)
        time.sleep(2)
        self.mouse.click_element(547, 146, times=0.5)
        time.sleep(2)
        self.mouse.click_element(204, 378, times=0.5)
        time.sleep(2)
        self.mouse.click_element(64, 242, times=0.5)
        # 点老鼠
        self.screen.find_ele_picture('yitiao\\digong\\1')
        time.sleep(2)
        self.mouse.click_element(64, 242, times=0.5)
        time.sleep(2)
        self.mouse.click_element(202, 363, times=0.5)
        time.sleep(1)
        self.mouse.click_element(197, 345, times=0.5)
        time.sleep(1)
        pyautogui.click()
        # 点击任务栏
        time.sleep(1)
        self.mouse.click_element(44, 269, times=0.5)
        time.sleep(2)
        if level is '0':
            self.mouse.click_element(486, 239, times=0.5)
            self.screen.find_ele_picture('yitiao\\digong\\2_0')
            self.mouse.click_element(179, 327, times=0.5)
        elif level is '1':
            self.mouse.click_element(486, 275, times=0.5)
            self.screen.find_ele_picture('yitiao\\digong\\2_1')
            self.mouse.click_element(179, 350, times=0.5)
        # 组队确认
        self.make_sure()
        time.sleep(2)
        self.screen.find_ele_picture('system\\zidong')
        self.common.find_attack('f7')
        self.keyboard.press_shortcut_key('alt', 'd')
        self.keyboard.press_shortcut_key('alt', '8')
        self.common.change_teamer()
        for i in range(2):
            self.keyboard.press_key('f7')
            pyautogui.click()
            self.keyboard.press_shortcut_key('alt', 'd')
            self.keyboard.press_shortcut_key('alt', '8')
            self.common.change_teamer()
        self.common.get_focus()
        time.sleep(20)
        self.game_over()
        print("任务结束")
Esempio n. 3
0
class Common:
    def __init__(self):
        self.personList = [75, 250, 400, 545, 700]
        self.mouse = Mouse()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.transform = TransForm()

    def get_focus(self, index=True):
        if index is True:
            self.mouse.click_direct_element(
                self.transform.trans_location(75, 0),
                self.transform.trans_location(45, 1))
        else:
            self.mouse.click_direct_element(
                self.transform.trans_location(700, 0),
                self.transform.trans_location(45, 1))

    def create_team(self):
        # 创建队伍
        self.keyboard.press_shortcut_key('alt', 't', 1)
        self.mouse.click_element(403, 318)
        # 打开好友列表查看组队信息
        self.keyboard.press_shortcut_key('alt', 'f', 1)
        time.sleep(0.5)

        self.screen.cut_screen()
        result = self.screen.find_color_ele(679, 291)
        if result != None:
            self.mouse.click_element(result[0], result[1])
        list = [315, 345, 375, 405]
        for i in list:
            self.mouse.click_element_right(730, i, 1)
            self.mouse.click_element(388, 505)
        self.mouse.click_element_right(388, 530, 1)
        self.keyboard.press_shortcut_key('alt', 'f', 1)

        for i in range(4):
            self.keyboard.press_shortcut_key('ctrl', 'tab', 1)
            self.mouse.click_element(347, 410)
        self.keyboard.press_shortcut_key('ctrl', 'tab', 1)

    def change_teamer(self, times=1):
        self.keyboard.press_shortcut_key('ctrl', 'tab', times)

    def change_dog(self, num):
        self.keyboard.press_shortcut_key('alt', 'o')
        if num == 1:
            self.mouse.click_element(90, 186)
        elif num == 2:
            self.mouse.click_element(90, 208)
        elif num == 3:
            self.mouse.click_element(90, 230)
        elif num == 4:
            self.mouse.click_element(90, 252)
        elif num == 5:
            self.mouse.click_element(90, 274)
        elif num == 6:
            self.mouse.click_element(90, 296)
        time.sleep(1.5)
        self.screen.cut_screen_location(width=200, height=50, x=200, y=350)
        time.sleep(1)
        result = self.screen.get_location_picture(
            "D:\\dh2\\game\\system\\0.png", 0.9, cut_zone=True)
        if result == 0:
            self.mouse.click_element(320, 380)
        self.keyboard.press_shortcut_key('alt', 'o')

    def clear_task(self):
        # 清除任务列表
        # self.keyboard.press_shortcut_key('alt', 'q')
        # for i in range(5):
        #     self.mouse.click_element(359, 223)
        # list = [27, 46, 65, 85, 103, 122, 141]
        # for i in list:
        #     time.sleep(1)
        #     self.screen.cut_screen_location(width=200, height=300, x=150, y=190)
        #     result = self.screen.find_color_ele(11, i, 2, 1, 190, 220, 60, 75, 50, 60, True)
        #     print(result)
        #     if result == None:
        #         self.mouse.click_element(11 + 200, i + 190)
        self.keyboard.press_shortcut_key('alt', '2')
        time.sleep(1)
        self.mouse.click_element(507, 419)
        time.sleep(1)
        self.mouse.click_element(310, 381)
        self.screen.find_ele_picture('game\\bangpai\\0_', 'mouse', 220, 328)
        time.sleep(2)
        self.keyboard.press_shortcut_key('alt', '1')
        time.sleep(1)
        self.mouse.click_element(500, 313)

    def iswalking(self):
        self.screen.cut_screen_by_PIL(30, 65, 140, 85,
                                      "D:\\dh2\\system\\2.PNG")
        time.sleep(2)
        self.screen.cut_screen_by_PIL(30, 65, 140, 85,
                                      "D:\\dh2\\system\\2_.PNG")
        result = Walking().iswalking()
        if result < 10:
            return False
        else:
            return True

    def click_until_find(self, file_name, x, y):
        Mouse().click_element(x, y)
        Screen().cut_screen()
        result = Screen().get_location_picture(file_name)
        if result is not 0:
            return True
        return False

    def capation_eat_xiang(self):
        KeyBoard().press_shortcut_key('alt', 'e')
        Mouse().click_element(344, 397)
        Mouse().click_element(44, 454, right=True)
        KeyBoard().press_shortcut_key('alt', 'e')

    def score_for_shifu(self):
        Screen().cut_screen()
        result = Screen().get_location_picture("D:\\dh2\\game\\system\\3.PNG")
        if result is not 0:
            Mouse().click_element(222, 264)
            Mouse().click_element(409, 506)

    def task_box(self):
        pass

    # 寻找共计目标
    def find_attack(self, type, str='zidong'):
        list = [[198, 280], [198, 320], [198, 360]]
        endtime = time.time() + int(1000)
        while time.time() < endtime:
            time.sleep(1.5)
            self.screen.cut_screen()
            pos_zidong = self.screen.get_location_picture(
                "D:\\dh2\\game\\system\\" + str + ".png")
            if pos_zidong is not 0:
                if type is 'f5' or type is 'f6' or type is 'f7':
                    self.keyboard.press_key(type)
                    for i in list:
                        self.mouse.click_element(i[0], i[1], times=0.5)
                        time.sleep(1)
                        self.screen.cut_screen()
                        pos_zidong = self.screen.get_location_picture(
                            "D:\\dh2\\game\\system\\" + str + ".png")
                        if pos_zidong is not 0:
                            return i
                elif type is None:
                    for i in list:
                        self.mouse.click_element(i[0], i[1], times=0.5)
                        time.sleep(1)
                        self.screen.cut_screen()
                        pos_zidong = self.screen.get_location_picture(
                            "D:\\dh2\\game\\system\\" + str + ".png")
                        if pos_zidong is not 0:
                            return i
        return 'failed'

    def game_over(self):
        endtime = time.time() + int(300)
        while time.time() < endtime:
            time.sleep(1)
            self.screen.cut_screen()
            time.sleep(1)
            result = self.screen.get_location_picture(
                "D:\\dh2\\game\\system\\zidong.png", num=0.8)
            if result is 0:
                return True
        return False
Esempio n. 4
0
class DianXing():
    def __init__(self):
        self.transform = TransForm()
        self.common = Common()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.mouse = Mouse()
    def operate(self,type):
        if type is 0:
            self.keyboard.press_shortcut_key('alt', 'a')
        elif type is 1:
            self.keyboard.press_shortcut_key('alt', 'w')
            time.sleep(0.5)
            self.mouse.click_element(317, 178)
            time.sleep(0.5)
            self.mouse.click_element(289, 383)
    def task_start(self):
        jiangxing = 0
        print("任务开始")
        self.common.get_focus()
        time.sleep(1)
        self.mouse.click_element(768, 195)
        time.sleep(1)
        for i in range(8):
            # for x in range(5):
            #     self.mouse.click_element(421, 208, times=1, right=True)
            #     self.common.change_teamer(0.5)
            endtime = time.time() + int(500)
            while time.time() < endtime:
                self.screen.cut_screen()
                time.sleep(2)
                loc_begin = self.screen.get_location_picture("D:\\dh2\\game\\dianxing\\begin2.png",num=0.9)
                if loc_begin is not 0:
                    self.mouse.click_element(432, 516)
                    for j in range(5):
                        self.mouse.click_element(309, 489, times=0.2, right=True)
                        self.mouse.click_element(309, 489, times=0.2)
                        self.common.change_teamer(0.2)
                pos_zidong = self.screen.get_location_picture("D:\\dh2\\game\\dianxing\\1.png",num=0.99)
                pos_caozuo = self.screen.get_location_picture("D:\\dh2\\game\\dianxing\\2.png",num=0.99)
                if pos_zidong is not 0 and pos_caozuo is 0:
                    # 人物
                    flag = 0
                    while True:
                        # self.mouse.click_element(412, 137, times=1, right=True
                        if flag is 0:
                            result = self.common.find_attack(type='f7')
                            self.mouse.click_element(result[0], result[1], times=0.5)
                            self.keyboard.press_shortcut_key('alt', '8')
                            self.common.change_teamer(0.3)
                            for jj in range(4):
                                self.keyboard.press_key('f7')
                                time.sleep(0.3)
                                pyautogui.click()
                                time.sleep(0.3)
                                pyautogui.click()
                                time.sleep(0.3)
                                self.keyboard.press_shortcut_key('alt', '8')
                                self.common.change_teamer(0.3)
                            flag+=1
                        self.screen.cut_screen()
                        time.sleep(1)
                        loc_begin2 = self.screen.get_location_picture("D:\\dh2\\game\\dianxing\\begin.png")
                        time.sleep(0.5)
                        if loc_begin2 is not 0:
                            break

                if pos_caozuo is not 0 and pos_zidong is 0:
                    # 星将
                    while True:
                        # self.mouse.click_element(412, 137, times=1, right=True)
                        self.screen.cut_screen()
                        time.sleep(1)
                        pos_caozuo2= self.screen.get_location_picture("D:\\dh2\\game\\dianxing\\2.png")
                        if pos_caozuo2 is not 0:
                            if jiangxing is 0:
                                for z in range(5):
                                    self.keyboard.press_shortcut_key('alt', 'a')
                                    self.keyboard.press_shortcut_key('alt', 'w')
                                    self.mouse.click_element(314, 179, times=0.2, right=True)

                                    if z is 0:
                                        result = self.common.find_attack(type='other',str='caozuo2')
                                        self.mouse.click_element(result[0], result[1], times=0.2)
                                    else:
                                        self.mouse.click_element(result[0], result[1], times=0.2)
                                    self.common.change_teamer(0.3)
                                    jiangxing+=1
                            else:
                                for z in range(5):
                                    self.keyboard.press_shortcut_key('alt', 'a')
                                    if z is 0:
                                        result = self.common.find_attack(type='other',str='caozuo2')
                                        self.mouse.click_element(result[0], result[1], times=0.2)
                                    else:
                                        pyautogui.click()
                                    self.common.change_teamer(0.3)
                        self.screen.cut_screen()
                        time.sleep(1)
                        loc_begin2 = self.screen.get_location_picture("D:\\dh2\\game\\dianxing\\begin.png")
                        time.sleep(0.5)
                        if loc_begin2 is not 0:
                            break
Esempio n. 5
0
class TianTi():
    def __init__(self):
        self.transform = TransForm()
        self.common = Common()
        self.keyboard = KeyBoard()
        self.screen = Screen()
        self.mouse = Mouse()
    def chong_operate(self,type):
        if type is 0:
            self.keyboard.press_shortcut_key('alt', 'a')
        elif type is 1:
            self.keyboard.press_shortcut_key('alt', 'w')
            time.sleep(0.5)
            self.mouse.click_element(317, 178)
            time.sleep(0.5)
            self.mouse.click_element(289, 383)

    def task_start(self):
        print("任务开始")
        self.common.get_focus()
        time.sleep(1)
        # 切换宝宝
        for i in range(5):
            self.common.change_dog(2)
            time.sleep(1)
            self.common.change_teamer(times=0.3)
        time.sleep(1)
        self.mouse.click_element(757, 553)
        time.sleep(1)
        self.mouse.click_element(161, 327)
        time.sleep(3)
        # 开始点击天梯
        self.mouse.click_element(770, 193)
        time.sleep(1)
        for i in range(10):
            for z in range(5):
                self.mouse.click_element(422, 144,right=True)
                time.sleep(1)
                self.common.change_teamer(times=0.3)
            if i is not 0:
                time.sleep(3)
            self.screen.find_ele_picture('game\\tianti\\begin')
            self.mouse.click_element(470, 444)
            for z in range(5):
                if z is 0:
                    self.mouse.click_element(312, 490)
                else:
                    pyautogui.click()
                time.sleep(1)
                self.common.change_teamer(times=0.3)
            # flag = 0
            self.screen.find_ele_picture('system\\zidong')
            self.common.find_attack('f7')
            pyautogui.click()
            self.keyboard.press_shortcut_key('alt', '8',times=0.3)
            self.common.change_teamer(times=0.3)
            for i in range(4):
                self.keyboard.press_key('f7')
                pyautogui.click()
                pyautogui.rightClick()
                pyautogui.click()
                self.keyboard.press_shortcut_key('alt', '8',times=0.3)
                self.common.change_teamer(times=0.3)
            self.common.get_focus()
            self.common.game_over()