Beispiel #1
0
    def take_images(self):
        for point in self.points:
            splittedpoints = point.split()
            x = float(splittedpoints[0])
            y = float(splittedpoints[1])
            try:
                self.locations = LocationSet(",".join(
                    splittedpoints[2].split("_")))
            except:
                self.locations = None
            if not self.noop or self.skip - test_seq_num < len(
                    self.exposures) * self.imcount * (self.bcount + 1):
                bot.moveTo(x, y)
            for exposure in self.exposures:
                (exposure1, exposure2) = exposure.split()
                self.exposure1 = float(exposure1) / self.signalpersec
                self.exposure2 = float(exposure2) / self.signalpersec

                def expose_command():
                    self.set_filter(self.mask1)
                    bot_bench.openShutter(self.exposure1)
                    if self.exposure2 != 0.:
                        self.set_filter(self.mask2)
                        bot_bench.openShutter(self.exposure2)

                for i in range(self.imcount):
                    self.take_bias_plus_image(
                        self.exposure1,
                        expose_command,
                        symlink_image_type='%03.1f_%03.1f_FLAT_%s_%03.1f_%03.1f'
                        % (x, y, self.mask1, self.exposure1, self.exposure2))
Beispiel #2
0
 def take_images(self):
     for point in self.points:
         (x, y) = [float(x) for x in point.split()]
         bot.moveTo(x, y)
         for exposure in self.exposures:
             exposure = float(exposure)
             expose_command = lambda: bot_bench.openShutter(exposure)
             for i in range(self.imcount):
                 self.take_bias_plus_image(
                     exposure,
                     expose_command,
                     symlink_image_type='%03.1f_%03.1f_%03.1f' %
                     (x, y, exposure))
Beispiel #3
0
def fightingfight(threadname):
    while True:
        while flag_should_fight:
            for x in range(0, 30):
                bot.click(747, 486, 5)
                if (x%10==0):
                    bot.moveTo(670,480)
                    time.sleep(0.05)
                    bot.dragTo(840,486,0.05)
                    time.sleep(0.05)
                if (x%4==0):
                    bot.click(180, 602, 10)
        while not(flag_should_fight):
            time.sleep(1)
            global flag_is_fighting
            flag_is_fighting = False
Beispiel #4
0
    def take_images(self):
        for point in self.points:
            (x, y) = [float(x) for x in point.split()]
            bot.moveTo(x, y)
            for exposure in self.exposures:
                (self.led, self.current, duration) = exposure.split()
                self.current = float(self.current)
                duration = float(duration)

                def expose_command():
                    adc = ccob.fireLED(self.led, self.current, duration)
                    return {"CCOBADC": adc}

                for i in range(self.imcount):
                    self.take_bias_plus_image(duration,
                                              expose_command,
                                              symlink_image_type='%s_%s_%s' %
                                              (self.led, x, y))
Beispiel #5
0
 def take_images(self):
     for point in self.points:
         splittedpoints = point.split()
         x = float(splittedpoints[0])
         y = float(splittedpoints[1])
         try:
             self.locations = LocationSet(",".join(
                 splittedpoints[2].split("_")))
         except:
             self.locations = None
         if not self.noop or self.skip - test_seq_num < self.exposures * self.imcount * (
                 self.bcount + 1):
             bot.moveTo(x, y)
         for exposure in self.exposures:
             exposure = float(exposure) / self.signalpersec
             expose_command = lambda: bot_bench.openShutter(exposure)
             for i in range(self.imcount):
                 self.take_bias_plus_image(
                     exposure,
                     expose_command,
                     symlink_image_type='%03.1f_%03.1f_%03.1f' %
                     (x, y, exposure))
