bobber improvements
This commit is contained in:
+2
-3
@@ -6,14 +6,13 @@ from core.Player import Player, PLAYER_STATE
|
||||
class MainAgent:
|
||||
def __init__(self) -> None:
|
||||
self.monitor = Monitor()
|
||||
self.playerAgent = Player()
|
||||
self.idlingBot = IdlingAgent(self.playerAgent)
|
||||
self.playerAgent = Player(self.monitor)
|
||||
self.idlingBot = IdlingAgent(self.monitor, self.playerAgent)
|
||||
self.fishingBot = FishingAgent(self.monitor, self.playerAgent)
|
||||
self.monitor.startScreenCaptureThread()
|
||||
# Start idling agent at the construction of the mainAgent for now
|
||||
self.idlingBot.run()
|
||||
|
||||
|
||||
def startFishBot(self):
|
||||
self.playerAgent.changeState(PLAYER_STATE.FISHING)
|
||||
self.fishingBot.run()
|
||||
|
||||
+4
-1
@@ -45,6 +45,9 @@ class Monitor:
|
||||
self.screenThread.start()
|
||||
self.logger.log("Main Agent: Thread started")
|
||||
|
||||
def findBestMatchFromDir(self, dirPath):
|
||||
pass
|
||||
|
||||
def findMatch(self, template, method = "TM_CCOEFF_NORMED"):
|
||||
methodInt = getattr(cv, method)
|
||||
res = cv.matchTemplate(self.screenshot, template, methodInt)
|
||||
@@ -53,7 +56,7 @@ class Monitor:
|
||||
|
||||
matchRatio = max_val * 100
|
||||
self.logger.log(matchRatio)
|
||||
if (matchRatio < 55):
|
||||
if (matchRatio < 60):
|
||||
self.logger.log("Cannot find matching result...")
|
||||
return -1
|
||||
|
||||
|
||||
+22
-2
@@ -1,5 +1,8 @@
|
||||
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"])
|
||||
@@ -7,16 +10,33 @@ CLASSES = Enum('CLASSES', ['DRUID', 'MAGE', 'HUNTER', 'PRIEST'])
|
||||
PLAYER_STATE = Enum('STATE', ['IDLE', 'FISHING', 'FARMING'])
|
||||
|
||||
class Player:
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, monitor) -> None:
|
||||
with open("config.json", encoding="utf-8") as jsonFile:
|
||||
self.config = json.load(jsonFile)
|
||||
self.isConnected = CONNECT_STATUS.DISCONNECTED
|
||||
self.isConnected = None
|
||||
self.idleThread = None
|
||||
self.enterWorldButton = cv.imread("assets/menus/EnterWorldButton.jpg", cv.IMREAD_GRAYSCALE)
|
||||
self.logger = Logger("Player Agent")
|
||||
self.state = PLAYER_STATE.IDLE
|
||||
self.monitor = monitor
|
||||
self.playerClass = self.config["class"]
|
||||
self.playerName = self.config["name"]
|
||||
self.logger.log("Connected with " + self.playerName + " (" + self.playerClass + ")")
|
||||
|
||||
def checkConnection(self):
|
||||
res = self.monitor.findMatch(self.enterWorldButton)
|
||||
if (res == -1):
|
||||
self.isConnected = CONNECT_STATUS.CONNECTED
|
||||
else:
|
||||
self.isConnected = CONNECT_STATUS.DISCONNECTED
|
||||
self.logger.log("Player not connected attempting to connect...")
|
||||
pyautogui.move(res[0], res[1])
|
||||
time.sleep(0.4)
|
||||
pyautogui.click()
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
|
||||
|
||||
def changeState(self, newState):
|
||||
self.state = newState
|
||||
@@ -33,7 +33,7 @@ class CLIAgent:
|
||||
cv.destroyAllWindows()
|
||||
self.logger.log("Exiting application...")
|
||||
self.isRunning = False
|
||||
else:
|
||||
else:
|
||||
self.logger.log("Unknown Command.")
|
||||
self.printMenu()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user