diff --git a/assets/icons/groupFinder.jpg b/assets/icons/groupFinder.jpg new file mode 100644 index 0000000..93c1a93 Binary files /dev/null and b/assets/icons/groupFinder.jpg differ diff --git a/assets/icons/profession.jpg b/assets/icons/profession.jpg new file mode 100644 index 0000000..121939e Binary files /dev/null and b/assets/icons/profession.jpg differ diff --git a/assets/screenshot.jpg b/assets/screenshot.jpg index 84d56dd..da7c838 100644 Binary files a/assets/screenshot.jpg and b/assets/screenshot.jpg differ diff --git a/assets/test.jpg b/assets/test.jpg new file mode 100644 index 0000000..d89d15c Binary files /dev/null and b/assets/test.jpg differ diff --git a/assets/test2.jpg b/assets/test2.jpg new file mode 100644 index 0000000..3fc4acc Binary files /dev/null and b/assets/test2.jpg differ diff --git a/bots/fishing/FishingAgent.py b/bots/fishing/FishingAgent.py index 7cb4edd..9070a9e 100644 --- a/bots/fishing/FishingAgent.py +++ b/bots/fishing/FishingAgent.py @@ -5,16 +5,23 @@ import time import cv2 as cv import pyautogui from core.Logger import Logger +from core.Player import PLAYER_STATE class FishingAgent: - def __init__(self, monitor) -> None: - self.logger = Logger("Fishing Agent") - self.retry = 0 - self.monitor = monitor - self.lureLoc = None + def __init__(self, monitor, player) -> None: self.fishingBobberImg = cv.imread("assets/fishing/Bobber.jpg", cv.IMREAD_GRAYSCALE) self.fishingIconImg = cv.imread("assets/fishing/FishIcon.jpg", cv.IMREAD_GRAYSCALE) self.fishingThread = None + self.logger = Logger("Fishing Agent") + self.monitor = monitor + self.lureLoc = None + self.player = player + self.retry = 0 + + def startFishing(self): + self.player.changeState(PLAYER_STATE.FISHING) + while self.player.state is PLAYER_STATE.FISHING: + self.castLure() def castLure(self): self.retry = 0 @@ -35,7 +42,7 @@ class FishingAgent: if (res == -1): if (self.retry > 4): self.logger.log("Took too to find lure long, retrying fishing from the beginning") - self.castLure() + return else: self.logger.log("Trying again in 1 second...") self.retry += 1 @@ -57,9 +64,9 @@ class FishingAgent: if (res != -1 and abs(res[1] - self.lureLoc[1]) > 20): pyautogui.click() time.sleep(0.5) - self.castLure() + return elif (self.retry > 200): - self.castLure() + return def run(self): self.logger.log("Starting fishing thread in 3 seconds...") @@ -70,8 +77,8 @@ class FishingAgent: time.sleep(1) self.fishingThread = Thread( - target=self.castLure, + target=self.startFishing, args=(), name="fishing thread", - daemon=True) + daemon=True) self.fishingThread.start() \ No newline at end of file diff --git a/bots/idling/IdlingAgent.py b/bots/idling/IdlingAgent.py new file mode 100644 index 0000000..6df80b2 --- /dev/null +++ b/bots/idling/IdlingAgent.py @@ -0,0 +1,31 @@ +import time +import pyautogui +from threading import Thread +from core.Logger import Logger +from core.Player import PLAYER_STATE + +class IdlingAgent: + def __init__(self, playerAgent) -> None: + self.logger = Logger("Idling Agent") + self.idleTime = time.time() + self.idleThread = None + self.player = playerAgent + + def checkIdleTime(self): + while self.player.state is PLAYER_STATE.IDLE: + elapsedTime = time.time() - self.idleTime + if (elapsedTime > 10): + self.logger.log("Jumping to avoid being afk...") + pyautogui.press("space") + self.idleTime = time.time() + time.sleep(0.5) + + def run(self): + self.logger.log("Starting Idle Thread...") + + self.idleThread = Thread( + target=self.checkIdleTime, + args=(), + name="idling thread", + daemon=True) + self.idleThread.start() \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..93df16d --- /dev/null +++ b/config.json @@ -0,0 +1,5 @@ +{ + "antiAfk": true, + "class": "DRUID", + "name": "Droïde" +} \ No newline at end of file diff --git a/core/Config.py b/core/Config.py new file mode 100644 index 0000000..6221eab --- /dev/null +++ b/core/Config.py @@ -0,0 +1,4 @@ +class Config: + def __init__(self) -> None: + ## PASS JSON CONFIG HERE AND DECLARE IT TO THE MAIN AGENT + pass \ No newline at end of file diff --git a/core/MainAgent.py b/core/MainAgent.py index 0bec72e..ecabe94 100644 --- a/core/MainAgent.py +++ b/core/MainAgent.py @@ -1,13 +1,21 @@ from core.Monitor import Monitor from bots.fishing.FishingAgent import FishingAgent +from bots.idling.IdlingAgent import IdlingAgent +from core.Player import Player, PLAYER_STATE class MainAgent: def __init__(self) -> None: self.monitor = Monitor() - self.fishingBot = FishingAgent(self.monitor) + self.playerAgent = Player() + self.idlingBot = IdlingAgent(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.monitor.startScreenCaptureThread() + self.playerAgent.changeState(PLAYER_STATE.FISHING) self.fishingBot.run() diff --git a/core/Player.py b/core/Player.py new file mode 100644 index 0000000..1e68ad6 --- /dev/null +++ b/core/Player.py @@ -0,0 +1,22 @@ +import json +from enum import Enum +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']) + +class Player: + def __init__(self) -> None: + with open("config.json", encoding="utf-8") as jsonFile: + self.config = json.load(jsonFile) + self.isConnected = CONNECT_STATUS.DISCONNECTED + self.idleThread = None + self.logger = Logger("Player Agent") + self.state = PLAYER_STATE.IDLE + self.playerClass = self.config["class"] + self.playerName = self.config["name"] + self.logger.log("Connected with " + self.playerName + " (" + self.playerClass + ")") + + def changeState(self, newState): + self.state = newState \ No newline at end of file diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..e03e1a6 --- /dev/null +++ b/main.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + [], + exclude_binaries=True, + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) +coll = COLLECT( + exe, + a.binaries, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='main', +)