Esempio n. 1
0
def rotate_cam_zoom_to(dev, poco, node_path, log_out=False):
    path_event_reward = 'H_Canvas/USER_Main_UI/EVENT_REVARD'
    pos_from = pos_scr2abs(dev, [0.5, 0.1])

    f_exit = False
    i = 0
    while not f_exit:
        pos_scr = [0, 0.2]
        # pos_abs = pos_scr2abs(dev, pos_scr)

        if wait_for_node_visible(poco, path_event_reward, 1).exists():
            out('event_reward')
            return True

        node_case_lod = wait_for_node_visible(poco, node_path)
        if node_case_lod.exists():
            if log_out:
                out(node_path + ' exists...')
            pos_scr = pos_center(dev, node_case_lod, False)
            # pos_abs = pos_scr2abs(dev, pos_scr)

        step = 0.1

        if pos_scr[0] > 0.48 and pos_scr[0] < 0.52:
            step = 0.0
            f_exit = True

        if pos_scr[0] < 0.48 or pos_scr[0] > 0.52:
            step = 0.01
        if pos_scr[0] < 0.40 or pos_scr[0] > 0.60:
            step = 0.02
        if pos_scr[0] < 0.30 or pos_scr[0] > 0.70:
            step = 0.05

        print('position:' + str(pos_scr))

        if pos_scr[0] > 0.5:
            swipe(pos_from, vector=[step, 0], duration=1)
            if log_out:
                out('swipe to left on ' + str(step))
        if pos_scr[0] < 0.5:
            swipe(pos_from, vector=[-step, 0], duration=1)
            if log_out:
                out('swipe to right on ' + str(step))
        i += 1
        if i > 30:
            if log_out:
                out('долгое ожидание поворота к обьекту', node_path)
            return False

    out('it: ' + str(i))
    return True
Esempio n. 2
0
def my_swipe(dev, poco, path_root, subpath_from, subpath_to):
    node_root = wait_for_node_visible(poco, path_root)
    if not node_root.exists():
        out('not ready to swipe, can\'t find node', path_root)
        return False

    node_from = get_node_child(node_root, subpath_from)
    if not node_from.exists():
        out('not ready to swipe, can\'t find node',
            path_root + '/' + node_from)
        return False
    pos_from = pos_center(dev, node_from)

    node_to = get_node_child(node_root, subpath_to)
    if not node_to.exists():
        out('not ready to swipe, can\'t find node', path_root + '/' + node_to)
        return False
    pos_to = pos_center(dev, node_to)

    swipe(pos_from, pos_to, duration=2)

    return True
Esempio n. 3
0
def rotate_cam_to(dev, poco, node_path, log_out=False):
    #node_path = 'Rank2(Clone)/MARKER_NEW(Clone)/10-MobileRelationsMark'
    pos_from = pos_scr2abs(dev, [0.5, 0.1])
    
    f_exit = False
    i = 0
    while not f_exit:
        pos_scr = [0,0.2]
        #pos_abs = pos_scr2abs(dev, pos_scr)

        node_case_lod = wait_for_node_visible(poco, node_path)
        if node_case_lod.exists():
            if log_out:
                out(node_path+' exists...')
            pos_scr = pos_center(dev, node_case_lod, False)
            #pos_abs = pos_scr2abs(dev, pos_scr)
        
        step = 0.1

        if pos_scr[0]>0.48 and pos_scr[0]<0.52:
            step = 0.0
            f_exit = True
        
        if pos_scr[0]<0.48 or pos_scr[0]>0.52:
            step = 0.03
        if pos_scr[0]<0.40 or pos_scr[0]>0.60:
            step = 0.05
        if pos_scr[0]<0.30 or pos_scr[0]>0.70:
            step = 0.1
        
        print('position:'+str(pos_scr))
        
        if pos_scr[0] > 0.5:
            swipe(pos_from, vector=[step,0], duration=1)
            if log_out:
                out('swipe to left on '+str(step))
        if pos_scr[0] < 0.5:
            swipe(pos_from, vector=[-step,0], duration=1)
            if log_out:
                out('swipe to right on '+str(step))
        i += 1
        if i>30:
            if log_out:
                out('долгое ожидание поворота к обьекту', node_path)
            return False 
        
        
    out('it: '+str(i))
    return True 
