fishyboteso/fishy/engine/semifisher/fishing_mode.py

41 lines
784 B
Python
Raw Normal View History

2021-05-07 12:13:55 +00:00
from enum import Enum
subscribers = []
2021-05-07 12:13:55 +00:00
class State(Enum):
IDLE = 0
LOOKAWAY = 1
LOOKING = 2
DEPLETED = 3
NOBAIT = 5
FISHING = 6
REELIN = 7
LOOT = 8
INVFULL = 9
FIGHT = 14
DEAD = 15
2021-05-09 09:09:26 +00:00
def _notify(event):
for subscriber in subscribers:
subscriber(event)
class FishingMode:
2021-05-07 12:13:55 +00:00
CurrentMode = State.IDLE
PrevMode = State.IDLE
def loop(state_num: int):
"""
Executed in the start of the main loop in fishy.py
Changes modes, calls mode events (callbacks) when mode is changed
"""
FishingMode.CurrentMode = State(state_num)
if FishingMode.CurrentMode != FishingMode.PrevMode:
_notify(FishingMode.CurrentMode)
FishingMode.PrevMode = FishingMode.CurrentMode