Exemple #1
0
    def run(self):

        self.init_main_city_location()

        self.init_wipe_out_land_info()

        while True:

            # 数据重置
            self.reset_data()

            # 征兵
            self.conscription()

            log.info(self.army_troops_list)

            for index in range(0, config.army_count):
                self.hero_wipe_out_analysis(index,
                                            self.army_troops_list[index])

            min_value = min(self.min_wait_duration_list)
            if min_value == 12 * 50 * 50:
                sleep_duration = 20
            else:
                sleep_duration = max(min_value, 20)

            log.info("睡眠" + str(sleep_duration) + "秒")
            time.sleep(sleep_duration)
Exemple #2
0
def click_hero_conscription_max(hwnd, hero_index):
    rect = position.hero_conscription_rect_list[hero_index]
    mouse.click_point(hwnd, rect[2] - window.seek_bar_limit,
                      int((rect[1] + rect[3]) / 2))
    time.sleep(0.2)
    mouse.click_point(hwnd, rect[2], int((rect[1] + rect[3]) / 2))
    time.sleep(0.2)
Exemple #3
0
def click_point(hwnd, x, y):
    # 位置坐标
    long_position = win32api.MAKELONG(x - window.left_space,
                                      y - window.top_space)
    # 鼠标左键按下
    win32api.SendMessage(hwnd, win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON,
                         long_position)
    time.sleep(0.1)
    # 鼠标左键抬起
    win32api.SendMessage(hwnd, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON,
                         long_position)
Exemple #4
0
 def run(self):
     start = (1092, 1377)
     end = (1103, 1384)
     while start != end:
         temp = self.occupy_next_land(start, end)
         print("武将出征")
         self.army_expedition(temp)
         print("选择合适的武将出征")
         while not self.choose_army():
             print("重新选择武将")
             time.sleep(60)
         start = temp
Exemple #5
0
 def get_location_list(self):
     location_list = set()
     while True:
         item_list = assistant.get_one_page_land_location_list(self.hwnd)
         before_count = len(location_list) + len(item_list)
         location_list.update(item_list)
         after_count = len(location_list)
         # 比较是否有重复的有就认为是到底了
         if before_count < 8 or before_count != after_count:
             break
         time.sleep(1)
         event.scroll_one_page(self.hwnd)
     return location_list
Exemple #6
0
    def run(self):
        while True:
            # 数据重置
            self.reset_data()

            log.info("进入城池页面")
            self.enter_city_page()
            log.info("疲倦武将替换")
            self.tired_hero_replace()
            log.info("武将循环出征")
            self.hit_the_ground()
            log.info("睡眠" + str(max(min(self.min_wait_duration_list), 20)) +
                     "秒")
            time.sleep(3 * 60)
Exemple #7
0
 def choose_army(self):
     for hero_index in range(5):
         print("判断武将灰度状态")
         # TODO 判断兵力
         if assistant.is_expedition_hero_gray(self.hwnd, hero_index):
             print("武将是灰色状态,无法出征")
             print("点击外部区域回到上一页")
         else:
             print("武将可以出征")
             event.click_expedition_army(self.hwnd, hero_index)
             print("武将开始出征了")
             duration = assistant.get_march_duration(self.hwnd)
             print("计算行军时长: " + str(duration))
             event.click_wipe_out_button(self.hwnd)
             time.sleep(duration * 2 + 30)
             return True
     return False
Exemple #8
0
 def hit_the_ground(self):
     for army_index in range(3, 4):
         if army_index == 3:
             log.info("撞地武将撞地:")
             self.army_expedition(config.leveling_land_help)
         else:
             log.info("普通武将撞地:")
             self.army_expedition(config.leveling_land)
         log.info("判断武将灰度状态:")
         if assistant.is_expedition_hero_gray(self.hwnd, army_index):
             log.info("武将是灰色状态,无法出征")
             log.info("点击外部区域回到上一页")
             event.click_outside(self.hwnd)
         else:
             log.info("武将可以出征")
             event.click_expedition_army(self.hwnd, army_index)
             log.info("武将开始出征了")
             event.click_wipe_out_button(self.hwnd)
             time.sleep(2)
