1 Star 4 Fork 4

Q/WoW_Fishing_Bot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fishing_util.py 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
Q 提交于 2020-05-05 08:17 . init
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dion_sun/WoW_Fishing_Bot.git
git@gitee.com:dion_sun/WoW_Fishing_Bot.git
dion_sun
WoW_Fishing_Bot
WoW_Fishing_Bot
master

搜索帮助