mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
1ae645294d
gui - enable "Debug > Keep Console" to unhide full auto - Removed Log Dump from Debug menu semi-auto - starting ai fix, sometime bot doesnt start - minimize bug fix, when minimized gui goes out of sync - keyboard button to pause play, now bot can be paused and played using f9 - now shows running as admin message - better error message, now tells to check #read-me-first instead full-auto - add tesseract binary in directory - install addon for full auto
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
class FishingMode:
|
|
"""
|
|
State machine for fishing modes
|
|
|
|
HValues hue values for each fishing mode
|
|
CurrentCount number of times same hue color is read before it changes state
|
|
CurrentMode current mode of the state machine
|
|
PrevMode previous mode of the state machine
|
|
FishingStarted probably does nothing (not sure though)
|
|
Modes list of states
|
|
"""
|
|
HValues = [60, 18, 100]
|
|
|
|
CurrentMode = None
|
|
PrevMode = None
|
|
|
|
Modes = []
|
|
|
|
def __init__(self, name, label, event):
|
|
"""
|
|
create a new state
|
|
:param name: name of the state
|
|
:param label: integer, label of the state (int)
|
|
:param event: object of class containing onEnterCallback & onExitCallback functions
|
|
which are called when state is changed
|
|
"""
|
|
self.name = name
|
|
self.label = label
|
|
self.event = event
|
|
|
|
FishingMode.Modes.append(self)
|
|
|
|
@staticmethod
|
|
def get_by_label(label):
|
|
"""
|
|
find a state using label
|
|
:param label: label integer
|
|
:return: state
|
|
"""
|
|
for m in FishingMode.Modes:
|
|
if m.label == label:
|
|
return m
|
|
|
|
@staticmethod
|
|
def loop(hue_values):
|
|
"""
|
|
Executed in the start of the main loop in fishy.py
|
|
Changes modes, calls mode events (callbacks) when mode is changed
|
|
|
|
:param hue_values: hue_values read by the bot
|
|
"""
|
|
if FishingMode.PrevMode is None:
|
|
FishingMode.PrevMode = FishingMode.get_by_label(3)
|
|
|
|
current_label = 3
|
|
for i, val in enumerate(FishingMode.HValues):
|
|
if hue_values == val:
|
|
current_label = i
|
|
|
|
FishingMode.CurrentMode = FishingMode.get_by_label(current_label)
|
|
|
|
if FishingMode.CurrentMode != FishingMode.PrevMode:
|
|
|
|
if FishingMode.PrevMode.event is not None:
|
|
FishingMode.PrevMode.event.on_exit_callback(FishingMode.CurrentMode)
|
|
|
|
if FishingMode.CurrentMode.event is not None:
|
|
FishingMode.CurrentMode.event.on_enter_callback(FishingMode.PrevMode)
|
|
|
|
FishingMode.PrevMode = FishingMode.CurrentMode
|