diff --git a/fishy/engine/common/window_server.py b/fishy/engine/common/window_server.py index 4b4907b..65170e3 100644 --- a/fishy/engine/common/window_server.py +++ b/fishy/engine/common/window_server.py @@ -60,8 +60,6 @@ def loop(): temp_screen = np.array(ImageGrab.grab(bbox=bbox)) - temp_screen = cv2.cvtColor(temp_screen, cv2.COLOR_BGR2RGB) - rect = win32gui.GetWindowRect(WindowServer.hwnd) crop = ( rect[0] + WindowServer.windowOffset, rect[1] + WindowServer.titleOffset, rect[2] - WindowServer.windowOffset, diff --git a/fishy/engine/semifisher/engine.py b/fishy/engine/semifisher/engine.py index f4d7bb9..b23344c 100644 --- a/fishy/engine/semifisher/engine.py +++ b/fishy/engine/semifisher/engine.py @@ -31,7 +31,7 @@ class SemiFisherEngine(IEngine): code explained in comments in detail """ fishing_event.init() - self.fishPixWindow = WindowClient(color=cv2.COLOR_RGB2HSV) + self.fishPixWindow = WindowClient() # check for game window and stuff self.gui.bot_started(True) diff --git a/fishy/engine/semifisher/fishing_event.py b/fishy/engine/semifisher/fishing_event.py index 895d566..d6dc036 100644 --- a/fishy/engine/semifisher/fishing_event.py +++ b/fishy/engine/semifisher/fishing_event.py @@ -28,7 +28,7 @@ class FishEvent: hole_start_time = 0 FishingStarted = False jitter = False - previousState = State.IDLE + previousState = "IDLE" # initialize these action_key = 'e' @@ -80,33 +80,35 @@ def subscribe(): if fisher_callback not in fishing_mode.subscribers: fishing_mode.subscribers.append(fisher_callback) - if FishingMode.CurrentMode == State.LOOKING: + if FishingMode.CurrentMode == ["LOOKING"]: fisher_callback(FishingMode.CurrentMode) def fisher_callback(event: State): callbacks_map = { - State.IDLE: on_idle, - State.LOOKAWAY: on_lookaway, - State.LOOKING: on_looking, - State.DEPLETED: on_depleted, - State.NOBAIT: on_nobait, - State.FISHING: on_fishing, - State.REELIN: on_reelin, - State.LOOT: on_loot, - State.INVFULL: on_invfull, - State.FIGHT: on_fight, - State.DEAD: on_dead + "IDLE": on_idle, + "LOOKAWAY": on_lookaway, + "LOOKING": on_looking, + "DEPLETED": on_depleted, + "NOBAIT": on_nobait, + "FISHING": on_fishing, + "REELIN": on_reelin, + "LOOT": on_loot, + "INVFULL": on_invfull, + "FIGHT": on_fight, + "DEAD": on_dead } try: callbacks_map[event]() FishEvent.previousState = event except KeyError as ex: - pass + logging.error("KeyError: State " + str(event) + " is not known.") + except TypeError as ex: + logging.error("TypeError when reading state: " + str(event)) def on_idle(): - if FishEvent.previousState in (State.FISHING, State.REELIN): + if FishEvent.previousState in ("FISHING", "REELIN"): logging.info("FISHING INTERRUPTED") _sound_and_send_fishy_data() diff --git a/fishy/engine/semifisher/fishing_mode.py b/fishy/engine/semifisher/fishing_mode.py index 7846fc7..a19c611 100644 --- a/fishy/engine/semifisher/fishing_mode.py +++ b/fishy/engine/semifisher/fishing_mode.py @@ -1,21 +1,22 @@ import time -from enum import Enum subscribers = [] -class State(Enum): - IDLE = [ 0, 0, 255] - LOOKAWAY = [150, 255, 76] - LOOKING = [100, 255, 101] - DEPLETED = [ 30, 255, 76] - NOBAIT = [ 96, 255, 255] - FISHING = [ 18, 165, 213] - REELIN = [ 60, 255, 204] - LOOT = [ 0, 255, 204] - INVFULL = [ 0, 255, 51] - FIGHT = [120, 255, 204] - DEAD = [ 0, 0, 51] +State = { + "IDLE" : [255, 255, 255], + "LOOKAWAY" : [ 76, 0, 76], + "LOOKING" : [101, 69, 0], + "DEPLETED" : [ 0, 76, 76], + "NOBAIT" : [255, 204, 0], + "FISHING" : [ 75, 156, 213], + "REELIN" : [ 0, 204, 0], + "LOOT" : [ 0, 0, 204], + "INVFULL" : [ 0, 0, 51], + "FIGHT" : [204, 0, 0], + "DEAD" : [ 51, 51, 51] +} + def _notify(event): for subscriber in subscribers: @@ -23,20 +24,20 @@ def _notify(event): class FishingMode: - CurrentMode = State.IDLE - PrevMode = State.IDLE + CurrentMode = "IDLE" + PrevMode = "IDLE" -def loop(hsv): +def loop(rgb): """ Executed in the start of the main loop in fishy.py Changes modes, calls mode events (callbacks) when mode is changed - :param hsv: hsv read by the bot + :param rgb: rgb read by the bot """ - FishingMode.CurrentMode = State.IDLE + FishingMode.CurrentMode = "IDLE" for s in State: - if all(hsv == s.value): + if all(rgb == State[s]): FishingMode.CurrentMode = s if FishingMode.CurrentMode != FishingMode.PrevMode: