41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
import json
|
|
from enum import Enum
|
|
import time
|
|
import cv2 as cv
|
|
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, config) -> None:
|
|
self.config = config
|
|
self.isConnected = None
|
|
self.idleThread = None
|
|
self.antiAfk = self.config.file["antiAfk"]
|
|
self.debug = self.config.file["debug"]
|
|
self.lang = self.config.file["lang"]
|
|
self.logger = Logger("Player Agent", self.debug)
|
|
self.state = PLAYER_STATE.IDLE
|
|
self.monitor = monitor
|
|
self.playerClass = self.config.file["class"]
|
|
self.playerName = self.config.file["name"]
|
|
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 |