Beispiel #6
0
    def take_images(self):
        for point in self.points:
            (x, y) = [float(x) for x in point.split()]
            bot.moveTo(x, y)
            for exposure in self.exposures:
                (spotexposure, flatexposure) = exposure.split()
                self.spotexposure = float(spotexposure)
                self.flatexposure = float(flatexposure)

                def expose_command():
                    self.set_filter(self.mask)
                    bot_bench.openShutter(self.spotexposure)  # spot mask
                    self.set_filter('empty6')  # empty1 was used for `grid'
                    if self.flatexposure != 0.:
                        bot_bench.openShutter(self.flatexposure)  # flat

                for i in range(self.imcount):
                    self.take_bias_plus_image(
                        self.spotexposure,
                        expose_command,
                        symlink_image_type='%03.1f_%03.1f_FLAT_%s_%03.1f_%03.1f'
                        % (x, y, self.mask, self.spotexposure,
                           self.flatexposure))
Beispiel #7
0
    def mcoc_arena(self):
        while True:
            if (self.reposition_max_wait > 0):
                self.reposition_max_wait -= 1

            img = pyautogui.screenshot()
            if (self.room_check.mcoc_is_room_home(img)):
                setting.printl("room: home")
                # click fight button on home
                bot.click(248, 155)
                time.sleep(0.5)
                self.reset_flag()

            elif (self.room_check.mcoc_is_room_fight(img)):
                self.reset_flag()
                setting.printl("room: home->fight")
                setting.printl("getting versus button")
                versus_button = self.room_check.mcoc_find_buttonversus()

                while (versus_button == False):
                    bot.moveTo(125, 256)
                    time.sleep(0.2)
                    bot.dragTo(383, 280)
                    time.sleep(2)
                    versus_button = self.room_check.mcoc_find_buttonversus()
                    if not self.room_check.mcoc_is_room_fight():
                        break
                if self.room_check.mcoc_is_room_fight():
                    setting.printl("found versusbutton")
                    time.sleep(0.2)
                    bot.click(versus_button)
                    time.sleep(0.5)

            elif (self.room_check.mcoc_is_room_versus(img)):
                self.reset_flag()
                setting.printl("room: home->fight->versus")
                versus_target = self.mcoc_get_buttonarenatarget()
                while (versus_target == False):
                    bot.moveTo(125, 284)
                    time.sleep(0.2)
                    bot.dragTo(356, 240)
                    time.sleep(2)
                    versus_target = self.mcoc_get_buttonarenatarget()
                    if not self.room_check.mcoc_is_room_versus():
                        break
                if self.room_check.mcoc_is_room_versus():
                    setting.printl("found target")
                    time.sleep(0.2)
                    bot.click(versus_target)
                    time.sleep(0.5)

            elif (self.room_check.mcoc_is_room_versus_findmatch(img)):
                self.reset_flag()
                setting.printl(
                    "room: home->fight->versus->findmatch select champ")

                time.sleep(2 + random.random())
                helpbt = self.room_check.mcoc_find_buttonversus_findmatchhelp()
                while helpbt:
                    time.sleep(2 + random.random())
                    bot.click(helpbt)
                    time.sleep(2 + random.random())
                    helpbt = self.room_check.mcoc_find_buttonversus_findmatchhelp(
                    )

                bot.moveTo(286, 225)
                time.sleep(0.3)
                bot.dragTo(156, 154)
                time.sleep(1)
                findmatch_bt = self.room_check.mcoc_is_room_versus_findmatch()
                if (findmatch_bt):
                    bot.click(findmatch_bt)

            elif (self.room_check.mcoc_is_fighting(img)):
                self.reset_flag()
                setting.printl("room: FIGHTING")
                while self.room_check.mcoc_is_fighting():
                    for x in range(0, 10):
                        bot.click(640, 326, 5)
                        time.sleep(0.3 + random.random() / 4)
                    time.sleep(random.random())
                    bot.click(178, 400, 10)
                setting.printl("done fighting")

                while (not (self.room_check.mcoc_is_loading())
                       and self.room_check.window_is_ready()
                       and not (self.room_check.mcoc_is_fighting_paused())):
                    bot.click(559, 326, 50)
                    time.sleep(random.random() / 4)

            elif (self.room_check.mcoc_is_loading(img)):
                self.reset_flag()
                setting.printl("room: loading")

                while self.room_check.mcoc_is_loading():
                    time.sleep(0.5)

            elif (self.room_check.mcoc_is_fighting_paused(img)):
                self.reset_flag()
                setting.printl("room: FIGHTING paused")
                resumebt = self.room_check.mcoc_is_fighting_paused()
                if resumebt:
                    bot.click(resumebt)
                    time.sleep(0.3)

            elif (self.room_check.mcoc_is_fighting_recovered(img)):
                self.reset_flag()
                setting.printl("room: FIGHTING recovered")
                resumebt = self.room_check.mcoc_is_fighting_recovered()
                if resumebt:
                    bot.click(resumebt)
                    time.sleep(0.3)

            elif (self.room_check.mcoc_is_popup(img)):
                self.reset_flag()
                setting.printl("room: there's popup")
                time.sleep(1)
                popupbt = self.room_check.mcoc_is_popup()
                bot.click(popupbt)

            elif (self.room_check.mcoc_is_session_offline(img)):
                self.reset_flag()
                setting.printl("room: lost connection")
                bot.click(cx(396), cy(305))
                time.sleep(3)

            elif (self.room_check.vysor_is_ads(img)):
                self.reset_flag()
                setting.printl("room: vysor ads")
                bot.click(self.room_check.vysor_is_ads())

            else:
                placed = self.room_check.window_reposition()
                if placed == "onplace":
                    self.reposition_max_wait += 2
                    setting.printl("reposition wait: {}".format(
                        self.reposition_max_wait))
                    if self.reposition_max_wait >= 10:

                        homebt = self.room_check.vysor_find_buttonhome()
                        if homebt != None:
                            bot.click(homebt)
                            time.sleep(1)
                            bot.click(homebt)
                            time.sleep(0.5)
                            bot.click(298, 149)
                            time.sleep(3)
                            self.reposition_max_wait = 0
                time.sleep(0.3)
