import json from enum import Enum import time import cv2 as cv import pyautogui from core.Logger import Logger CONNECT_STATUS = Enum('CONNECT_STATUS', ["CONNECTED", "CONNECTING", "DISCONNECTED"]) CLASSES = Enum('CLASSES', ['DRUID', 'MAGE', 'HUNTER', 'PRIEST']) PLAYER_STATE = Enum('STATE', ['IDLE', 'FISHING', 'FARMING', 'BG_FARMING']) class Player: def __init__(self, monitor) -> None: with open("config.json", encoding="utf-8") as jsonFile: self.config = json.load(jsonFile) self.isConnected = None self.idleThread = None self.logger = Logger("Player Agent") self.state = PLAYER_STATE.IDLE self.monitor = monitor self.playerClass = self.config["class"] self.playerName = self.config["name"] self.antiAfk = self.config["antiAfk"] self.lang = self.config["lang"] self.enterWorldButton = cv.imread("assets/" + self.lang + "/menus/EnterWorldButton.jpg", cv.IMREAD_GRAYSCALE) self.reconnectButton = cv.imread("assets/" + self.lang + "/menus/Reconnect.jpg", cv.IMREAD_GRAYSCALE) self.logger.log("Connected with " + self.playerName + " (" + self.playerClass + ")") def connectButtonFound(self): self.isConnected = CONNECT_STATUS.DISCONNECTED self.logger.log("Player not connected attempting to connect...") time.sleep(30) def connectButtonNotFound(self): self.isConnected = CONNECT_STATUS.CONNECTED def checkConnection(self): self.monitor.findMatchAndClickIfAvailable(self.enterWorldButton, self.connectButtonFound, self.connectButtonNotFound) self.monitor.findMatchAndClickIfAvailable(self.reconnectButton, self.connectButtonFound, self.connectButtonNotFound) def changeState(self, newState): self.state = newState