Esempio n. 4
0
def rotate_l_let_to(dev, poco, node_path, log_out=False):
    path_rot_right = 'H_Canvas/USER_Main_UI/CONTROLL_PANEL/ROT_RIGHT'
    pos_abs_right = pos_center(dev,
                               wait_for_node_visible(poco, path_rot_right))

    f_exit = False
    i = 0
    while not f_exit:
        swipe(pos_abs_right, pos_abs_right, duration=2)

        if wait_for_node_visible(poco, node_path, 1).exists():
            out('precision exists')
            f_exit = True
            return True

        i += 1
        if i > 30:
            if log_out:
                out('долгое ожидание поворота к обьекту', node_path)
            return False

    out('it: ' + str(i))
    return True
Esempio n. 5
0
def run_test(dev, poco, big_test=False):
    btn_back = 'H_Canvas/USER_Main_UI/BACK_BUTTON_MOBILE'
    btn_map = 'H_Canvas/USER_Main_UI/SWITCH_TO_MAP/Button_exit'
    # btn_map = 'H_Canvas/USER_Main_UI/MAP_ADDON/SWITCH_TO_WORLD'

    btn_quests_menu = 'H_Canvas/USER_Main_UI/CONFIG/AllButtons/Button_qwest'
    # wnd_quests_menu_lst = 'H_Canvas/USER_Main_UI/CONFIG_QWESTS/AVR_bg_paper/AVR_bg'
    btn_quest_5 = 'H_Canvas/USER_Main_UI/CONFIG_QWESTS/AVR_bg_paper/AVR_bg/A1 (4)'
    btn_quest_6 = 'H_Canvas/USER_Main_UI/CONFIG_QWESTS/AVR_bg_paper/AVR_bg/A1 (5)'
    btn_accept_qst = 'H_Canvas/USER_Main_UI/EVENT_REVARD/Avr_paper/Avr_Accept'
    btn_cancel_qst = 'H_Canvas/USER_Main_UI/EVENT_REVARD/Avr_paper/Avr_Decline'

    wnd_event_reward = 'H_Canvas/USER_Main_UI/EVENT_REVARD'

    ### ---------------------------------------

    if not go_to_academia(dev, poco):
        return False
    time.sleep(1)

    ### ---------------------------------------
    # идем в меню выбора квеста
    # out('нажимаем кнопку квестов')
    if not wait_and_click_button(dev, poco, btn_quests_menu): return False
    # тыкаем первый квест
    if not wait_and_click_button(dev, poco, btn_quest_5): return False
    # тыкаем принять
    if not wait_and_click_button(dev, poco, btn_accept_qst): return False

    # тыкаем 'H_Canvas/USER_Main_UI/CONFIG/AllButtons/Button_equip'
    btn_path = 'H_Canvas/USER_Main_UI/CONFIG/AllButtons/Button_equip'
    if not wait_and_click_button(dev, poco, btn_path): return False
    time.sleep(2)

    # подготавливаемся к свайпу
    sn_item_list = 'H_Canvas/USER_Main_UI/CONFIG_EQUIP_MAIN/'\
        +'ItemsBG/ScrollItems/Viewport/ItemList'
    sn_slot_canon = 'H_Canvas/USER_Main_UI/CONFIG_EQUIP_MAIN/Slots/Canon_1'
    sn_slot_canon_sub = 'H_Canvas/USER_Main_UI/CONFIG_EQUIP_MAIN/Slots/Canon_1/sub_1'
    node_slot = wait_for_node_visible(poco, sn_slot_canon, 5)
    node_slot_sub = wait_for_node_visible(poco, sn_slot_canon_sub, 5)

    # перетаскиваем пушку в слот
    node_item_list = wait_for_node_visible(poco, sn_item_list, 5)
    node_from = node_item_list.child()[0]
    pos_abs_from = pos_center(dev, node_from)
    pos_from = pos_center(dev, node_from, False)
    pos_to = pos_center(dev, node_slot, False)
    vec = [pos_to[0] - pos_from[0], pos_to[1] - pos_from[1]]
    print('vector ', pos_abs_from, vec)
    swipe(pos_abs_from, vector=vec, duration=3)
    time.sleep(1)

    # перетаскиваем улучшение в слот
    node_item_list = wait_for_node_visible(poco, sn_item_list, 5)
    node_from = node_item_list.child()[0]
    pos_abs_from = pos_center(dev, node_from)
    pos_from = pos_center(dev, node_from, False)
    pos_to = pos_center(dev, node_slot_sub, False)
    vec = [pos_to[0] - pos_from[0], pos_to[1] - pos_from[1]]
    print('vector ', pos_abs_from, vec)
    swipe(pos_abs_from, vector=vec, duration=3)
    time.sleep(1)

    # выходим из окна улучшений
    if not wait_and_click_button(dev, poco, btn_back): return False

    time.sleep(2)

    # сообщение "вот ваша награда"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', '"вот ваша награда"')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False

    if big_test:
        # идем в меню выбора квеста
        if not wait_and_click_button(dev, poco, btn_quests_menu): return False
        # тыкаем третий квест
        if not wait_and_click_button(dev, poco, btn_quest_6): return False
        # тыкаем отменить
        if not wait_and_click_button(dev, poco, btn_cancel_qst): return False
        # тыкаем назад из меню квестов
        if not wait_and_click_button(dev, poco, btn_back): return False
    ### ---------------------------------------

    out('нажимаем кнопку выхода из города на карту')
    node = wait_for_node_visible(poco, btn_map, 5)
    if not node.exists():
        out('Button not showed', btn_map)
        return False
    touch_center(dev, node)
    time.sleep(1)

    return True
