Improvement on fishbot + config + idling bot
This commit is contained in:
parent
446e584b66
commit
db5b3a521c
BIN
assets/icons/groupFinder.jpg
Normal file
BIN
assets/icons/groupFinder.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/icons/profession.jpg
Normal file
BIN
assets/icons/profession.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 308 KiB After Width: | Height: | Size: 1.2 MiB |
BIN
assets/test.jpg
Normal file
BIN
assets/test.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
BIN
assets/test2.jpg
Normal file
BIN
assets/test2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
|
|
@ -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()
|
||||
31
bots/idling/IdlingAgent.py
Normal file
31
bots/idling/IdlingAgent.py
Normal file
|
|
@ -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()
|
||||
5
config.json
Normal file
5
config.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"antiAfk": true,
|
||||
"class": "DRUID",
|
||||
"name": "Droïde"
|
||||
}
|
||||
4
core/Config.py
Normal file
4
core/Config.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
class Config:
|
||||
def __init__(self) -> None:
|
||||
## PASS JSON CONFIG HERE AND DECLARE IT TO THE MAIN AGENT
|
||||
pass
|
||||
|
|
@ -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()
|
||||
|
||||
|
||||
|
|
|
|||
22
core/Player.py
Normal file
22
core/Player.py
Normal file
|
|
@ -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
|
||||
44
main.spec
Normal file
44
main.spec
Normal file
|
|
@ -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',
|
||||
)
|
||||
Loading…
Reference in New Issue
Block a user