Beispiel #8
0
    def mcoc_quest(self):
        room = self.room_check
        while True:

            img = room.get_grab(region=(0, 0, 470 * 2, 109 * 2))
            while room.quest_isin_fight(img):
                print("fight")
                # ~ self.last_fight_scrot = img
                for x in range(0, 30):
                    bot.doubleClick(747, 486, 5)
                    if (x % 2 == 0):
                        bot.moveTo(600, 480)
                        bot.dragTo(780, 486, 0.2)
                    if (x % 3 == 0):
                        bot.click(180, 602, 10)
                img = room.get_grab(region=(0, 0, 470 * 2, 109 * 2))

            img = room.get_grab()
            if room.quest_isin_postfight(img):
                print("post fight")
                bot.click(180, 602, 10)
                time.sleep(1)

            elif room.quest_portal(img):
                print("portal")
                # only 1 option, or already selected: teleport button is clickable
                if room.is_color_similar(img.getpixel((664 * 2, 431 * 2)),
                                         [45, 128, 0], 10):
                    bot.click(710, 358)
                    time.sleep(1)
                    bot.click(664, 431)
                elif room.quest_portal_is_ready(img):
                    print("teleport ready")
                    bot.click(room.last_coord)

                elif room.quest_portal_get_options_count(img) == 2:
                    print("2 options")
                    self.quest_next_node_select([
                        [700, 380 + 60 * 0],
                        [700, 380 + 60 * 1],
                    ])

            elif room.quest_isin_quest(img):
                print("is in quest")
                coord_next_node = room.quest_get_nextnode(img)
                tries = 0
                while not (coord_next_node) and tries < 3:
                    coord_next_node = room.quest_get_nextnode()
                    tries += 1

                if not coord_next_node:
                    continue

                #make sure target is clickable node
                i = 0
                while i < len(coord_next_node):
                    print(coord_next_node)
                    c = coord_next_node[i]

                    x0 = 2 * (c[0] - 5)
                    y0 = 2 * (c[1] - 5)
                    x1 = 2 * (c[0] + 5)
                    y1 = 2 * (c[1] + 5)
                    comparator = []  #if comparator is the same
                    max_score = 3
                    score = max_score
                    for x in range(0, max_score):
                        node = room.get_grab(region=(x0, y0, x1, y0))
                        p = node.getpixel((3, 3))
                        if p == comparator:
                            score -= 1
                        else:
                            break
                        comparator = p
                        # ~ print(c, node.getpixel((5,5)), sep="    :    ")
                    if score < 1:
                        print("invalid ", c)
                        coord_next_node.pop(i)
                    else:
                        i += 1
                self.quest_next_node_select(coord_next_node)

            elif room.quest_isin_prefight(img):
                print("quest prefight")
                bot.click(727, 612)

            elif room.quest_complete(img):
                print("quest dialog")
                bot.click(room.last_coord)

            elif room.quest_isin_questdialog(img):
                print("quest dialog")
                print("isin quest or popup? ")
                inquest = room.quest_isin_quest()
                print(inquest)
                if inquest:
                    continue
                if room.is_popup():
                    bot.click(room.last_coord)
                    continue
                bot.click(433, 624)
                time.sleep(2)
            elif room.is_popup(img):
                print("popup")
                bot.click(room.last_coord)

            elif room.quest_playnextbutton(img):
                print("next button click in 5s")
                time.sleep(5)
                bot.click(room.last_coord)