Exemple #9
0
    def hero_wipe_out_analysis(self, hero_index, troops):
        manor_dict = config.wipe_out_threshold_dict[hero_index]
        enable_index = -1
        for index in range(0, len(config.wipe_out_threshold_dict)):
            if manor_dict[index] <= troops:
                log.info(manor_dict[index])
                log.info(troops)
                enable_index = index
                break

        if enable_index >= 0:
            log.info("有能战胜的土地:%d 级地" %
                     (len(config.wipe_out_threshold_dict) - enable_index))
            log.info("寻找合适的土地:")
            manor_list = config.wipe_out_location_dict[
                "manor_%d" %
                (len(config.wipe_out_threshold_dict) - enable_index)]
            manor_index = self.manor_index_list[enable_index]
            point = manor_list[manor_index]
            log.info("合适的土地坐标:" + str(point))
            log.info("定位扫荡地点")
            self.wipe_out(point)
            log.info("判断武将灰度状态")
            if assistant.is_expedition_hero_gray(self.hwnd, hero_index) or not \
                    self.is_enable_wipe_out(hero_index, enable_index, assistant.is_troops_enough(self.hwnd,
                                                                                                 hero_index)):
                log.info("武将是灰色状态,无法出征")
                log.info("点击外部区域回到上一页")
                event.click_outside(self.hwnd)
            else:
                log.info("武将可以出征")
                event.click_expedition_army(self.hwnd, hero_index)
                log.info("武将开始出征了")
                event.click_wipe_out_button(self.hwnd)
                self.manor_index_list[enable_index] = (
                    self.manor_index_list[enable_index] +
                    1) % len(config.wipe_out_location_dict[
                        "manor_%d" %
                        (len(config.wipe_out_threshold_dict) - enable_index)])
                time.sleep(2)
        else:
            log.info("没有能战胜的土地")
Exemple #10
0
def click_hero_force_expedition(hwnd):
    mouse.click(hwnd, position.hero_force_expedition_rect)
    time.sleep(1)
Exemple #11
0
def click_army_hero(hwnd, hero_index):
    mouse.click(hwnd, position.army_hero_rect_list[hero_index])
    time.sleep(0.5)
Exemple #12
0
def click_city_army_even(hwnd, army_index):
    mouse.click(hwnd, position.city_army_even_list[army_index])
    time.sleep(0.5)
Exemple #13
0
def click_mark_location_main_city(hwnd):
    mouse.click(hwnd, position.mark_location_menu_main_city_rect)
    time.sleep(2)
    assert_right.assert_click_mark_location_main_city(hwnd)
Exemple #14
0
def drag_hero_down(hwnd, index):
    mouse.press_move(hwnd, position.army_hero_raise_rect_list[index],
                     position.hero_select_rect_list[0])
    time.sleep(2)
Exemple #15
0
def click_mark_location_menu(hwnd):
    mouse.click(hwnd, position.mark_location_menu_rect)
    time.sleep(0.5)
    assert_right.assert_click_mark_location_menu(hwnd)
Exemple #16
0
def click_hero_screen_arms_item(hwnd, arms):
    mouse.click(
        hwnd, position.hero_screen_arms_item_rect_list[const.hero_dict[arms]])
    time.sleep(1)
Exemple #17
0
def click_hero_screen_camp_item(hwnd, camp):
    mouse.click(
        hwnd, position.hero_screen_camp_item_rect_list[const.hero_dict[camp]])
    time.sleep(1)
Exemple #18
0
def click_interior_detail_menu(hwnd):
    mouse.click(hwnd, position.interior_detail_menu_rect)
    time.sleep(1)
Exemple #19
0
def drag_hero_placeholder(hwnd, index, target_index):
    mouse.press_move(hwnd, position.hero_select_rect_list[index],
                     position.army_hero_raise_rect_list[target_index])
    time.sleep(2)
Exemple #20
0
def click_army_setting_menu(hwnd):
    mouse.click(hwnd, position.army_setting_menu_rect)
    time.sleep(1)
Exemple #21
0
def click_map_menu(hwnd):
    mouse.click(hwnd, position.map_menu_rect)
    time.sleep(0.5)
Exemple #22
0
def click_hero_select(hwnd, index):
    mouse.click(hwnd, position.hero_select_rect_list[index])
    time.sleep(1)
Exemple #23
0
def click_city_menu(hwnd):
    mouse.click(hwnd, position.city_menu_rect)
    time.sleep(1.5)
    assert_right.assert_enter_city_page(hwnd)
Exemple #24
0
def click_center(hwnd):
    mouse.click_point(hwnd, window.center_x, window.center_y)
    time.sleep(1)
Exemple #25
0
def click_expedition_army_even(hwnd, army_index):
    mouse.click(hwnd, position.expedition_army_even_rect_list[army_index])
    time.sleep(1)
Exemple #26
0
def click_hero_screen_button(hwnd):
    mouse.click(hwnd, position.hero_screen_button_rect)
    time.sleep(1)
Exemple #27
0
def click_wipe_out_button(hwnd):
    mouse.click(hwnd, position.wipe_out_button_rect)
    time.sleep(1)
Exemple #28
0
def click_hero_screen_camp_reset(hwnd):
    mouse.click(hwnd, position.hero_screen_camp_reset_rect)
    time.sleep(1)
Exemple #29
0
def click_page_close(hwnd):
    mouse.click(hwnd, position.page_close_rect)
    time.sleep(2)
Exemple #30
0
def click_hero_screen_star_item(hwnd, star):
    mouse.click(
        hwnd, position.hero_screen_star_item_rect_list[const.hero_dict[star]])
    time.sleep(1)