代码拉取完成,页面将自动刷新
import pywinauto
from datetime import datetime,timedelta
def cast(coords=None):
''' Casts the fishing pole by clicking the middle mouse button (scrollwheel)
at specified coordinates and returns the time of the cast.
ARGS: (optional) coords (tuple (X,Y))
RETURNS: timestamp (datetime object) '''
timestamp = datetime.now()
pywinauto.mouse.wheel_click((coords if coords else (0,0)))
print(f'Middle Click at {coords if coords else (0,0)}')
return timestamp
def click(coords=None):
''' Clicks the left mouse button at specified coordinates and returns
the time of the click.
ARGS: (optional) coords (tuple (X,Y))
RETURNS: timestamp (datetime object) '''
timestamp = datetime.now()
pywinauto.mouse.click(button='right', coords=(coords if coords else (0,0)))
print(f'right Click at {coords if coords else (0,0)}')
return timestamp
def check_new_cast(new_cast_threshold, last_cast_time, last_coords, current_coords):
''' Checks if more than 3 seconds have passed since the last cast,
and then checks to see if the x coordinate of the bobber is more than
new_cast_threshold away from its previous location.
ARGS: new_cast_threshold (int)
last_cast_time (datetime object)
last_coords (tuple (X,Y))
current_coords (tuple (X,Y))
RETURNS: new_cast (boolean) '''
new_cast = False
# Check if 3 seconds have passed
timestamp = datetime.now()-timedelta(seconds=3)
if last_cast_time < (timestamp):
last_x,last_y = last_coords
new_x,new_y = current_coords
# Check if x coord has changed by more than new_cast_threshold
if last_x > (new_x + new_cast_threshold) or last_x < (new_x - new_cast_threshold):
new_cast = True
return new_cast
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。