Beispiel #9
0
    def quest_next_node_select(self, coord_next_node):

        if len(coord_next_node) > 1:
            if (type(self.map_antiduplicate_lastcoord) == list
                    and abs(coord_next_node[0][0] -
                            self.map_antiduplicate_lastcoord[0][0]) < 20
                    and abs(coord_next_node[0][1] -
                            self.map_antiduplicate_lastcoord[0][1]) < 20
                    and abs(coord_next_node[1][0] -
                            self.map_antiduplicate_lastcoord[1][0]) < 20
                    and abs(coord_next_node[1][1] -
                            self.map_antiduplicate_lastcoord[1][1]) < 20):
                self.redo_limit += 1
                if self.redo_limit > 5:
                    print("too many redo, pick other")
                    if self.map_antiduplicate_lastcoord_picked != 0:
                        self.map_antiduplicate_lastcoord_picked = 0
                    else:
                        self.map_antiduplicate_lastcoord_picked = 1
                print("redo pick: auto")
                pick = self.map_antiduplicate_lastcoord_picked
                print(pick)
                bot.click(coord_next_node[pick][0], coord_next_node[pick][1])
                time.sleep(0.5)
                bot.click(coord_next_node[pick][0], coord_next_node[pick][1])
                return False

            self.redo_limit = 0
            self.map[self.map_current_pos] = {}
            i = 0
            for coord in coord_next_node:
                new_pos_key = self.map_current_pos + ":" + str(i)
                self.map[new_pos_key] = coord
                self.map[self.map_current_pos][i] = new_pos_key

                print(i, ":", coord)
                bot.moveTo(coord[0], coord[1])
                time.sleep(2)
                i += 1
            save_map(self.map)
            print("which one to pick?")
            pick = input()
            try:
                pick = int(pick)
            except:
                print("invalid input, pick 0")
                pick = 0

            self.map_current_pos = self.map[self.map_current_pos][pick]
            self.map["map_current_pos"] = self.map_current_pos
            save_map(self.map)
            print(self.map)
            self.map_antiduplicate_lastcoord = coord_next_node
            self.map_antiduplicate_lastcoord_picked = pick

            bot.click(coord_next_node[pick][0], coord_next_node[pick][1])
            time.sleep(0.5)
            bot.click(coord_next_node[pick][0], coord_next_node[pick][1])

        else:
            try:
                bot.click(coord_next_node[0][0], coord_next_node[0][1])
            except:
                pass
