4 Коміти 0368e4d585 ... 83be77c1b5

Автор SHA1 Опис Дата
  Richard Köhl 83be77c1b5 add Readme 1 рік тому
  Richard Köhl f25a31fb4c add .env file 1 рік тому
  Richard Köhl 58a66f3b98 remove unused import and unnecessary sleep 1 рік тому
  Richard Köhl 04ff242113 add requirements 1 рік тому
6 змінених файлів з 49 додано та 3 видалено
  1. 1 0
      .env.example
  2. 2 0
      .gitignore
  3. 35 0
      Readme.md
  4. 0 2
      dungeon.py
  5. 6 1
      helper.py
  6. 5 0
      requirements.txt

+ 1 - 0
.env.example

@@ -0,0 +1 @@
+ANDROID_ADDRESS=192.168.178.32:5555

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+test/
+.env

+ 35 - 0
Readme.md

@@ -0,0 +1,35 @@
+# Hero Wars Dungeon runner
+
+## requirements
+
+### python
+
+python needs to be installed
+
+following python packages are needed
+
+```
+pip install -r requirements.txt
+```
+
+### environment
+
+- copy the `.env.example`-file to `.env`
+- adjust the ip address of your android device
+
+### adb
+
+adb commandline tool needs to be installed with Android Studio. (with sdk
+manager install
+`Android SDK > SDK Tools: Android SDK Build-Tools, Android SDK Command-line Tools, Android SDK Platform-Tools and Google USB Driver`)
+
+if you want to work wireless:
+
+- set adb port to 5555 while connected via usb:
+  ```
+  adb tcpip 5555
+  ```
+- connect wireless to device (with your android's ip address)
+  ```
+  adb connect 192.168.178.32:5555
+  ```

+ 0 - 2
dungeon.py

@@ -4,7 +4,6 @@ import numpy as np
 from helper import (
     tap,
     look_for_templates,
-    find_template,
     first_template,
     capture_current_screen,
     get_current_screen,
@@ -65,7 +64,6 @@ def read_screen():
 print("watching the screen...")
 is_mixed = False
 while True:
-    time.sleep(0.5)  # Polling interval
     capture_current_screen()
 
     name, locations = look_for_templates(templates)

+ 6 - 1
helper.py

@@ -1,8 +1,10 @@
 import cv2
 import numpy as np
+import os
 from io import BytesIO
 from PIL import Image
 from ppadb.client import Client as AdbClient
+from dotenv import load_dotenv
 
 with_cuda = 0
 if cv2.cuda.getCudaEnabledDeviceCount() > 0:
@@ -12,6 +14,9 @@ else:
     print("CUDA is not available")
     with_cuda = 0
 
+load_dotenv()
+android_address = os.getenv("ANDROID_ADDRESS")
+
 
 def get_current_screen():
     return current_screen
@@ -186,6 +191,6 @@ def non_max_suppression(boxes, overlapThresh):
 
 
 client = AdbClient(host="127.0.0.1", port=5037)
-device = client.device("192.168.178.32:5555")
+device = client.device(android_address)
 
 current_screen = capture_current_screen()

+ 5 - 0
requirements.txt

@@ -0,0 +1,5 @@
+opencv-python==4.9.0.80
+numpy==1.26.1
+Pillow==9.0.1
+pure-python-adb==0.3.0.dev0
+python-dotenv==1.0.0