Exemplo n.º 1
0
 def check_if_constructed(self):
     self.go_to_tab()
     pos = helpers.return_position_of_image_on_screen(IMAGE_DICTIONARY["div_gen_uc"])
     pos_2 = helpers.return_position_of_image_on_screen(IMAGE_DICTIONARY["div_gen_constructed"])
     if pos[0] != -1:
         return False
     elif pos_2[0] != -1:
         return True
     else:
         return True
class Campaign(ActionClass):
    COORDINATES = c.CampaignCords()
    print(
        f"{Fore.CYAN}Campaign called c.CampaignCords() at {helpers.time_format()}"
    )
    START_BUTTON = "select_button"
    CLOSE_BUTTON = "auto_button"
    REWARD_BUTTON = "result_button"
    pg.click(COORDINATES.tab)
    FALL_BACK_POS = helpers.return_position_of_image_on_screen(
        IMAGE_DICTIONARY["growth_active"], COORDINATES)
    TABS = [COORDINATES.tab]
    CAMPAIGNS = {}

    def __init__(self, name, rooms):
        super().__init__(name)
        self.duration = int(rooms) * 60 * 60 + 20
        self.current_duration = self.duration
        try:
            self.camp_index = CAMPAIGN_INDEX[self.name]
        except KeyError:
            print(f"{self.name} not found in campaign_index")
        ActionClass.CAMPAIGNS[self.name] = self
        ActionClass.ALL_ACTION_CLASSES[self.name] = self

    def start_action(self):
        """ This can set and collect both campaign and dungeons. """
        coordinates = self.get_cords()
        self.go_to_tab()
        super().start_action()
        pg.click(coordinates.hour_12)
        pg.moveTo(coordinates.safe_spot)
        helpers.click_image_on_screen(IMAGE_DICTIONARY[self.CLOSE_BUTTON])
        self.is_active = True
 def start_action(self):
     """ This part can be run for both campaign and dungeons. """
     if self.is_active and self.timer.time_remaining() > 0:
         print(
             f"{self.name} is active with {self.timer.time_remaining():.0f} remaining"
         )
         return
     coordinates = self.get_cords()
     self.go_to_tab()
     pos = helpers.return_position_of_image_on_screen(
         IMAGE_DICTIONARY[self.name], coordinates)  # coordinates
     x = round(pos[0])
     y = round(pos[1]) - 25
     self.action_region = (x, y, x + 350, y + 50)
     self.action_region_relative = (x - coordinates.X_PAD,
                                    y - coordinates.Y_PAD,
                                    x + 350 - coordinates.X_PAD,
                                    y + 50 - coordinates.Y_PAD)
     pg.moveTo(coordinates.safe_spot)
     helpers.click_image_in_zone(IMAGE_DICTIONARY[self.START_BUTTON],
                                 zone=self.action_region)
     pg.moveTo(coordinates.safe_spot)
     duration = self.current_duration + 20
     if self.timer == -1:
         self.timer = TimerClass(self.name, duration)
     else:
         self.timer.set_end_time(duration)
         self.timer.reset_timer()
     TIMER_TRACKER[self.timer.name] = self.timer
     print(
         f"{self.name} has {self.timer.time_remaining()} seconds remaining")
Exemplo n.º 4
0
 def check_if_idle(self):
     """ Defaults to create weather if idle """
     self.go_to_tab()
     pos = helpers.return_position_of_image_on_screen(IMAGE_DICTIONARY["creating_shadow_clones"], self.COORDINATES)
     if pos[0] != -1:
         # We're creating shadow clones
         return True
     else:
         # We're still in the cycle
         return False
def set_input_box_value(identity_image, input_box, input_value):
    coordinates = Dungeon.COORDINATES
    pos = helpers.return_position_of_image_on_screen(
        IMAGE_DICTIONARY[identity_image], coordinates)  # coordinates
    x = round(pos[0])
    y = round(pos[1]) - 25
    helpers.click_image_in_zone(IMAGE_DICTIONARY[input_box], x, y, x + 300,
                                y + 50)
    helpers.click_image_in_zone(IMAGE_DICTIONARY[input_box], x, y, x + 300,
                                y + 50)
    pg.write(input_value)
