2019-02-07 22:03:28 +00:00
|
|
|
from fishing_mode import *
|
|
|
|
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
Defines different fishing modes (states) which acts as state for state machine
|
|
|
|
also implements callbacks which is called when states are changed
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
|
|
|
|
class FishEvent(ABC):
|
|
|
|
@abstractmethod
|
|
|
|
def onEnterCallback(self, previousMode):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def onExitCallback(self, currentMode):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class HookEvent(FishEvent):
|
|
|
|
def onEnterCallback(self, previousMode):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
called when the fish hook is detected
|
|
|
|
increases the `fishCaught` and `totalFishCaught`, calculates the time it took to catch
|
|
|
|
presses e to catch the fish
|
|
|
|
|
|
|
|
:param previousMode: previous mode in the state machine
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
G.fishCaught += 1
|
2019-06-19 09:28:18 +00:00
|
|
|
G.totalFishCaught += 1
|
2019-02-07 22:03:28 +00:00
|
|
|
timeToHook = time.time() - G.stickInitTime
|
2019-06-19 09:28:18 +00:00
|
|
|
print("HOOOOOOOOOOOOOOOOOOOOOOOK....... " + str(G.fishCaught) + " caught " + "in " + str(
|
|
|
|
round_float(timeToHook)) + " secs. " + "Total: " + str(G.totalFishCaught))
|
2019-02-07 22:03:28 +00:00
|
|
|
pyautogui.press('e')
|
|
|
|
|
2019-06-19 09:28:18 +00:00
|
|
|
if arguments["--collect-r"]:
|
|
|
|
time.sleep(0.1)
|
|
|
|
pyautogui.press('r')
|
|
|
|
time.sleep(0.1)
|
|
|
|
|
2019-02-07 22:03:28 +00:00
|
|
|
def onExitCallback(self, currentMode):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class LookEvent(FishEvent):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
state when looking on a fishing hole
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
def onEnterCallback(self, previousMode):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
presses e to throw the fishing rod
|
|
|
|
:param previousMode: previous mode in the state machine
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
pyautogui.press('e')
|
|
|
|
|
|
|
|
def onExitCallback(self, currentMode):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class IdleEvent(FishEvent):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
State when the fishing hole is depleted or the bot is doing nothing
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
|
|
|
|
def __init__(self, use_net):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
sets the flag to send notification on phone
|
|
|
|
:param use_net: true if user wants to send notification on phone
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
self.use_net = use_net
|
|
|
|
|
|
|
|
def onEnterCallback(self, previousMode):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
Resets the fishCaught counter and logs a message depending on the previous state
|
|
|
|
:param previousMode: previous mode in the state machine
|
|
|
|
"""
|
|
|
|
|
2019-02-07 22:03:28 +00:00
|
|
|
G.fishCaught = 0
|
|
|
|
if self.use_net:
|
|
|
|
net.sendHoleDeplete(G.fishCaught)
|
|
|
|
|
|
|
|
if previousMode.name == "hook":
|
|
|
|
print("HOLE DEPLETED")
|
|
|
|
elif previousMode.name == "stick":
|
|
|
|
print("FISHING INTERRUPTED")
|
|
|
|
|
|
|
|
def onExitCallback(self, currentMode):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class StickEvent(FishEvent):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
State when fishing is going on
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
|
|
|
|
def onEnterCallback(self, previousMode):
|
2019-06-29 20:35:53 +00:00
|
|
|
"""
|
|
|
|
resets the fishing timer
|
|
|
|
:param previousMode: previous mode in the state machine
|
|
|
|
"""
|
2019-02-07 22:03:28 +00:00
|
|
|
G.stickInitTime = time.time()
|
|
|
|
|
|
|
|
def onExitCallback(self, currentMode):
|
|
|
|
pass
|