# 自动塔 # 使用方法 python ./tower.py 30 # 输入参为战斗时间(秒) import sys import game import win32_helper if len(sys.argv) != 2: print('format: python ./tower.py 战斗时间') exit() hWnd = win32_helper.find_window_handle('MuMu', None, None) hWnd = win32_helper.find_first_child_window(hWnd) op_delay = 3 i = 0 while True: print('\nloop {0}'.format(i)) i += 1 win32_helper.send_key_to_window(hWnd, win32_helper.VK_Y) win32_helper.wait(op_delay) if game.has_select_box(hWnd): game.press_button_cancel(hWnd) continue game.battle(hWnd, battle_cost_times=int(sys.argv[1])) win32_helper.wait(14.5 * 60)
# 判断是否失败 if not is_win(): win32_helper.wait(battle_end_delay) print('lost the battle!') return True # 点击略过 while not game.press_button_skip(hWnd): win32_helper.wait(op_delay) win32_helper.wait(op_delay) # 点击确认 win32_helper.wait(battle_end_delay) while not game.press_button_reward_check(hWnd): win32_helper.wait(op_delay) # 若没有奖励, 跳出 if game.has_mainui_sign(hWnd): print('No reward') break return True if __name__ == "__main__": handle = win32_helper.find_window_handle('MuMu', None, None) handle = win32_helper.find_first_child_window(handle) battle(handle, 10000) pass