def afterDuelNext(): pos = img_search.pos_rel2abs(DUEL_END_NEXT_POS) for _ in range(DUEL_END_NEXT_MAX_TIMES): if img_search.duelEndNextFlag(): clickRandomPos((pos[0] + 2, pos[1] + 2), 86, 16) delay.random_float_delay(0.3, 0.2) return temp_pos = img_search.pos_rel2abs(SKIP_DUEL_ANIMATION_POS) clickRandomPos((temp_pos[0] + 10, temp_pos[1] + 10), 30, 30) delay.random_float_delay(0.5, 0.2) # retry too much times raise img_search.ButtonNotFoundException("duel end next flag")
def endDuel(): pos = img_search.pos_rel2abs(DUEL_END_POS) clickRandomPos((pos[0] + 2, pos[1] + 2), 81, 16) delay.random_float_delay(0.3, 0.5) afterDuelNext() afterDuelNext() afterDuelActivityNext()
def summonMonster(): selectMonster() for _ in range(SUMMON_MONSTER_MAX_TIMES): if not img_search.monsterSelected(): return pos = img_search.pos_rel2abs(SUMMON_MONSTER_POS) clickRandomPos((pos[0] + 2, pos[1] + 2), 26, 26) delay.random_float_delay(0.6, 0.2) raise img_search.ButtonNotFoundException("monster summoned flag")
def openGate(): pos = img_search.pos_rel2abs(GATE_POS) for _ in range(WAIT_FOR_GATE_MAX_TIMES): if img_search.isGateOpen(): return clickRandomPos((pos[0] + 5, pos[1] + 5), 30, 30) delay.random_float_delay(1.0, 0.2) # retry too much times raise img_search.ButtonNotFoundException("gate open flag")
def selectMonster(): # randomly select monster card for _ in range(SELECT_CARD_MAX_TIMES): if img_search.monsterSelected(): return pos = img_search.pos_rel2abs(SELECT_CARD_POS) clickRandomPos((pos[0] + 5, pos[1] + 2), 170, 40) delay.random_float_delay(0.5, 0.2) raise img_search.ButtonNotFoundException("monster selected flag")
def skipDuelAnimation(): pos = img_search.pos_rel2abs(SKIP_DUEL_ANIMATION_POS) for _ in range(SKIP_DUEL_ANIMATION_MAX_TIMES): if img_search.duelAnimationEnd() or img_search.duelEnd(): return clickRandomPos((pos[0] + 10, pos[1] + 10), 30, 30) delay.random_float_delay(0.2, 0.2) # retry too much times raise img_search.ButtonNotFoundException("talking end flag")
def skipTalking(): pos = img_search.pos_rel2abs(SKIP_TALKING_POS) for _ in range(SKIP_TALKING_MAX_TIMES): if img_search.talkingEnd(): return clickRandomPos((pos[0] + 10, pos[1] + 10), 30, 30) delay.random_float_delay(0.2, 0.2) # retry too much times raise img_search.ButtonNotFoundException("talking end flag")
def afterDuelActivityNext(): pos = img_search.pos_rel2abs(AFTER_DUEL_ACTIVITY_NEXT) skip_pos = img_search.pos_rel2abs(SKIP_TALKING_POS) overtime_flag = True for _ in range(AFTER_DUEL_ACTIVITY_CHECK_TIMES): for _ in range(AFTER_DUEL_ACTIVITY_MAX_TIMES): if img_search.afterDuelActivityNextFlag(): overtime_flag = False break clickRandomPos((skip_pos[0] + 5, skip_pos[1] + 5), 40, 40) delay.random_float_delay(0.3, 0.2) if overtime_flag: #raise img_search.ButtonNotFoundException("after duel activity next flag") return for _ in range(AFTER_DUEL_ACTIVITY_MAX_TIMES): if not img_search.afterDuelActivityNextFlag(): return clickRandomPos((pos[0] + 2, pos[1] + 2), 86, 16) delay.random_float_delay(0.3, 0.2)
def allMonsterAttack(): my_monster_seats = img_search.getMyMonsterSeatsList() for my_seat_id in range(len(my_monster_seats)): if my_monster_seats[my_seat_id]: oppo_monster_seats = img_search.getOppoMonsterSeatsList() for oppo_seat_id in range(len(oppo_monster_seats)): if oppo_monster_seats[oppo_seat_id] or oppo_seat_id == 2: # battle pos = img_search.pos_rel2abs( MY_MONSTER_SEATS_POS[my_seat_id]) moveToRandomPos((pos[0] + 27, pos[1] + 32), 15, 20) pyautogui.mouseDown() pos = img_search.pos_rel2abs( OPPO_MONSTER_SEATS_POS[oppo_seat_id]) moveToRandomPos((pos[0] + 27, pos[1] + 32), 15, 20, duration=0.2) pyautogui.mouseUp() skipDuelAnimation() delay.random_float_delay(0.8, 0.2) break
def nextStage(): pos = img_search.pos_rel2abs(NEXT_STAGE_POS) clickRandomPos((pos[0] + 2, pos[1] + 2), 20, 20) delay.random_float_delay(0.5, 0.5) stage_id = img_search.checkStage() if stage_id < 0: raise img_search.ButtonNotFoundException("unknown stage") clickRandomPos((pos[0] + 2, pos[1] + 2), 20, 20) delay.random_float_delay(0.3, 0.5) return stage_id
def reconnect(): pos = img_search.pos_rel2abs(RECONNECT_POS) clickRandomPos((pos[0] + 10, pos[1] + 5), 80, 20) delay.random_float_delay(0.5, 0.2)
def beginGateDuel(): pos = img_search.pos_rel2abs(GATE_DUEL_START_POS) clickRandomPos((pos[0] + 20, pos[1] + 5), 100, 10) delay.random_float_delay(0.5, 0.2)
def selectGateLevel10(): pos = img_search.pos_rel2abs(GATE_LEVEL_10_POS) clickRandomPos((pos[0] + 5, pos[1] + 5), 15, 10) delay.random_float_delay(0.3, 0.2)
def streetToWorkshop(): pos = img_search.pos_rel2abs(WORKSHOP_POS) clickRandomPos((pos[0] + 5, pos[1] + 5), 15, 15) delay.random_float_delay(0.8, 0.2)
def streetToPVP(): pos = img_search.pos_rel2abs(PVP_POS) clickRandomPos((pos[0] + 5, pos[1] + 5), 15, 15) delay.random_float_delay(0.8, 0.2)
def duelReallyBegin(): pos = img_search.pos_rel2abs(DUEL_REALLY_BEGIN_POS) clickRandomPos((pos[0] + 10, pos[1] + 5), 105, 10) delay.random_float_delay(0.8, 0.2)