def check_for_currency(curr_item): # move cursor to first item slot in inventory 1300, 615 gui.moveTo(TOP_LEFT_INVENTORY_COORDS) # sleep 0.1 second to allow item text to appear t.sleep(0.1) # take a screenshot of the currency item description img = screenshot(CURRENCY_DESCRIPTION_COORDS) # colors the currency image item name to white color_text(img, CURRENCY_ITEM_COLOR, WHITE_COLOR) # perform adjustments img = image_adjustments(img) #inventory_img = screenshot(top_left_inventory_coords) #inventory_img = image_adjustments(inventory_img) # parse the image for text currency_text = [] for i in range(len(img)): currency_text.append(pytesseract.image_to_string(img[i], lang='eng', \ config = '--psm 12')\ .lower()) return (search_text(curr_item, currency_text))
def check_stash_tabs(): gui.moveTo(TOP_LEFT_CORNER) parsed_text = [] for i in range(len(TAB_BOARDER_COORDS)): img = screenshot(TAB_BOARDER_COORDS[i]) img = color_text(img, STASH_YELLOW_TEXT, YELLOW_TEXT) img = color_text(img, STASH_BLACK_TEXT, BLACK_TEXT) img = image_adjustments(img) for j in range(len(img)): parsed_text.append(pytesseract.image_to_string(img[j], lang='eng', config = '--psm 12').lower()) return(parsed_text)
def check_for_text(text, coords): gui.moveTo(TOP_LEFT_CORNER) img = screenshot(coords) img = color_text(img, STASH_BLACK_TEXT, BLACK_TEXT) img = color_text(img, STASH_YELLOW_TEXT, YELLOW_TEXT) img = image_adjustments(img) parsed_text = [] for i in range(len(img)): parsed_text.append(pytesseract.image_to_string(img[i], lang='eng', config = '--psm 12').lower()) text_found = 0 #print(mod) for i in range(len(parsed_text)): if bool(re.search(text, parsed_text[i])): text_found += 1 # if mod found is greater than 0, mod is found so return -1 to stop rolling # mod found = 0, return 1 which indicates continue to roll if text_found > 0: return(-1) else: return(1)
# blue RGB values for magic a item blue_value = ((135, 135, 254), (98, 98, 188), (99, 99, 189), (74, 73, 142),\ (74, 74, 142), (73, 73, 141), (127, 127, 239), (81, 81, 155),\ (98, 98, 162), (108, 108, 178), (96, 96, 182), (125, 125, 233),\ (108, 108, 181), (97, 97, 184), (123, 123, 233),(109, 109, 207)) # create a list containing the words we're looking for in the image currency_items = ['orb of alteration', 'chaos orb', 'orb of scouring', \ 'orb of transmutation', 'regal orb'] coords = (52,133,586,158) img = screenshot(coords) img = color_text(img, STASH_BLACK_TEXT, BLACK_TEXT) img = color_text(img, STASH_YELLOW_TEXT, YELLOW_TEXT) img = image_adjustments(img) parsed_text = [] for i in range(len(img)): parsed_text.append(pytesseract.image_to_string(img[i], lang='eng', config = '--psm 12').lower()) parsed_text img_set = img.getdata()
def check_for_mod(mod): # moves to item coords gui.moveTo(ITEM_IN_STASH_COORDS) # Realized mod type is in name, dont need to parse alt text # holds down alt to display indepth item text #gui.keyDown('alt') # sleep 0.1 second to allow item text to appear t.sleep(0.1) # screenshot stash coords img = screenshot(ENTIRE_STASH_COORDS) # sleep 0.1 second to allow item text to appear t.sleep(0.1) # left off alt #gui.keyUp('alt') # adjust image colors, turn blue white img = color_text(img, BLUE_COLOR, WHITE_COLOR) #img = color_text(img, GREY_COLOR, WHITE_COLOR) # resize image img = image_adjustments(img) # parse the text from each imageand a create a list of strings from each images parsed_text_list = [] for i in range(len(img)): parsed_text_list.append( pytesseract.image_to_string(img[i], lang='eng', config='--psm 12').lower()) # parsed_text_list[1].split('\n') return (search_text(mod, parsed_text_list)) # mod_found = 0 # for i in range(len(parsed_text)): # if bool(re.search(mod, parsed_text[i])): # mod_found += 1 # # if mod found is greater than 0, mod is found so return -1 to stop rolling # # mod found = 0, return 1 which indicates continue to roll # if mod_found > 0: # return(-1) # else: # return(1) # checks for the desired mod on the item being rolled #def check_for_text(text, coords): # #gui.moveTo(ITEM_IN_STASH_COORDS) # # img = screenshot(coords) # img = color_text(img, STASH_BLACK_TEXT, BLACK_TEXT) # img = color_text(img, STASH_YELLOW_TEXT, YELLOW_TEXT) # img = image_adjustments(img) # # parsed_text = [] # for i in range(len(img)): # parsed_text.append(pytesseract.image_to_string(img[i], lang='eng', # config = '--psm 12').lower()) # # text_found = 0 # #print(mod) # for i in range(len(parsed_text)): # if bool(re.search(text, parsed_text[i])): # text_found += 1 # # if mod found is greater than 0, mod is found so return -1 to stop rolling # # mod found = 0, return 1 which indicates continue to roll # if text_found > 0: # return(-1) # else: # return(1)