예제 #1
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
예제 #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("任务结束")
예제 #3
0
파일: tianti.py 프로젝트: Greatwan/dh2
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()