Initial Commit
This commit is contained in:
54
##More Basic testing for fishing.py
Normal file
54
##More Basic testing for fishing.py
Normal file
@@ -0,0 +1,54 @@
|
||||
##More Basic testing for fishing
|
||||
import pyautogui as pag
|
||||
from random import randint, uniform
|
||||
import cv2
|
||||
import numpy
|
||||
import math
|
||||
import time
|
||||
import sys
|
||||
|
||||
class FishBot(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def random_coordinate(self, location):
|
||||
#Moves cursor to random locaction still above the object to be clicked
|
||||
x = randint(location[0], location[0]+location[2])
|
||||
y = randint(location[1], location[1]+location[3])
|
||||
time = self.travel_time(x, y)
|
||||
|
||||
return pag.moveTo(x, y, time)
|
||||
|
||||
|
||||
def fishLoop(self):
|
||||
#check if inventory is full
|
||||
pag.screenshot('Images/shrimp.png', region=(1575, 1689, 305, 411))
|
||||
screen = cv2.imread('Images/shrimp.png')
|
||||
template = cv2.imread('Images/fullinv.png')
|
||||
res = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
|
||||
threshold = .80
|
||||
loc = numpy.where(res >= threshold)
|
||||
if len(loc[0]) > 0:
|
||||
invResult = True
|
||||
|
||||
else:
|
||||
invResult = False
|
||||
#Move to Random Coordinate where shrimps are
|
||||
##need to add some variance, misses clicks, doesn't move in a
|
||||
###straight line too fast
|
||||
#Shrimp location
|
||||
location1 = (580, 1954, 60, 60)
|
||||
|
||||
#Now add a little variance to the x and y coordinates
|
||||
##The location is in a tuple, these are immutable so it must be converted into a list to be changed
|
||||
###Then converted back
|
||||
locationList = list(location1)
|
||||
modifiedx = randint(0,35)
|
||||
modifiedy = randint(0,35)
|
||||
locationList[0] = locationList[0] + modifiedx
|
||||
print (locationList)
|
||||
locationList[1] = locationList[1] + modifiedy
|
||||
modifiedLocation = tuple(locationList)
|
||||
pag.moveTo(modifiedLocation, 2)
|
||||
pag.click()
|
||||
self.random_wait(0.05, 0.1)
|
||||
Reference in New Issue
Block a user