GeMercher.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:RunescapeBots 作者: lukegarbutt 项目源码 文件源码
def sell_items(runescape_window, ge_slot, record_number_selling=False):
    # click correct sell bag
    move_mouse_to_image_within_region('Tools/screenshots/sell_bag.png', ge_slot)
    pyautogui.click()
    wait_for('Tools/screenshots/quantity_box.png', runescape_window)
    # click item in inv
    coords_of_item = pointfrombox.random_point((runescape_window.bottom_right_corner[0]-180, runescape_window.bottom_right_corner[1]-372), (runescape_window.bottom_right_corner[0]-166, runescape_window.bottom_right_corner[1]-349))
    realmouse.move_mouse_to(coords_of_item[0], coords_of_item[1])
    pyautogui.click()
    # click all button incase
    move_mouse_to_image_within_region("Tools/screenshots/all_button.png", runescape_window)
    pyautogui.click()
    # recording number selling if needed
    if record_number_selling:
        try:
            time.sleep(1+random.random())
            loc_of_all_button = pyautogui.locateOnScreen('Tools/screenshots/All_button.png', region=(runescape_window.top_left_corner[0], runescape_window.top_left_corner[1], runescape_window.bottom_right_corner[0]-runescape_window.top_left_corner[0], runescape_window.bottom_right_corner[1]-runescape_window.top_left_corner[1]))
            number_selling_image = screengrab_as_numpy_array((loc_of_all_button[0]-100,loc_of_all_button[1]-27,loc_of_all_button[0]-3,loc_of_all_button[1]-12))
            quantity = tesser_quantity_image(number_selling_image)
            runescape_window.update_money(runescape_window.money+((ge_slot.item.quantity_to_buy-quantity)*ge_slot.item.price_instant_sold_at))
            print('About to update the quantity to buy to {}'.format(quantity))
            ge_slot.item.set_quantity_to_buy(quantity)
        except:
            print("Couldn't read the quantity bought correctly so setting score to invalid to prevent artificial high scores, money for the window may now be wrong too, we think there is {}gp in this window available".format(runescape_window.money))
            ge_slot.item.set_score_invalid()
    # click price button
    coords_of_price_box = pointfrombox.random_point((runescape_window.bottom_right_corner[0]-384, runescape_window.bottom_right_corner[1]-272), (runescape_window.bottom_right_corner[0]-291, runescape_window.bottom_right_corner[1]-259))
    realmouse.move_mouse_to(coords_of_price_box[0], coords_of_price_box[1])
    pyautogui.click()
    time.sleep(2+random.random())
    # type price in and hit enter
    random_typer(str(ge_slot.item.price_instant_bought_at))
    pyautogui.press('enter')
    # click confirm
    move_mouse_to_image_within_region("Tools/screenshots/confirm_offer_button.png", runescape_window)
    pyautogui.click()
    # update state of ge slot
    ge_slot.update_buy_or_sell_state('sell')
    wait_for('Tools/screenshots/lent_item_box.png', runescape_window)
    runescape_window.set_time_of_last_action()
    print('Placed a sell order for {} {} at {} each'.format(ge_slot.item.quantity_to_buy, ge_slot.item.item_name, ge_slot.item.price_instant_bought_at))
    time.sleep(2+random.random())
    ge_slot.set_image_of_slot()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号