def dungeon_info(dungeon):
    coordinates = Dungeon.COORDINATES
    depth_text = helpers.return_position_of_image_on_screen(
        IMAGE_DICTIONARY["depth_text"], coordinates)  # coordinates
    current_depth = d.new_check_current_team(dungeon.depth, depth_text)
    if not current_depth:
        return
    set_input_box_value("duration_text", "input_box", dungeon.rooms)
    pg.moveTo(coordinates.safe_spot)
    set_input_box_value("difficulty_text", "input_box", dungeon.difficulty)
    pg.moveTo(coordinates.safe_spot)
class Dungeon(ActionClass):
    COORDINATES = c.DungeonCords()
    print(
        f"{Fore.CYAN}Dungeon called c.DungeonCords() at {helpers.time_format()}"
    )
    START_BUTTON = "info_button"
    CLOSE_BUTTON = "start_button"
    REWARD_BUTTON = "dungeon_finished_button"
    pg.click(COORDINATES.tab)
    FALL_BACK_POS = helpers.return_position_of_image_on_screen(
        IMAGE_DICTIONARY["newbie_active"], COORDINATES)
    TABS = [COORDINATES.tab, COORDINATES.dungeon_tab]
    DUNGEONS = {}

    def __init__(self, name, team, depth, rooms, difficulty):
        super().__init__(name)
        self.team = team
        self.depth = depth
        self.rooms = rooms
        self.difficulty = difficulty
        self.duration = int(self.rooms) * self.get_cords().room_duration + 5
        self.current_duration = self.duration
        self.timer = TimerClass(self.name, -1)
        self.active_name = self.name + "_active"
        try:
            self.camp_index = G_DUNGEON_INDEX[self.name]
        except KeyError as exception:
            print(exception, "Not in list")
        super().DUNGEONS[self.name] = self
        Dungeon.DUNGEONS[self.name] = self

    def start_action(self):
        """ This is part 2 of start_action. ActionClass holds part 1"""
        self.go_to_tab()
        super().start_action()
        self.check_if_correct_team()
        dungeon_info(self)
        helpers.click_image_on_screen(IMAGE_DICTIONARY[self.CLOSE_BUTTON])
        self.is_active = True

    def check_if_correct_team(self):
        coordinates = self.get_cords()
        next_button_cord = helpers.add_screen_padding(
            helpers.find_image_in_game_window(IMAGE_DICTIONARY["next_button"],
                                              coordinates=coordinates),
            coordinates)
        button_center = (next_button_cord[0] + 26, next_button_cord[1] + 18)
        current_team = d.new_check_current_team(self.team, button_center)
        if not current_team:
            return
 def check_if_active(self):
     coordinates = self.get_cords()
     self.go_to_tab()
     try:
         pos = helpers.return_position_of_image_on_screen(
             IMAGE_DICTIONARY[self.active_name])
     except KeyError as exception:
         pos = (self.FALL_BACK_POS[0],
                self.FALL_BACK_POS[1] + 45 * self.camp_index)
         print(exception)
     if pos[0] == -1:
         pos = (self.FALL_BACK_POS[0],
                self.FALL_BACK_POS[1] + 45 * self.camp_index)
     x = round(pos[0])
     y = round(pos[1]) - 25
     self.action_region_relative = (x - coordinates.X_PAD,
                                    y - coordinates.Y_PAD,
                                    x + 350 - coordinates.X_PAD,
                                    y + 50 - coordinates.Y_PAD)
     pg.moveTo(pos[0] + 50, pos[1])
     tooltip_image = helpers.get_image_from_zone(coordinates.tooltip_region)
     time.sleep(0.1)
     time_left = get_hours_left(tooltip_image)
     if time_left == -1:
         print(f"{Fore.RED}{self.name} is not active")
         self.is_active = False
         return False
     elif time_left == 0:
         print(
             f"{Fore.GREEN}{self.name} is finished... Collecting Reward (self.collect_reward())"
         )
         self.collect_reward()
         self.is_active = False
         return False
     self.timer.set_end_time(time_left + 5)
     self.timer.reset_timer()
     self.is_active = True
     print(
         f"{Fore.GREEN}{self.name} is active with {self.timer.time_remaining():.0f} remaining"
     )
     return True