From c6b7568aac502d585cbb0fbc4c103d7371dfd4fd Mon Sep 17 00:00:00 2001 From: Jeffrey Tan Date: Wed, 25 May 2022 17:38:03 -0700 Subject: [PATCH] organized project structure into ./src --- command_books/blaster.py | 9 +++------ command_books/kanna.py | 8 +++----- gui_components/edit/commands.py | 4 ++-- gui_components/edit/components.py | 5 ++--- gui_components/edit/controls.py | 3 +-- gui_components/edit/main.py | 4 ++-- gui_components/edit/minimap.py | 7 ++----- gui_components/edit/record.py | 3 +-- gui_components/edit/routine.py | 1 - gui_components/edit/status.py | 3 +-- gui_components/menu/main.py | 4 +--- gui_components/settings/main.py | 3 +-- gui_components/view/main.py | 5 ++--- layouts/bd1 | Bin 63 -> 0 bytes layouts/cf1 | Bin 1717 -> 0 bytes layouts/dcsa | Bin 64 -> 0 bytes layouts/dcup2 | Bin 1044 -> 1248 bytes layouts/hft | Bin 1492 -> 0 bytes layouts/mts3 | Bin 2618 -> 0 bytes layouts/srs1 | Bin 64 -> 0 bytes main.py | 10 +++++----- routines/dcup2.csv | 11 ++++++----- config.py => src/common/config.py | 0 settings.py => src/common/settings.py | 0 utils.py => src/common/utils.py | 3 +-- vkeys.py => src/common/vkeys.py | 2 +- detection.py => src/detection/detection.py | 4 ++-- bot.py => src/modules/bot.py | 22 ++++++++++++--------- capture.py => src/modules/capture.py | 3 +-- gui.py => src/modules/gui.py | 5 ++--- listener.py => src/modules/listener.py | 3 +-- notifier.py => src/modules/notifier.py | 7 +++---- components.py => src/routine/components.py | 10 ++++++---- layout.py => src/routine/layout.py | 4 +--- routine.py => src/routine/routine.py | 8 +++----- 35 files changed, 66 insertions(+), 85 deletions(-) delete mode 100644 layouts/bd1 delete mode 100644 layouts/cf1 delete mode 100644 layouts/dcsa delete mode 100644 layouts/hft delete mode 100644 layouts/mts3 delete mode 100644 layouts/srs1 rename config.py => src/common/config.py (100%) rename settings.py => src/common/settings.py (100%) rename utils.py => src/common/utils.py (99%) rename vkeys.py => src/common/vkeys.py (99%) rename detection.py => src/detection/detection.py (98%) rename bot.py => src/modules/bot.py (92%) rename capture.py => src/modules/capture.py (99%) rename gui.py => src/modules/gui.py (94%) rename listener.py => src/modules/listener.py (98%) rename notifier.py => src/modules/notifier.py (98%) rename components.py => src/routine/components.py (97%) rename layout.py => src/routine/layout.py (99%) rename routine.py => src/routine/routine.py (98%) diff --git a/command_books/blaster.py b/command_books/blaster.py index fa7d48ae..482f71a1 100644 --- a/command_books/blaster.py +++ b/command_books/blaster.py @@ -1,12 +1,9 @@ """A collection of all commands that a Blaster can use to interact with the game.""" -import config import time -import math -import settings -import utils -from components import Command -from vkeys import press, key_down, key_up +from src.common import settings +from src.routine.components import Command +from src.common.vkeys import press, key_down, key_up # # class Move(Command): diff --git a/command_books/kanna.py b/command_books/kanna.py index cc0550e3..62e274f5 100644 --- a/command_books/kanna.py +++ b/command_books/kanna.py @@ -1,12 +1,10 @@ """A collection of all commands that a Kanna can use to interact with the game.""" -import config +from src.common import config, settings, utils import time import math -import settings -import utils -from components import Command -from vkeys import press, key_down, key_up +from src.routine.components import Command +from src.common.vkeys import press, key_down, key_up # List of key mappings diff --git a/gui_components/edit/commands.py b/gui_components/edit/commands.py index 1f241bbf..974ee9ba 100644 --- a/gui_components/edit/commands.py +++ b/gui_components/edit/commands.py @@ -1,7 +1,7 @@ import tkinter as tk -import config -from components import Point +from src.common import config +from src.routine.components import Point from gui_components.interfaces import Frame diff --git a/gui_components/edit/components.py b/gui_components/edit/components.py index 5196422b..5371a995 100644 --- a/gui_components/edit/components.py +++ b/gui_components/edit/components.py @@ -1,7 +1,6 @@ import tkinter as tk - -import config -from components import Point +from src.common import config +from src.routine.components import Point from gui_components.interfaces import Frame diff --git a/gui_components/edit/controls.py b/gui_components/edit/controls.py index c4ba47c7..5eff8fec 100644 --- a/gui_components/edit/controls.py +++ b/gui_components/edit/controls.py @@ -1,6 +1,5 @@ import tkinter as tk - -import config +from src.common import config from gui_components.interfaces import Frame diff --git a/gui_components/edit/main.py b/gui_components/edit/main.py index 5036a929..18441722 100644 --- a/gui_components/edit/main.py +++ b/gui_components/edit/main.py @@ -1,9 +1,9 @@ """Allows the user to edit routines while viewing each Point's location on the minimap.""" -import config +from src.common import config import inspect import tkinter as tk -from components import Point, Command +from src.routine.components import Point, Command from gui_components.edit.minimap import Minimap from gui_components.edit.record import Record from gui_components.edit.routine import Routine diff --git a/gui_components/edit/minimap.py b/gui_components/edit/minimap.py index 07522b05..54e7c931 100644 --- a/gui_components/edit/minimap.py +++ b/gui_components/edit/minimap.py @@ -1,11 +1,8 @@ import tkinter as tk - import cv2 from PIL import ImageTk, Image - -import config -import utils -from components import Point +from src.common import config, utils +from src.routine.components import Point from gui_components.interfaces import LabelFrame diff --git a/gui_components/edit/record.py b/gui_components/edit/record.py index a7b81dc9..5ebcd610 100644 --- a/gui_components/edit/record.py +++ b/gui_components/edit/record.py @@ -1,6 +1,5 @@ import tkinter as tk - -from components import Point +from src.routine.components import Point from gui_components.interfaces import LabelFrame diff --git a/gui_components/edit/routine.py b/gui_components/edit/routine.py index fe03f1b1..6bbbfac3 100644 --- a/gui_components/edit/routine.py +++ b/gui_components/edit/routine.py @@ -1,5 +1,4 @@ import tkinter as tk - from gui_components.edit.commands import Commands from gui_components.edit.components import Components from gui_components.edit.controls import Controls diff --git a/gui_components/edit/status.py b/gui_components/edit/status.py index 2871c3fa..7ec2994a 100644 --- a/gui_components/edit/status.py +++ b/gui_components/edit/status.py @@ -1,6 +1,5 @@ import tkinter as tk - -import config +from src.common import config from gui_components.interfaces import LabelFrame diff --git a/gui_components/menu/main.py b/gui_components/menu/main.py index 414a6db2..6a649ed9 100644 --- a/gui_components/menu/main.py +++ b/gui_components/menu/main.py @@ -1,12 +1,10 @@ """A menu for loading routines and command books.""" -import config -import utils +from src.common import config, utils import queue import tkinter as tk from tkinter.filedialog import askopenfilename, asksaveasfilename from tkinter.messagebox import askyesno -from bot import Bot class Menu(tk.Menu): diff --git a/gui_components/settings/main.py b/gui_components/settings/main.py index ba61adf8..328cd035 100644 --- a/gui_components/settings/main.py +++ b/gui_components/settings/main.py @@ -1,7 +1,6 @@ """Displays Auto Maple's current settings and allows the user to edit them.""" -import config -import utils +from src.common import config, utils import tkinter as tk import keyboard as kb from gui_components.interfaces import Tab, Frame, LabelFrame diff --git a/gui_components/view/main.py b/gui_components/view/main.py index dd41e751..28318fcf 100644 --- a/gui_components/view/main.py +++ b/gui_components/view/main.py @@ -1,11 +1,10 @@ """Displays the current minimap as well as various information regarding the current routine.""" -import config -import utils +from src.common import config, utils import cv2 import tkinter as tk from gui_components.interfaces import LabelFrame, Tab -from components import Point +from src.routine.components import Point from PIL import Image, ImageTk diff --git a/layouts/bd1 b/layouts/bd1 deleted file mode 100644 index 8540c47963e058727a68fd577dbe193ae0fe3fa4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 63 zcmZo*PR>cJ%r7nB@_|r=44RFFjJ1VK8WAiE3=DaRxv7QB5zIhlQi@?A3s|ryKfk1q J)vq*34**4B5ZwR( diff --git a/layouts/cf1 b/layouts/cf1 deleted file mode 100644 index b95f8ecb3a31ab4863df1627a0f73438a4cade9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1717 zcmai!IZRYh6ov;umO)$*P+SMm0Tl-~Tp2|Xm+_&}JZ+Tync$3v%&0_8qM@UsqqEXz z#8^m7#KNeFf`wp25~C(WiE#-Qb~MI&|F_Sg)w}QJ`_FdIIoHygI~uzpv8Xqsf5=mI zozj?Q`PB@M#}jV6&`RlQx;QqsRZ<2nJ0p=O%{GNfq@~qMnL?JulVngO z@Pny_EL?Pvw=Vd2U?%_R(5RXvh}gxm9j$Fq%GIQD4pW|A6Pj;Tr+=6AT+#$R>g$(3 znoi7Rng`-z@3~Ly!?zNN`AiEyycrtp3l-l>Bo;C)0`UZ<%M*!wro|xcBGfS#p{Ut< z;GO5&wI~%RYL57CiChlrsT3-z*Sye?A|=+O6(GYUOiN+;MYl{~#BJGtikX%HdO27+ zopZHDLgRmK2Jh7W&~g>6K+y^n4MyX?x|8KhE1-X;mp-YJl}xJuy_b*C7mA1e=VUdL z5Be#*W}i!sTuYeNfS8mGkonU^xY9_Hk)BB@(^{DLF4`e>qa?M7LbzPVn{c z`PVo#n3V%p##9b&Og2&8gyfz{559h*(bh9<0P#w8(ZEb1v5~0)#B-Tkb!{TCi75c$ zksZC;OC{505V!4yw}@0Fa#YKCL}FW*w!+{zVhXr|5(WWnW7-bL@$|{PI{ORKDyAKf zey}IQm}e9i&`zdZfIee%dt?w61Y$SS9uSkF_}#sYE+SRlMlfQQieO|fQ#FiywP(rg zCdjl8g#JRPhDDgw*w0iG4~-Zzk$l?hs#~!fU^)mRj?IK>w`!^SWiXHq~oww6V> sp9>c2nNEP8up`lDz-Nx3V}U_(lIavAj&*Y1T>VZLvgBf)#+oYr0cJ%r7nB@_|r=44RFFjJ1VK8WAiE3=DaRxv7QBU}j2kabh70m|2vcUsA~G ISDK^;0A0rsf&c&j diff --git a/layouts/dcup2 b/layouts/dcup2 index 96246c1f1ce032bdf8d9bc12a39f1f4fd198a184..a1fe8080323fe60f1ea97d2148707866335bb7da 100644 GIT binary patch literal 1248 zcmZo*PA)D=)+@>{Ey>JF)yqk&1hTk%AXFiPW@8~^Z6T9J1PcQLLtbKTY9Vt3E0CFz zTv}jM$O0BF%Fiz;WW{ETUw%p|S0NkF5cb+a4vh##pw5ayPIvoPh8qMu;`zV=m4#gH z_9v6P=ghyGAHfb(QCbk6lbTji$ejVw$x~a%tC0cJ^QXVe~Jst~9x6a=fdKg0Lv>ive8Duikag~2MWW!`o(W75P_AyQi?3RZFcZocE= zS813k#A*x0!7A2>&MLdu+Xzx|2IwiE>I`nb2o8wXiZatPN(v?XA~-?8m|va;@vNj@ z1Q$#IqC^Vped*dl8L*)zZg4EoZ)ZiZ)-OZCFGJEVL&~o-sWb_RlOX}tEL&SB2iAQ1 zLdCC{Nj^9=!wiAyldmmQ0PB0$+tB6oqksr~aCbnBP^>Lf0vqvS(sT9i(HDp?0_Uv;ymV4T|#eXDB+s4zR8*v;nJtmK-1zyBS4*PFM?e N0K#nK98sF22LL*axp4ph literal 1044 zcmZo*PR>cJ%r7nB@_|r=44RFFjJ1VK8WAiE3=DaRxv7QB5v)LFN^)s|Q6URhxF|or zq>vS+)h|CKm8*~qsFA(4kV7Ma5vaPNkkj4%_33v@9xmtx3se?zx!Z4$g7b7)brxg@0AuA${9e_Cu^?&)yHH&RPfan@`F`8&8Y-Q zV5$(PEffT+c*L=`Uw_vWOcg@4g~DJJcUi)YPrvJhsY0Z-P!z1P;$hfx91Z)vBD}pS7XDe(Ll_u!{03A_Y5dZ)H diff --git a/layouts/hft b/layouts/hft deleted file mode 100644 index d25c477a7daec73b258cf15646f44c843aec9ac6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1492 zcmaize`t(x9LH~N>~`ZeGxKX^hI40(VP-pXHk(uCk@(|Dip|DD=Wd^M#||HnBqYfn z{#eq|5-mxRBuSD+(yYd&ZMVZ*NAfG7mGAfSeeQ10bw~HdbI-Te`~Cg=ct1z)Bsrrw5Yhu*vQA!0510a@RK)VGNU{AQ&ui z5@VYo)nV^+T{yF$-$n;MFgoo1(DB?m8$)smBfO2!Z86q$oQ zB}yx4l57xyrro;~511r5mA%)y_q&8ex+ELJ2Lj2Eymg9+oW~<%l5@AQyzz3kQR}Qi z6A-cp>bZ1(-;-OVv5=&sOA47ro@71|A)9nB-fgcqSyIDwz4`p*6f0XXMRgg(PePbX zeAn=|+tsa4V|jw6AWS9bjpfI~vs5mTLskWbS0)vX;5j%8}hS>x2m zEQHwveaNU=-}&WQEEJuNcB*p_%%mF>0phv@Q{{WsisvF&Nc_@sZ_nXhy(6>#~B2yc}3W7pyflVyNu~3|Rgug=4mm{ns zz5nW;A?N8Tu8&zYadw1N#0}&=G@(XM4|$rlK8r#9K8p32P85aUiTEJ{TQf#8ESFHU8eZ@UQSM16UcI diff --git a/layouts/mts3 b/layouts/mts3 deleted file mode 100644 index 8dc44c8335cd7d10be26f4046241a1238ce94f59..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2618 zcmai$S#uOs7>0wO36mfMa7$1?6bDpXa8PjxI$%UYGhrRKU_uf)PLknGW`wcotJ0hJ z2mAx@2SQn1Myn{W)R9fYmXuV&l7dQw8~g*DeouFwKABFDT+B?@^S?qY zNoMCM-BB!TZaSTsT2xB6@j(fR=BDwXkz>Qj-fXoZiiZ#Mc6Ap}>w3yM!J?$AG{0r8 z{G?>ApZUrInnBZ{||D@Ygs+%f_Cj?KD_&dhKv0}~+|CFGC(rc=1 z%DvLOQLuu_JT+zM=)79+EQv`k z`p~ZyVb?}}jo>-*x94(vUa*$Lt+-{ix<$tq1WEEUs<2$S(aM0tI>CApcj6rhy(oBz z(6rZ}T-ma*3b9-CvS0&scRAXv57q_xIX{`tD}q<)`-|Q)p6{sNGd=&W30^1hv))7= zp$kmAwN}P@2sR4dAb--Uui<~o(c**5mNJu+U=ww>y?t0pTRIYN3f>|SBv_H_+k(v` z&YC$6U|r2Sf_F*$5fepa$3X81-X~Nxa~xlCP(sCqZW3&v#eZg8E^+BH{<-pj;6oCZ zyt68EHNLORCoR}YbjwawFc9l9b_g7bXM9D)itiL;NKBih3RgVZn&^(! znY9XbQ95M?RnP1_e~ESr_K>(`!k^;_Rp%3X1^Y-$m}Ai<_6xEk{5#0&vrT*^_?*P= zW)Lp;M~Jt<*v2meUlNKO|4}IBXf=QBjuo=lSHKAGyXmaEAA3>Ya5ep2rOSl@g{IRfn4@C+MXja=nELdiDwWNsO71`ina-6%0GMyx=go$fgLLqOqgz z2oMZV6uG4TWbPw@x&KZPEJ^SgdC?dY6lfB;71Bzvss_rKvjz4)TQ diff --git a/layouts/srs1 b/layouts/srs1 deleted file mode 100644 index 5aa43a88937aac39d08f9b1b25dea9580cea268f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 64 zcmZo*PR>cJ%r7nB@_|r=44RFFjJ1VK8WAiE3=DaRxv7QBU}kYqv0)(#m|2vcUsA~G ISDK^;09?)yZ~y=R diff --git a/main.py b/main.py index 0b41ffb5..a881093a 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,11 @@ """The central program that ties all the modules together.""" import time -from bot import Bot -from capture import Capture -from notifier import Notifier -from listener import Listener -from gui import GUI +from src.modules.bot import Bot +from src.modules.capture import Capture +from src.modules.notifier import Notifier +from src.modules.listener import Listener +from src.modules.gui import GUI bot = Bot() diff --git a/routines/dcup2.csv b/routines/dcup2.csv index 58b076cf..780c2fb4 100644 --- a/routines/dcup2.csv +++ b/routines/dcup2.csv @@ -1,3 +1,4 @@ +$, target=record_layout, value=True $, target=move_tolerance, value=0.075 @, label=main @@ -8,7 +9,7 @@ $, target=move_tolerance, value=0.075 Shikigami, direction=right, attacks=2, repetitions=1 >, label=loot, frequency=4, skip=False *, x=0.873, y=0.200, frequency=1, skip=False, adjust=False - Fall, distance=0.05 + Fall, distance=0.02 @, label=afterboss *, x=0.055, y=0.125, frequency=1, skip=False, adjust=False @@ -37,7 +38,7 @@ $, target=move_tolerance, value=0.075 Walk, direction=left, duration=0.2 Shikigami, direction=left, attacks=2, repetitions=1 *, x=0.225, y=0.200, frequency=1, skip=False, adjust=False - Fall, distance=0.05 + Fall, distance=0.02 Walk, direction=left, duration=0.2 Tengu *, x=0.660, y=0.083, frequency=1, skip=False, adjust=False @@ -59,7 +60,7 @@ $, target=move_tolerance, value=0.075 Shikigami, direction=right, attacks=2, repetitions=1 >, label=boss2, frequency=5, skip=True *, x=0.873, y=0.200, frequency=1, skip=False, adjust=False - Fall, distance=0.05 + Fall, distance=0.02 Walk, direction=right, duration=0.2 @, label=afterboss2 @@ -76,8 +77,8 @@ $, target=move_tolerance, value=0.075 Teleport, direction=left, jump=False Yaksha, direction=left *, x=0.750, y=0.200, frequency=3, skip=True, adjust=False - Fall, distance=0.05 + Fall, distance=0.02 >, label=afterboss, frequency=3, skip=True *, x=0.750, y=0.200, frequency=1, skip=False, adjust=False - Fall, distance=0.05 + Fall, distance=0.02 >, label=afterboss2, frequency=1, skip=False diff --git a/config.py b/src/common/config.py similarity index 100% rename from config.py rename to src/common/config.py diff --git a/settings.py b/src/common/settings.py similarity index 100% rename from settings.py rename to src/common/settings.py diff --git a/utils.py b/src/common/utils.py similarity index 99% rename from utils.py rename to src/common/utils.py index 527bd753..71d9957a 100644 --- a/utils.py +++ b/src/common/utils.py @@ -1,12 +1,11 @@ """A collection of functions and classes used across multiple modules.""" -import config -import settings import math import queue import cv2 import threading import numpy as np +from src.common import config, settings from random import random diff --git a/vkeys.py b/src/common/vkeys.py similarity index 99% rename from vkeys.py rename to src/common/vkeys.py index b6fa51c7..33fccc2d 100644 --- a/vkeys.py +++ b/src/common/vkeys.py @@ -2,9 +2,9 @@ import ctypes import time -import utils import win32con import win32api +from src.common import utils from ctypes import wintypes from random import random diff --git a/detection.py b/src/detection/detection.py similarity index 98% rename from detection.py rename to src/detection/detection.py index 96a11f82..623b35d5 100644 --- a/detection.py +++ b/src/detection/detection.py @@ -1,9 +1,9 @@ """A module for classifying directional arrows using TensorFlow.""" -import utils import cv2 import tensorflow as tf import numpy as np +from src.common import utils ######################### @@ -178,7 +178,7 @@ def merge_detection(model, image): # Script for testing the detection module by itself if __name__ == '__main__': - import config + from src.common import config, utils import mss config.enabled = True monitor = {'top': 0, 'left': 0, 'width': 1366, 'height': 768} diff --git a/bot.py b/src/modules/bot.py similarity index 92% rename from bot.py rename to src/modules/bot.py index 042674c2..b63935a1 100644 --- a/bot.py +++ b/src/modules/bot.py @@ -1,19 +1,19 @@ """An interpreter that reads and executes user-created routines.""" -import config -import detection + import threading import time import cv2 -import utils import inspect -import components import numpy as np from PIL import ImageGrab from os.path import splitext, basename -from routine import Routine -from components import Point -from vkeys import press, click +from src.common import config, utils +from src.detection import detection +from src.routine import components +from src.routine.routine import Routine +from src.routine.components import Point +from src.common.vkeys import press, click # The rune's buff icon @@ -117,12 +117,16 @@ def _solve_rune(self, model): time.sleep(0.3) frame = np.array(ImageGrab.grab(config.capture.window)) frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR) - rune_buff = utils.multi_match(frame[:frame.shape[0]//8, :], + rune_buff = utils.multi_match(frame[:frame.shape[0] // 8, :], RUNE_BUFF_TEMPLATE, threshold=0.9) if rune_buff: rune_buff_pos = min(rune_buff, key=lambda p: p[0]) - click(rune_buff_pos, button='right') + click( + (rune_buff_pos[0] + config.capture.window[0], + rune_buff_pos[1] + config.capture.window[0]), + button='right' + ) break elif len(solution) == 4: inferences.append(solution) diff --git a/capture.py b/src/modules/capture.py similarity index 99% rename from capture.py rename to src/modules/capture.py index 913f3185..3587ddbd 100644 --- a/capture.py +++ b/src/modules/capture.py @@ -1,12 +1,11 @@ """A module for tracking useful in-game information.""" -import config -import utils import time import cv2 import threading import ctypes import numpy as np +from src.common import config, utils from ctypes import wintypes from PIL import ImageGrab user32 = ctypes.windll.user32 diff --git a/gui.py b/src/modules/gui.py similarity index 94% rename from gui.py rename to src/modules/gui.py index 78ff30a4..f42a5615 100644 --- a/gui.py +++ b/src/modules/gui.py @@ -1,9 +1,8 @@ """User friendly GUI to interact with Auto Maple.""" -import config import tkinter as tk from tkinter import ttk -import settings +from src.common import config, settings from gui_components import Menu, View, Edit, Settings @@ -76,7 +75,7 @@ def start(self): self._save_layout() self.root.mainloop() - def _save_layout(self): + def _save_layout(self): # TODO: move to bot main loop, file I/O is costly, blocks gui main loop """Periodically saves the current Layout object.""" if config.layout is not None and settings.record_layout: diff --git a/listener.py b/src/modules/listener.py similarity index 98% rename from listener.py rename to src/modules/listener.py index af51b2b1..f27820ac 100644 --- a/listener.py +++ b/src/modules/listener.py @@ -1,12 +1,11 @@ """A keyboard listener to track user inputs.""" -import config import time -import utils import threading import winsound import pickle import keyboard as kb +from src.common import config, utils from os.path import isfile from datetime import datetime diff --git a/notifier.py b/src/modules/notifier.py similarity index 98% rename from notifier.py rename to src/modules/notifier.py index 89e3389f..dd7e7d67 100644 --- a/notifier.py +++ b/src/modules/notifier.py @@ -1,14 +1,13 @@ """A module for detecting and notifying the user of dangerous in-game events.""" -import config -import utils +from src.common import config, utils import time import cv2 import pygame import threading import numpy as np import keyboard as kb -from components import Point +from src.routine.components import Point # A rune's symbol on the minimap @@ -57,7 +56,7 @@ def _main(self): # Check for unexpected black screen gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) - if np.count_nonzero(gray < 15) / height / width > 0.75: + if np.count_nonzero(gray < 15) / height / width > 0.9: self._alert() # Check for elite warning diff --git a/components.py b/src/routine/components.py similarity index 97% rename from components.py rename to src/routine/components.py index 23df68ff..f55c9485 100644 --- a/components.py +++ b/src/routine/components.py @@ -1,11 +1,9 @@ """A collection of classes used to execute a Routine.""" -import config -import settings -import utils import math import time -from vkeys import key_down, key_up, press +from src.common import config, settings, utils +from src.common.vkeys import key_down, key_up, press ################################# @@ -263,6 +261,8 @@ def main(self): key = 'right' self._new_direction(key) step(key, point) + if settings.record_layout: + config.layout.add(*config.player_pos) counter -= 1 if i < len(path) - 1: time.sleep(0.15) @@ -275,6 +275,8 @@ def main(self): key = 'down' self._new_direction(key) step(key, point) + if settings.record_layout: + config.layout.add(*config.player_pos) counter -= 1 if i < len(path) - 1: time.sleep(0.05) diff --git a/layout.py b/src/routine/layout.py similarity index 99% rename from layout.py rename to src/routine/layout.py index 89359227..5a83d3f7 100644 --- a/layout.py +++ b/src/routine/layout.py @@ -1,11 +1,9 @@ """A module for saving map layouts and determining shortest paths.""" -import config -import settings -import utils import cv2 import math import pickle +from src.common import config, settings, utils from os.path import join, isfile, splitext, basename from heapq import heappush, heappop diff --git a/routine.py b/src/routine/routine.py similarity index 98% rename from routine.py rename to src/routine/routine.py index 7413d088..37ef5ff7 100644 --- a/routine.py +++ b/src/routine/routine.py @@ -1,12 +1,10 @@ """A collection of classes used in the 'machine code' generated by Auto Maple's compiler for each routine.""" -import config -import utils +from src.common import config, settings, utils import csv -import settings from os.path import splitext, basename -from components import Point, Label, Jump, Setting, Command, SYMBOLS -from layout import Layout +from src.routine.components import Point, Label, Jump, Setting, Command, SYMBOLS +from src.routine.layout import Layout def update(func):