2020-04-15 11:27:26 +00:00
|
|
|
"""Fishy
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
fishy.py -h | --help
|
|
|
|
fishy.py -v | --version
|
2020-04-16 23:14:33 +00:00
|
|
|
fishy.py [--debug] [--ip=<ipv4>] [--collect-r] [--borderless]
|
2020-04-15 11:27:26 +00:00
|
|
|
|
|
|
|
Options:
|
|
|
|
-h, --help Show this screen.
|
|
|
|
-v, --version Show version.
|
|
|
|
--ip=<ipv4> Local Ip Address of the android phone.
|
|
|
|
--debug Start program in debug controls.
|
|
|
|
--borderless Use if the game is in fullscreen or borderless window
|
|
|
|
"""
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
import cv2
|
|
|
|
|
|
|
|
from docopt import docopt
|
|
|
|
from pynput.keyboard import Listener
|
|
|
|
|
2020-04-16 23:14:33 +00:00
|
|
|
from fishy.systems import *
|
2020-04-15 11:27:26 +00:00
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
Start reading from `init.py`
|
|
|
|
"""
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2020-04-15 11:27:26 +00:00
|
|
|
|
2018-05-03 16:37:18 +00:00
|
|
|
def on_release(key):
|
2019-02-05 09:33:59 +00:00
|
|
|
"""
|
2019-06-29 20:35:53 +00:00
|
|
|
Reads input, finds out the resultant action and performs it
|
|
|
|
|
|
|
|
:param key: key pressed
|
2019-02-05 09:33:59 +00:00
|
|
|
"""
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2019-02-15 13:44:49 +00:00
|
|
|
c = Control.find(key)
|
|
|
|
if c is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
if c[0] == Control.Keywords.StartPause:
|
2019-02-16 11:32:20 +00:00
|
|
|
|
|
|
|
if not G.pause:
|
2018-05-03 16:37:18 +00:00
|
|
|
print("PAUSED")
|
2019-02-16 11:32:20 +00:00
|
|
|
G.pause = True
|
|
|
|
return
|
|
|
|
|
|
|
|
if PixelLoc.config():
|
2018-05-03 16:37:18 +00:00
|
|
|
print("STARTED")
|
2019-02-16 11:32:20 +00:00
|
|
|
G.pause = False
|
|
|
|
else:
|
2019-11-13 11:58:45 +00:00
|
|
|
print("addon properly not installed, if it is installed try restarting the game.")
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2019-02-15 13:44:49 +00:00
|
|
|
elif c[0] == Control.Keywords.Debug:
|
2019-02-07 22:03:28 +00:00
|
|
|
G.debug = not G.debug
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2019-02-15 13:44:49 +00:00
|
|
|
elif c[0] == Control.Keywords.Stop:
|
2019-02-07 22:03:28 +00:00
|
|
|
G.stop = True
|
2019-02-05 15:18:20 +00:00
|
|
|
|
2019-02-15 13:44:49 +00:00
|
|
|
elif c[0] == Control.Keywords.SwitchMode:
|
|
|
|
Control.nextState()
|
|
|
|
Log.ctrl()
|
|
|
|
|
|
|
|
elif c[0] == Control.Keywords.ClearPrintOnce:
|
|
|
|
Log.clearPrintIds()
|
|
|
|
|
|
|
|
|
|
|
|
def hsv2rgb(img):
|
|
|
|
return cv2.cvtColor(img, cv2.COLOR_HSV2RGB)
|
|
|
|
|
2019-02-05 09:33:59 +00:00
|
|
|
|
2018-05-03 16:37:18 +00:00
|
|
|
def startFishing():
|
2019-02-05 09:33:59 +00:00
|
|
|
"""
|
2019-06-29 20:35:53 +00:00
|
|
|
Starts the fishing
|
|
|
|
code explained in comments in detail
|
2019-02-05 09:33:59 +00:00
|
|
|
"""
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2020-04-15 11:27:26 +00:00
|
|
|
Control.current = 1 if G.arguments["--debug"] else 0
|
|
|
|
|
|
|
|
use_net = G.arguments["--ip"] is not None
|
2019-02-07 22:03:28 +00:00
|
|
|
if use_net:
|
2020-04-15 11:27:26 +00:00
|
|
|
net.initialize(G.arguments["--ip"])
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2020-04-16 23:14:33 +00:00
|
|
|
sleepFor = 1
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
# initializes fishing modes and their callbacks
|
2019-02-07 22:03:28 +00:00
|
|
|
FishingMode("hook", 0, HookEvent())
|
|
|
|
FishingMode("stick", 1, StickEvent())
|
|
|
|
FishingMode("look", 2, LookEvent())
|
|
|
|
FishingMode("idle", 3, IdleEvent(use_net))
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2019-02-07 22:03:28 +00:00
|
|
|
Log.ctrl()
|
2019-02-15 13:44:49 +00:00
|
|
|
|
2019-02-16 11:32:20 +00:00
|
|
|
fishPixWindow = Window(color=cv2.COLOR_RGB2HSV)
|
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
# initialize widow
|
2019-02-16 11:32:20 +00:00
|
|
|
Window.Init()
|
2019-02-07 22:03:28 +00:00
|
|
|
with Listener(on_release=on_release):
|
|
|
|
while not G.stop:
|
2019-06-29 20:35:53 +00:00
|
|
|
# record the time to calculate time taken to execute one loop
|
2019-02-15 13:44:49 +00:00
|
|
|
current_time = time.time()
|
2019-06-29 20:35:53 +00:00
|
|
|
|
|
|
|
# Services to be ran in the start of the main loop
|
2019-02-07 22:03:28 +00:00
|
|
|
Window.Loop()
|
|
|
|
Log.Loop()
|
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
# get the PixelLoc and find the color values, to give it to `FishingMode.Loop`
|
2019-02-16 11:32:20 +00:00
|
|
|
fishPixWindow.crop = PixelLoc.val
|
2019-02-07 22:03:28 +00:00
|
|
|
hueValue = fishPixWindow.getCapture()[0][0][0]
|
|
|
|
FishingMode.Loop(hueValue, G.pause)
|
2019-02-15 13:44:49 +00:00
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
# if debug is on, show the color on the PixelLoc in a window and print the hue values of it
|
2019-02-15 13:44:49 +00:00
|
|
|
if G.debug:
|
2019-02-16 11:32:20 +00:00
|
|
|
fishPixWindow.show("pixloc", resize=200, func=hsv2rgb)
|
|
|
|
Log.ou(str(FishingMode.CurrentMode.label) + ":" + str(fishPixWindow.getCapture()[0][0]))
|
2019-02-07 22:03:28 +00:00
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
# Services to be ran in the end of the main loop
|
2019-02-07 22:03:28 +00:00
|
|
|
Log.LoopEnd()
|
|
|
|
Window.LoopEnd()
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
# calculate the time it took to execute one loop of code, if it is more than the expected time warn user
|
2019-02-15 13:44:49 +00:00
|
|
|
frameTime = time.time() - current_time
|
|
|
|
if frameTime < sleepFor:
|
|
|
|
time.sleep(sleepFor - frameTime)
|
2019-02-16 11:32:20 +00:00
|
|
|
else:
|
|
|
|
Log.po(231, "Program taking more time than expected, this might slow your computer try increasing "
|
|
|
|
"\"--check-frequency\".")
|
2019-02-15 13:44:49 +00:00
|
|
|
|
2018-05-03 16:37:18 +00:00
|
|
|
|
2020-04-15 11:27:26 +00:00
|
|
|
def main():
|
|
|
|
G.arguments = docopt(__doc__)
|
|
|
|
if G.arguments["--version"]:
|
|
|
|
quit()
|
|
|
|
|
2019-02-05 09:33:59 +00:00
|
|
|
startFishing()
|
2020-04-15 11:27:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|