fishyboteso/fishy/engine/semifisher/fishing_mode.py

46 lines
1.0 KiB
Python
Raw Normal View History

2021-03-14 21:16:49 +00:00
import time
from enum import Enum
subscribers = []
class State(Enum):
2021-03-14 21:16:49 +00:00
IDLE = [ 0, 0, 255]
LOOKAWAY = [150, 255, 76]
LOOKING = [100, 255, 101]
DEPLETED = [ 30, 255, 76]
2021-03-28 15:33:09 +00:00
NOBAIT = [ 96, 255, 255]
2021-03-14 21:16:49 +00:00
FISHING = [ 18, 165, 213]
REELIN = [ 60, 255, 204]
LOOT = [ 0, 255, 204]
2021-03-28 15:33:09 +00:00
INVFULL = [ 0, 255, 51]
2021-03-14 21:16:49 +00:00
FIGHT = [120, 255, 204]
2021-04-12 16:34:02 +00:00
DEAD = [ 0, 0, 51]
def _notify(event):
for subscriber in subscribers:
subscriber(event)
class FishingMode:
CurrentMode = State.IDLE
PrevMode = State.IDLE
2021-03-14 21:16:49 +00:00
def loop(hsv):
"""
Executed in the start of the main loop in fishy.py
Changes modes, calls mode events (callbacks) when mode is changed
2021-03-14 21:16:49 +00:00
:param hsv: hsv read by the bot
"""
FishingMode.CurrentMode = State.IDLE
for s in State:
2021-03-14 21:16:49 +00:00
if all(hsv == s.value):
FishingMode.CurrentMode = s
if FishingMode.CurrentMode != FishingMode.PrevMode:
_notify(FishingMode.CurrentMode)
FishingMode.PrevMode = FishingMode.CurrentMode