def apple_feed(): time.sleep(1.5) Flag,Position = Base_func.match_template('AP_recover') if Flag: Flag,Position = Base_func.match_template('Silver_apple') if Flag: Serial.touch(709,Position[1]) time.sleep(1.5) Flag,Position = Base_func.match_template('Feedapple_decide') Serial.touch(Position[0],Position[1]) print(' Feed silver apple success') else: Flag,Position = Base_func.match_template('Gold_apple') if Flag: Serial.touch(709,Position[1]) time.sleep(1.5) Flag,Position = Base_func.match_template('Feedapple_decide') Serial.touch(Position[0],Position[1]) print(' Feed gold apple success') else: print(' No apple remain') Serial.touch(0,0) sys.exit(0) else: print(' No need to feed apple')
def card(Baoju_no=1): Serial.send(950, 510) #点击attack按钮 Serial.wait_for_flag() time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') i = 0 while Flag: i += 1 if i > 3: print(' 发卡失败,需人工处理') Serial.send(0, 0) Serial.wait_for_flag() exit() time.sleep(2) Serial.send(950, 510) #如没有进入选卡界面再次点击attack按钮 Serial.wait_for_flag() Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') Serial.send(340 + (Baoju_no - 1) * 200, 170) #打手宝具,参数可选1-3号宝具位 Serial.wait_for_flag() Serial.send(340 + (Baoju_no - 1) * 200, 430) #随便两张牌,先选宝具下面那张 Serial.wait_for_flag() Serial.send(540, 430) #默认选中间的牌 Serial.wait_for_flag() print(' Card has pressed')
def quit_battle(): global num_Craft time.sleep(15) while True: time.sleep(1) Flag, Position = Base_func.match_template('Battlefinish_sign') if Flag: break Flag, Position = Base_func.match_template('Attack_button') if Flag: break Flag, Position = Base_func.match_template('Attack_button') if Flag: print(' 翻车,进入补刀程序') #翻车检测 #Serial.mouse_set_zero() #sent_message(text='【FGO】: Encounter a battle error.') budao() print(' Battle finished') time.sleep(1) Flag, Position = Base_func.match_template('Rainbow_box') #检测是否掉礼装,若掉落则短信提醒 if Flag: sent_message() num_Craft += 1 Serial.touch(986, 565, 6) Serial.touch(235, 525, 2) #拒绝好友申请 Serial.mouse_set_zero() #鼠标复位,防止误差累积 print(' Quit success') time.sleep(1)
def quit_battle(): time.sleep(15) while True: time.sleep(1) Flag,Position = Base_func.match_template('Battlefinish_sign') if Flag: break Flag,Position = Base_func.match_template('Master_face') if Flag: break Flag,Position = Base_func.match_template('Master_face') if Flag: print(' 翻车,需要人工处理') #翻车检测 Serial.mouse_set_zero() sent_message(text='【FGO】: Encounter a battle error.') sys.exit(0) print(' Battle finished') time.sleep(1) Flag,Position = Base_func.match_template('Rainbow_box') #检测是否掉礼装,若掉落则短信提醒 if Flag: sent_message() Serial.touch(986,565,6) Serial.touch(235,525,2) #拒绝好友申请 Serial.mouse_set_zero() #鼠标复位,防止误差累积 print(' Quit success') time.sleep(1)
def find_friend(servant): Current_state.WaitForFriendShowReady() Flag,Position = Base_func.match_template(servant+'_skill_level',False,0.9) time_limit_flag = 1 #找310CBA直到找到为止 while bool(1-Flag): print(' Didn\'t find {}, retry. Attempt{}'.format(servant,time_limit_flag)) if time_limit_flag>1: time.sleep(15) #Flag,Position = Base_func.match_template('Refresh_friend') Serial.touch(710,110) time.sleep(1.5) Flag,Position = Base_func.match_template('Refresh_decide') Serial.touch(Position[0],Position[1]) Current_state.WaitForFriendShowReady() Flag,Position = Base_func.match_template(servant+'_skill_level',False,0.9) time_limit_flag+=1 if Flag: print(' Success find',servant) Serial.touch(Position[0],Position[1]-60) time.sleep(1.5) Serial.touch(1005,570) print(' Start battle button pressed')
def HasBackToMenu(self): Flag,Position = Base_func.match_template('Menu_button') while bool(1-Flag): time.sleep(1) Flag,Position = Base_func.match_template('Menu_button') if Flag: break Flag,Position = Base_func.match_template('reenter_battle') if Flag: break
def WaitForFriendShowReady(self): Flag,Position = Base_func.match_template('friend_sign') while bool(1-Flag): time.sleep(1) Flag,Position = Base_func.match_template('friend_sign') if Flag: break Flag,Position = Base_func.match_template('no_friend') if Flag: break
def GetAvailableSkillIndex(): img = Base_func.window_capture() AvailableSkillIndex = [] for Servant_no in range(3): AvailableSkillIndex.append(DetectAvailableSkill(img, Servant_no)) return AvailableSkillIndex
def enter_battle(): Current_state.HasBackToMenu() #确认已经返回菜单界面 Flag, Position = Base_func.match_template('LastOrder_sign') if Flag: Serial.touch(Position[0] + 230, Position[1] + 50) print(' ') print(' Enter battle success') else: print(' Enter battle fail')
def enter_battle(): Current_state.HasBackToMenu() #确认已经返回菜单界面,或检测到连续出击按键 Flag,Position = Base_func.match_template('reenter_battle') if Flag: Serial.touch(705,475) print(' ') print(' Reenter battle success') return Flag,Position = Base_func.match_template('LastOrder_sign') if Flag: Serial.touch(Position[0]+230,Position[1]+50) print(' ') print(' Enter battle success') else: Serial.touch(791,155) print(' ') print(' Enter battle by clicking the default position')
def GetAvailableTreasureDevice(): img = Base_func.window_capture() AvailableTreasureDeviceList = [] for i in range(3): Flag = DetectTreasureDevice(img, i) if Flag == True: AvailableTreasureDeviceList.append(i + 1) return AvailableTreasureDeviceList
def budao(): while True: while True: time.sleep(1) Flag, Position = Base_func.match_template('Battlefinish_sign') if Flag: break Flag, Position = Base_func.match_template('Attack_button') if Flag: break Flag, Position = Base_func.match_template('Attack_button') if Flag: Serial.touch(960, 510) #点击attack按钮 time.sleep(1) Card_index = random.sample(range(0, 4), 3) #随机三张牌 Serial.touch(115 + (Card_index[0]) * 215, 430) Serial.touch(115 + (Card_index[1]) * 215, 430) Serial.touch(115 + (Card_index[2]) * 215, 430) print(' Card has pressed') else: break
def enter_battle(): Current_state.HasBackToMenu() #确认已经返回菜单界面 Flag, Position = Base_func.match_template('LastOrder_sign', err=0.85) if Flag: Serial.touch(Position[0] + 230, Position[1] + 50) print(' ') print(' Enter battle success') else: Serial.touch(791, 155) print(' ') print(' Enter battle by clicking the default position')
def config2battle(): Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') while bool(1 - Flag): time.sleep(2) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') #Turn1 Config.Config2Command(Config.df1) time.sleep(5) #等待战斗动画播放完成 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') while bool(1 - Flag): time.sleep(2) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') #Turn2 Config.Config2Command(Config.df2) time.sleep(5) #等待战斗动画播放完成 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') while bool(1 - Flag): time.sleep(2) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') #Tun3 Config.Config2Command(Config.df3)
def GetCardIndex(): img = Base_func.window_capture() CardIndex = [] for Card_no in range(5): Flag, CardColor = DetectCardColor(img, Card_no) if Flag == True: CardIndex.append(CardColor) else: CardIndex.append('None') return CardIndex
def quit_battle(): time.sleep(15) while True: time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Battlefinish_sign.jpg') if Flag: break Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') if Flag: break #检测到战斗结束标志或御主的脸时跳出循环 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') if Flag: for i in range(3): playsound('F:/FGO_Project/11750.mp3') print(' 翻车,需要人工处理') #翻车检测,系统三声报警 Serial.send(0, 0) Serial.wait_for_flag() exit() print(' battle finished') Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Next_step.jpg') Serial.send(936, 571) #一直点,直到发现“下一步”的按钮 Serial.wait_for_flag() while bool(1 - Flag): time.sleep(2) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Next_step.jpg') if Flag: Serial.send(Position[0], Position[1]) Serial.wait_for_flag() else: Serial.send(936, 571) Serial.wait_for_flag() #time.sleep(7) print(' quit success')
def apple_feed(): #喂苹果,先银后金 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/AP_recover.jpg') if Flag: Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Silver_apple.jpg') if Flag: Serial.send(709, Position[1]) Serial.wait_for_flag() Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Feedapple_decide.jpg') Serial.send(Position[0], Position[1]) Serial.wait_for_flag() print(' feed silver apple success') return Flag else: Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Gold_apple.jpg') if Flag: Serial.send(709, Position[1]) Serial.wait_for_flag() Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Feedapple_decide.jpg') Serial.send(Position[0], Position[1]) Serial.wait_for_flag() print(' feed gold apple success') return Flag else: print(' no apple remain') Serial.send(0, 0) Serial.wait_for_flag() exit() return Flag else: print(' no need to feed apple')
def battle(): #判断是否进入战斗界面 time.sleep(10) #等待战斗开始 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') #Turn1 character_skill(1, 1) character_skill(2, 1, 1) character_skill(2, 3, 1) character_skill(3, 1, 1) card() time.sleep(10) #等待战斗动画播放完成 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') #Turn2 character_skill(3, 2) character_skill(3, 3, 1) Master_skill(3) character_skill(3, 3) card(3) time.sleep(10) #等待战斗动画播放完成 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Master_face.jpg') #Tun3 character_skill(1, 2) character_skill(1, 3) character_skill(3, 3) Master_skill(1) card()
def enter_battle(template='F:/FGO_Project/Template/LastOrder_sign.jpg'): Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Menu_button.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Menu_button.jpg') #不停检测菜单按键,确认已经返回菜单界面 Flag, Position = Base_func.match_template(template) if bool(1 - Flag): Serial.send(1060, 480) #如果没有找到,点一下滚动条 Serial.wait_for_flag() i = 1 while bool(1 - Flag): i += 1 time.sleep(2) Flag, Position = Base_func.match_template(template) if i > 3: k = input('未找到上次执行关卡,需人工操作,按0退出执行:') if k == 0: Serial.send(0, 0) Serial.wait_for_flag() exit() if Flag: Serial.send(Position[0] + 230, Position[1] + 50) #加一点偏移量,保证点在关卡图标上 Serial.wait_for_flag() Flag, Position = Base_func.match_template(template) while Flag: time.sleep(2) Flag, Position = Base_func.match_template(template) print(' ') print(' enter battle success') return Flag else: print(' enter battle fail') return Flag
def HasBackToMenu(self): Flag, Position = Base_func.match_template('Menu_button') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template('Menu_button')
def WaitForBattleStart(self): Flag,Position = Base_func.match_template('Attack_button') while bool(1-Flag): time.sleep(1) Flag,Position = Base_func.match_template('Attack_button')
def find_friend(): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Caster_sign.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Caster_sign.jpg') #检测到滚动条说明好友已经刷出 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/friend_sign.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/friend_sign.jpg') Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/CBA_skill_level.jpg') time_limit_flag = 1 #找310CBA直到找到为止 while bool(1 - Flag): print(' didn\'t find CBA, retry. attempt{}'.format(time_limit_flag)) if time_limit_flag > 1: time.sleep(15) #如果不是第一次刷新,等待15秒 #Flag,Position = Base_func.match_template('F:/FGO_Project/Template/Refresh_friend.jpg') Serial.send(720, 110) Serial.wait_for_flag() Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Refresh_decide.jpg') Serial.send(Position[0], Position[1]) Serial.wait_for_flag() Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/friend_signal.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/friend_signal.jpg') if time_limit_flag > 4: k = input(' 5次刷新未找到CBA,需人工操作,按0退出执行:') if k == 0: Serial.send(0, 0) Serial.wait_for_flag() exit() Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/CBA_skill_level.jpg') time_limit_flag += 1 if Flag: print(' success find CBA') Serial.send(Position[0], Position[1] - 50) Serial.wait_for_flag() #识别“开始任务”按钮 Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Start_button.jpg') while bool(1 - Flag): time.sleep(1) Flag, Position = Base_func.match_template( 'F:/FGO_Project/Template/Start_button.jpg') Serial.send(Position[0], Position[1]) Serial.wait_for_flag() print(' Start battle button pressed')