Beispiel #10
0
    def mcoc_quest(self):
        global flag_should_fight
        global flag_is_fighting
        room = self.room_check
        while True:
            img = room.get_grab(region=(445*2,87*2,470*2,109*2))
            
            while room.quest_isin_fight_focus(img):
                printlog("fight")
                if not(flag_is_fighting):
                    flag_should_fight = True
                    flag_is_fighting = True
                    print("ordering to fight")


                img = room.get_grab(region=(445*2,87*2,470*2,109*2))
                # ~ printlog(time.time()-room.last_room_time)
                if (time.time()-room.last_room_time>300):
                    printlog("reset Nox")
                    bot.click(15,42)
                    time.sleep(0.5)
                    bot.click(15,42)
                    time.sleep(3)
                    bot.click(360,370)
                    time.sleep(10)
                    bot.click(81,1120)
                    pyautogui.doubleClick(81,1120)
                    # ~ time.sleep(0.1)
                    # ~ time.sleep(0.1)
                    # ~ bot.click(81,1120)
                    time.sleep(5)
                    bot.click(868,293)
                    time.sleep(1)
                    pyautogui.hotkey('ctrl','option','command','1')
                    room.last_room_time = time.time()
                    img = room.get_grab()
                    flag_should_fight = False
                    flag_is_fighting = False
                    break
                    
            flag_should_fight = False
            flag_is_fighting = False
            
            img = room.get_grab()

            if room.quest_isin_postfight(img):
                printlog("post fight")
                bot.click(180, 602, 10)
                bot.click(727, 613, 10)
                time.sleep(1)
            
            elif room.is_champion_info(img):
                printlog("chamption info")
                bot.click(room.last_coord)
                time.sleep(2)
                
            elif room.arena_rearrangeteam(img):
                print("rearrange team")
                
                self.wait_until_true_or_timeout(room.is_continuebutton,10)
                
                img = room.get_grab()
                
                skill = [187,21,21]
                cosmic = [4,135,172]
                science = [72,144,25]
                tech = [11,72,161]
                mystic = [145,34,154]
                mutant = [160,128,27]
                
                class_pool = {
                    "skill":skill,
                    "cosmic":cosmic,
                    "science":science,
                    "tech":tech,
                    "mystic":mystic,
                    "mutant":mutant
                }
                
                champ = [0]*6
                # index 0~2 ours, 3~5 enemy
                img = room.get_grab(rescale=False)
                champ[0] = room.color_average_area( (590,606    ,590+40,606+40    ), [30,35,35], img)
                champ[1] = room.color_average_area( (590,606+160,590+40,606+40+160), [30,35,35], img )
                champ[2] = room.color_average_area( (590,606+320,590+40,606+40+320), [30,35,35], img )
                
                champ[3] = room.color_average_area( (590+654,606+26    ,590+654+40,606+26+40    ), [30,35,35], img )
                champ[4] = room.color_average_area( (590+654,606+26+160,590+654+40,606+26+40+160), [30,35,35], img )
                champ[5] = room.color_average_area( (590+654,606+26+320,590+654+40,606+26+40+320), [30,35,35], img )
                
                champ_class = []
                for c in champ:
                    found_class = False
                    for key in class_pool:
                        if room.is_color_similar(c, class_pool[key], 15):
                            print(key)
                            champ_class.append(key)
                            found_class = True
                            break
                    if not found_class:
                        print("unknown: {}".format(c))
                        champ_class.append("unknown{}".format(c))
                # sort each
                team_class = champ_class[:3]
                enemy_class = champ_class[3:]
                team_class.sort()
                enemy_class.sort()
                # join as code
                rearrange_code = " ".join(team_class + enemy_class)
                
                try:
                    solution = setting.class_selection_pool[rearrange_code]
                    printlog("solution: {}".format(solution))
                    enemy_class_unsorted = champ_class[3:]
                    team_class_unsorted = champ_class[:3]
                    
                    for key in solution:
                        target_enemy = solution[key]
                        team_pos = team_class_unsorted.index(key)
                        if team_pos<0:
                            break
                        for enemy_pos in range(0,3):
                            if enemy_class_unsorted[enemy_pos]==target_enemy:
                                printlog("{} vs {}".format( team_class_unsorted[team_pos], target_enemy))
                                printlog("drag {} to {}".format(team_pos, enemy_pos))
                                
                                if team_pos!=enemy_pos:
                                    time.sleep(1)
                                    bot.moveTo(282,285+80*team_pos)
                                    bot.dragTo(282,285+80*enemy_pos,drag_time=1.5)
                                    time.sleep(1)
                                #team class position has been modified
                                # ~ temp = team_class_unsorted[team_pos]
                                team_class_unsorted[team_pos] = team_class_unsorted[enemy_pos]
                                team_class_unsorted[enemy_pos] = "occupied"
                                
                                enemy_class_unsorted[enemy_pos] = "occupied"
                                break
                    
                    
                except KeyError:
                    printlog("solution for {} is not exists".format(rearrange_code))
                    self.solution_unsolved[rearrange_code] = 0
                    with open("solution_unsolved.txt", "a+") as f:
                        f.write("{}\n".format(self.solution_unsolved))
                    # check 1
                    m = setting.coord_multiplier
                    for i in range(0,3):
                        time.sleep(0.5)
                        ok = True
                        if room.is_color_dominant( img.getpixel( (int(m*756/2),int(m*(764-162)/2)) ), "r" ):
                            print("1 is red")
                            bot.moveTo(282,285+80*0)
                            bot.dragTo(282,285+80*1)
                            time.sleep(0.5)
                            ok = False
                        img = room.get_grab()
                        if room.is_color_dominant( img.getpixel( (int(m*756/2),int(m*(764)/2)) ), "r" ):
                            print("2 is red")
                            bot.moveTo(282,285+80*1)
                            bot.dragTo(282,285+80*2)
                            time.sleep(0.5)
                            ok = False
                        img = room.get_grab()
                        if room.is_color_dominant( img.getpixel( (int(m*756/2),int(m*(764+162)/2)) ), "r" ):
                            print("3 is red")
                            bot.moveTo(282,285+80*2)
                            bot.dragTo(282,285+80*0)
                            ok = False
                        if ok:
                            break
                
                print("OK")
                bot.click(768,613)
                
            
            elif room.arena_2nd(img):
                printlog("arena select, found")
                # bot.click(442,592)
                bot.click(833,592)


                #3rd
                # bot.moveTo(833,300)
                # time.sleep(1)
                # bot.dragTo(100,300)
                # time.sleep(1)
                # bot.click(440,577)

            
            elif room.arena_champselect_helpneeded(img):
                printlog("need help")
                while (room.arena_champselect_helpneeded()):
                    printlog("help needed")
                    bot.click(291,280,1)
                    time.sleep(2)
                
            elif room.arena_champselect(img):
                printlog("arena champ select")

                bot.click(576,430) #KO
                time.sleep(0.5)
                bot.click(576,540) #victory
                time.sleep(0.5)
                bot.click(792,630)
                time.sleep(2)
                # ~ if room.arena_champselect_multiplier1():                    
                # ~ printlog("manual belum x3")
                # ~ x = input()
                # ~ if x=="":
                    # ~ printlog("manually")
                    # ~ continue
                if room.arena_champselect_notmultiplier3(img):
                    print("not multiplier 3")
                    bot.click(801,596)#filter menu
                    time.sleep(1)
                    bot.click(801,596)#filter menu
                    time.sleep(1)
                    bot.click(679,165) #reset
                    time.sleep(1)
                    bot.click(679,165)#reset
                    time.sleep(1)
                    bot.click(801,620) #filter tab
                    time.sleep(1)
                    bot.dragTo(800,120) #drag
                    time.sleep(1)
                    # bot.click(727,443)#2*
                    bot.click(727,483)#3*
                    bot.click(727,523)#4*
                    time.sleep(1)
                    for x in range(0,2): #drag time
                        bot.moveTo(430,600)
                        time.sleep(0.2)
                        bot.dragTo(430,80,drag_time=0.2)
                        time.sleep(0.2)
                else:
                    printlog("possibly multiplier 3")
                start = time.time()
                while room.arena_champselect(img) and room.arena_champselect_champempty(img) and (time.time()-start)<30:
                    bot.moveTo(363,357)
                    bot.dragTo(207,344)
                    time.sleep(2)
                    img = room.get_grab()
                start = time.time()
                while room.arena_champselect(img) and not(room.arena_champselect_champempty(img)) and (time.time()-start)<30:
                    bot.click(159,618)
                    time.sleep(0.5)
                    img = room.get_grab()
                    
                    
            elif room.arena_enemyselect(img):
                printlog("enemy select")
                time.sleep(2)
                if room.is_color_dominant(img.getpixel((512*2,488*2)), "g"):
                    bot.click(512,488)
                elif room.is_color_dominant(img.getpixel((519*2,341*2)), "g"):
                    bot.click(519,341)
                time.sleep(2)
                bot.click(758,616)
                
                
            elif room.is_continuebutton(img):
                printlog("continue button shows up")
                if (room.arena_rearrangeteam()):
                    printlog("but in rearrange team")
                    continue
                bot.click(room.last_coord)
                time.sleep(0.5)
                bot.click(792,630)
                time.sleep(2)
            
            elif room.arena_betweenfight(img):
                printlog("continue button between fight")
                # bot.click(room.last_coord)
                # time.sleep(0.5)
                bot.click(576,430) #KO
                time.sleep(0.5)
                bot.click(576,540) #victory
                time.sleep(0.5)
                bot.click(792,630)
                time.sleep(2)
            
            
            elif room.is_popup(img):
                printlog("popup")
                # ~ bot.click(room.last_coord)
                # ~ time.sleep(1)
                bot.click(822,85)
            
            elif room.is_reconnect(img):
                printlog("reconnect")
                time.sleep(3)
                if room.is_reconnect():
                    print("wait 30 min then reconnect")
                    time.sleep(60*30)
                    bot.click(room.last_coord)
            
            elif room.mcoc_fightrecovered(img):
                printlog("fight recovered")
                bot.click(room.last_coord)
            
            
            elif room.mcoc_fightbutton(img):
                printlog("fight button shown")
                bot.click(room.last_coord)
                while room.mcoc_fightbutton():
                    bot.click(room.last_coord)
                    time.sleep(1)
                bot.moveTo(71,352)
                bot.dragTo(1800,360)
                time.sleep(3)
                
            
            elif room.mcoc_fightroom_arenashown(img):
                printlog("versus arena shown")
                bot.click(room.last_coord)
            
            elif room.mcoc_fightroom(img):
                printlog("home -> fight")
                bot.moveTo(71,352)
                bot.dragTo(1800,360)
                time.sleep(3)
            
            elif room.android_home(img):
                printlog("android in home")
                bot.click(room.last_coord)
            
            elif room.last_room!=None:
                room.last_room = None
                room.last_room_time = time.time()
            else:
                printlog("failed for {}".format(time.time() - room.last_room_time))
                if (time.time()-room.last_room_time)>500:
                    printlog("reset Nox")
                    bot.click(15,42)
                    time.sleep(0.5)
                    bot.click(15,42)
                    time.sleep(3)
                    bot.click(360,370)
                    time.sleep(10)
                    bot.click(81,1120)
                    pyautogui.doubleClick(81,1120)
                    # ~ time.sleep(0.1)
                    # ~ time.sleep(0.1)
                    # ~ bot.click(81,1120)
                    time.sleep(5)
                    bot.click(868,293)
                    time.sleep(1)
                    pyautogui.hotkey('ctrl','option','command','1')
                    room.last_room_time = time.time()