Esempio n. 6
0
def run_test_tutorial_2(dev, poco, big_test=False):
    btn_back = 'H_Canvas/USER_Main_UI/BACK_BUTTON_MOBILE'
    btn_map = 'H_Canvas/USER_Main_UI/SWITCH_TO_MAP/Button_exit'
    # btn_map = 'H_Canvas/USER_Main_UI/MAP_ADDON/SWITCH_TO_WORLD'
    
    btn_quests_menu = 'H_Canvas/USER_Main_UI/CONFIG/AllButtons/Button_qwest'
    # wnd_quests_menu_lst = 'H_Canvas/USER_Main_UI/CONFIG_QWESTS/AVR_bg_paper/AVR_bg'
    btn_quest_2 = 'H_Canvas/USER_Main_UI/CONFIG_QWESTS/AVR_bg_paper/AVR_bg/A1 (1)'
    btn_quest_3 = 'H_Canvas/USER_Main_UI/CONFIG_QWESTS/AVR_bg_paper/AVR_bg/A1 (2)'
    btn_accept_qst = 'H_Canvas/USER_Main_UI/EVENT_REVARD/Avr_paper/Avr_Accept'
    btn_cancel_qst = 'H_Canvas/USER_Main_UI/EVENT_REVARD/Avr_paper/Avr_Decline'

    wnd_event_reward = 'H_Canvas/USER_Main_UI/EVENT_REVARD'
    
    ### ---------------------------------------   
    
    if not go_to_academia(dev, poco):
        return False
    time.sleep(1)

    ### ---------------------------------------   
    # идем в меню выбора квеста
    # out('нажимаем кнопку квестов')
    if not wait_and_click_button(dev, poco, btn_quests_menu): return False
    # тыкаем первый квест
    if not wait_and_click_button(dev, poco, btn_quest_2): return False
    # тыкаем принять
    if not wait_and_click_button(dev, poco, btn_accept_qst): return False
    
    # тыкаем 'H_Canvas/USER_Main_UI/CONFIG/AllButtons/Button_team'
    btn_team = 'H_Canvas/USER_Main_UI/CONFIG/AllButtons/Button_team'
    if not wait_and_click_button(dev, poco, btn_team): return False
    
    # сообщение "Сначала наймем команду"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', 'нет сообщения "Сначала наймем команду"')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False

    # тыкаем 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/TeamManageShipMobile/ScrollingPanel/TavernButton'
    btn_tavern = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/ScrollingPanel/TavernButton'
    if not wait_and_click_button(dev, poco, btn_tavern): return False

    # сообщение "Найми 7 салаг."
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', 'нет сообщения "Найми 7 салаг."')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False

    # тыкаем 7 раз на салагу "+" 
    # 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/TeamManageShipMobile/ScrollingPanel/TavernButton'
    btn_crewman_hire_0 = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageTavernMobile/TavernBgImage/Crewman_Hire_0/ActionButton'
    i = 7
    while i > 0:
        if not wait_and_click_button(dev, poco, btn_crewman_hire_0): return False
        i -= 1
    # тыкаем кнопку назад
    if not wait_and_click_button(dev, poco, btn_back): return False
        
    # сообщение "перетащите 2х матросов на паруса"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', 'перетащите 2х матросов на паруса')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False        
        
    # подготавливаемся к свайпам
    sn_tmp = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/ScrollingPanel/ShipDecks'
    sn_parus = 'ParuDeck/CrewmanDeck_Paru_3'
    sn_aboard = 'AboardDeck/CrewmanDeck_Aboard_3'
    sn_cannon = 'CanonDeck/CrewmanDeck_Canon_3'
    sn_from = 'AboardDeck/CrewmanDeck_Aboard_0'

    node_tmp = wait_for_node_visible(poco, sn_tmp, 5)
    pos_parus = get_node_child(node_tmp, sn_parus).attr('pos')
    pos_aboard = get_node_child(node_tmp, sn_aboard).attr('pos')
    pos_cannon = get_node_child(node_tmp, sn_cannon).attr('pos')
    
    pos_abs_from = pos_center(dev, get_node_child(node_tmp, sn_from))
    
    # перетаскиваем 2х матросов на паруса
    vec = [0, pos_parus[1] - pos_aboard[1]]
    print('vector ', pos_abs_from, vec)
    swipe(pos_abs_from, vector=vec, duration=3)
    sleep(1)
    swipe(pos_abs_from, vector=vec, duration=3)
    sleep(1)

    # сообщение "перетащите 2х матросов на паруса"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', 'перетащите 2х матросов на пушки')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False        

    # перетаскиваем 2х матросов на пушки
    vec = [0, pos_cannon[1] - pos_aboard[1]]
    print('vector ', pos_abs_from, vec)
    swipe(pos_abs_from, vector=vec, duration=3)
    sleep(1)
    swipe(pos_abs_from, vector=vec, duration=3)
    sleep(1)

    # сообщение "больше матросов на палубе, больше эффективность"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', 'больше матросов на палубе, больше эффективность')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False        

    # тыкаем на кнопку "Раненые" 
    btn_med = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/ScrollingPanel/MedbayButton'
    if not wait_and_click_button(dev, poco, btn_med): return False

    # тыкаем на кнопку "лечить матроса" 
    btn_med = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/ScrollingPanel/ShipDecks/'\
        +'Medbay/Crewman_Wounded_1/ActionButton'
    if not wait_and_click_button(dev, poco, btn_med): return False

    # сообщение "про офицеров, выбрать"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', 'про офицеров, выбрать')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False        

    # тыкаем на кнопку "слот офицера 1" 
    btn_med = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/ScrollingPanel/RightPanel/'\
        +'DeckStats_Paru/BorderImage/OfficerSlotsPanel/OfficerSlot1'
    if not wait_and_click_button(dev, poco, btn_med): return False
    
    # тыкаем на кнопку "боцман" 
    btn_med = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/OfficersWindow/BgImage/'\
        +'BorderImage/SlotsPanel/OfficerSlot1'
    if not wait_and_click_button(dev, poco, btn_med): return False

    # тыкаем на кнопку "назначить" 
    btn_med = 'H_Canvas/USER_Main_UI/CONFIG_TEAM_MOBILE/'\
        +'TeamManageShipMobile/OfficersWindow/BgImage/'\
        +'BorderImage/ActionButton(Clone)'
    if not wait_and_click_button(dev, poco, btn_med): return False

    time.sleep(2);

    # сообщение "вот ваша награда"
    node = wait_for_node_visible(poco, wnd_event_reward, 5)
    if not node.exists():
        out('долгое ожидание сообщения', '"вот ваша награда"')
        return False
    if not wait_and_click_button(dev, poco, btn_back): return False        
    
    if big_test:
        # идем в меню выбора квеста
        if not wait_and_click_button(dev, poco, btn_quests_menu): return False
        # тыкаем третий квест
        if not wait_and_click_button(dev, poco, btn_quest_3): return False
        # тыкаем отменить
        if not wait_and_click_button(dev, poco, btn_cancel_qst): return False
        # тыкаем назад из меню квестов
        if not wait_and_click_button(dev, poco, btn_back): return False
    ### ---------------------------------------    
        
    out('нажимаем кнопку выхода из города на карту')
    node = wait_for_node_visible(poco, btn_map, 5)
    if not node.exists():
        out('Button not showed', btn_map)
        return False
    touch_center(dev, node)
    time.sleep(1)

    return True