Added lang + findAndClick Function
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
BIN
assets/en/menus/EnterWorldButton.jpg
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
BIN
assets/en/menus/Reconnect.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 828 KiB |
|
|
@ -11,23 +11,22 @@ BG_STATUS = Enum('BG_STATUS', ['IDLE', 'IN_QUEUE', 'IN_BG', 'LOADING'])
|
||||||
class BattlegroundAgent:
|
class BattlegroundAgent:
|
||||||
def __init__(self, monitor, player) -> None:
|
def __init__(self, monitor, player) -> None:
|
||||||
self.battlegroundThread = None
|
self.battlegroundThread = None
|
||||||
|
self.player = player
|
||||||
self.logger = Logger("Battleground Agent")
|
self.logger = Logger("Battleground Agent")
|
||||||
self.groupFinderIcon = cv.imread("assets/icons/GroupFinder.jpg", cv.IMREAD_GRAYSCALE)
|
self.groupFinderIcon = cv.imread("assets/icons/GroupFinder.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.pvpTab = cv.imread("assets/menus/PlayerVsPlayerTab.jpg", cv.IMREAD_GRAYSCALE)
|
self.pvpTab = cv.imread("assets/" + player.lang + "/menus/PlayerVsPlayerTab.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.randomEpicBgButton = cv.imread("assets/menus/RandomEpicBGButton.jpg", cv.IMREAD_GRAYSCALE)
|
self.randomEpicBgButton = cv.imread("assets/" + player.lang + "/menus/RandomEpicBGButton.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.joinBattleButton = cv.imread("assets/menus/JoinBattleButton.jpg", cv.IMREAD_GRAYSCALE)
|
self.joinBattleButton = cv.imread("assets/" + player.lang + "/menus/JoinBattleButton.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.deserterIcon = cv.imread("assets/icons/Deserter.jpg", cv.IMREAD_GRAYSCALE)
|
self.deserterIcon = cv.imread("assets/icons/Deserter.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.joinBgWindow = cv.imread("assets/menus/JoinBGWindow.jpg", cv.IMREAD_GRAYSCALE)
|
self.joinBgWindow = cv.imread("assets/" + player.lang + "/menus/JoinBGWindow.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.enterBgButton = cv.imread("assets/menus/EnterBgButton.jpg", cv.IMREAD_GRAYSCALE)
|
self.enterBgButton = cv.imread("assets/" + player.lang + "/menus/EnterBgButton.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.leaveBgButton = cv.imread("assets/menus/LeaveMatchButton.jpg", cv.IMREAD_GRAYSCALE)
|
self.leaveBgButton = cv.imread("assets/" + player.lang + "/menus/LeaveMatchButton.jpg", cv.IMREAD_GRAYSCALE)
|
||||||
self.status = BG_STATUS.IDLE
|
self.status = BG_STATUS.IDLE
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
self.player = player
|
|
||||||
|
|
||||||
def startBGFarming(self):
|
def startBGFarming(self):
|
||||||
pyautogui.press("esc")
|
|
||||||
self.player.checkConnection()
|
|
||||||
while self.player.state is PLAYER_STATE.BG_FARMING:
|
while self.player.state is PLAYER_STATE.BG_FARMING:
|
||||||
|
self.player.checkConnection()
|
||||||
self.status = BG_STATUS.IDLE
|
self.status = BG_STATUS.IDLE
|
||||||
if (self.isDeserter() is False):
|
if (self.isDeserter() is False):
|
||||||
self.tagInBg()
|
self.tagInBg()
|
||||||
|
|
@ -46,17 +45,10 @@ class BattlegroundAgent:
|
||||||
pyautogui.moveTo(50,50)
|
pyautogui.moveTo(50,50)
|
||||||
self.logger.log("Tagging in random epic bg...")
|
self.logger.log("Tagging in random epic bg...")
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
self.monitor.findMatchAndMoveToPosition(self.groupFinderIcon)
|
self.monitor.findMatchAndClickIfAvailable(self.groupFinderIcon)
|
||||||
pyautogui.click()
|
self.monitor.findMatchAndClickIfAvailable(self.pvpTab)
|
||||||
time.sleep(0.2)
|
self.monitor.findMatchAndClickIfAvailable(self.randomEpicBgButton)
|
||||||
self.monitor.findMatchAndMoveToPosition(self.pvpTab)
|
self.monitor.findMatchAndClickIfAvailable(self.joinBattleButton)
|
||||||
pyautogui.click()
|
|
||||||
time.sleep(0.2)
|
|
||||||
self.monitor.findMatchAndMoveToPosition(self.randomEpicBgButton)
|
|
||||||
pyautogui.click()
|
|
||||||
time.sleep(0.2)
|
|
||||||
self.monitor.findMatchAndMoveToPosition(self.joinBattleButton)
|
|
||||||
pyautogui.click()
|
|
||||||
self.status = BG_STATUS.IN_QUEUE
|
self.status = BG_STATUS.IN_QUEUE
|
||||||
self.waitForBg()
|
self.waitForBg()
|
||||||
|
|
||||||
|
|
@ -66,24 +58,19 @@ class BattlegroundAgent:
|
||||||
res = self.monitor.findMatch(self.joinBgWindow)
|
res = self.monitor.findMatch(self.joinBgWindow)
|
||||||
if (res != -1):
|
if (res != -1):
|
||||||
self.logger.log("Bg started joining the game...")
|
self.logger.log("Bg started joining the game...")
|
||||||
time.sleep(0.2)
|
self.monitor.findMatchAndClickIfAvailable(self.enterBgButton)
|
||||||
self.monitor.findMatchAndMoveToPosition(self.enterBgButton)
|
|
||||||
pyautogui.click()
|
|
||||||
self.status = BG_STATUS.LOADING
|
self.status = BG_STATUS.LOADING
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.inBgRoutine()
|
self.inBgRoutine()
|
||||||
|
|
||||||
|
|
||||||
|
def foundEndOfBg(self ):
|
||||||
|
self.logger.log("End of bg detected, leaving...")
|
||||||
|
self.status = BG_STATUS.IDLE
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
def checkEndOfBg(self):
|
def checkEndOfBg(self):
|
||||||
res = self.monitor.findMatch(self.leaveBgButton)
|
self.monitor.findMatchAndClickIfAvailable(self.leaveBgButton, self.foundEndOfBg)
|
||||||
if (res != -1):
|
|
||||||
self.logger.log("End of bg detected, leaving...")
|
|
||||||
time.sleep(0.2)
|
|
||||||
pyautogui.move(res[0], res[1])
|
|
||||||
time.sleep(0.3)
|
|
||||||
self.status = BG_STATUS.IDLE
|
|
||||||
pyautogui.click()
|
|
||||||
time.sleep(10)
|
|
||||||
|
|
||||||
def inBgRoutine(self):
|
def inBgRoutine(self):
|
||||||
self.logger.log("BG in progress...")
|
self.logger.log("BG in progress...")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"antiAfk": true,
|
"antiAfk": true,
|
||||||
"class": "DRUID",
|
"class": "DRUID",
|
||||||
|
"lang": "en",
|
||||||
"name": "Droïde"
|
"name": "Droïde"
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import time
|
import time
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from screeninfo import get_monitors
|
from screeninfo import get_monitors
|
||||||
|
from inspect import isfunction
|
||||||
import pyautogui
|
import pyautogui
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import cv2 as cv
|
import cv2 as cv
|
||||||
|
|
@ -77,6 +78,21 @@ class Monitor:
|
||||||
pyautogui.moveTo(point[0], point[1])
|
pyautogui.moveTo(point[0], point[1])
|
||||||
time.sleep(0.15)
|
time.sleep(0.15)
|
||||||
|
|
||||||
|
def findMatchAndClickIfAvailable(self, template, onSuccess = None, onNotFound = None):
|
||||||
|
res = self.findMatchAndMoveToPosition(template)
|
||||||
|
|
||||||
|
if (res == -1):
|
||||||
|
time.sleep(0.3)
|
||||||
|
if isfunction(onNotFound) is True:
|
||||||
|
return onNotFound(res)
|
||||||
|
else:
|
||||||
|
time.sleep(0.1)
|
||||||
|
pyautogui.click()
|
||||||
|
time.sleep(0.15)
|
||||||
|
if (isfunction(onSuccess) is True):
|
||||||
|
return onSuccess(res)
|
||||||
|
|
||||||
|
|
||||||
def stopScreenCaptureThread(self):
|
def stopScreenCaptureThread(self):
|
||||||
if (self.screenThread):
|
if (self.screenThread):
|
||||||
self.screenThread.terminate()
|
self.screenThread.terminate()
|
||||||
|
|
|
||||||
|
|
@ -15,25 +15,28 @@ class Player:
|
||||||
self.config = json.load(jsonFile)
|
self.config = json.load(jsonFile)
|
||||||
self.isConnected = None
|
self.isConnected = None
|
||||||
self.idleThread = None
|
self.idleThread = None
|
||||||
self.enterWorldButton = cv.imread("assets/menus/EnterWorldButton.jpg", cv.IMREAD_GRAYSCALE)
|
|
||||||
self.logger = Logger("Player Agent")
|
self.logger = Logger("Player Agent")
|
||||||
self.state = PLAYER_STATE.IDLE
|
self.state = PLAYER_STATE.IDLE
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
self.playerClass = self.config["class"]
|
self.playerClass = self.config["class"]
|
||||||
self.playerName = self.config["name"]
|
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 + ")")
|
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):
|
def checkConnection(self):
|
||||||
res = self.monitor.findMatch(self.enterWorldButton)
|
self.monitor.findMatchAndClickIfAvailable(self.enterWorldButton, self.connectButtonFound, self.connectButtonNotFound)
|
||||||
if (res == -1):
|
self.monitor.findMatchAndClickIfAvailable(self.reconnectButton, self.connectButtonFound, self.connectButtonNotFound)
|
||||||
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):
|
def changeState(self, newState):
|
||||||
self.state = newState
|
self.state = newState
|
||||||