Skip to content

Commit

Permalink
应该不会炸
Browse files Browse the repository at this point in the history
  • Loading branch information
mmwuyou committed Nov 15, 2024
1 parent dfa6461 commit 0381b3f
Show file tree
Hide file tree
Showing 16 changed files with 633 additions and 0 deletions.
84 changes: 84 additions & 0 deletions assets/resource/data/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from maa.toolkit import Toolkit
from maa.resource import Resource
from maa.controller import AdbController
from maa.tasker import Tasker

from maa.notification_handler import NotificationHandler, NotificationType



def main():
user_path = "./"
Toolkit.init_option(user_path)

resource = Resource()
res_job = resource.post_path("./resource_picli/base")
res_job.wait()

adb_devices = Toolkit.find_adb_devices()
if not adb_devices:
print("No ADB device found.")
exit()

# for demo, we just use the first device
device = adb_devices[0]
controller = AdbController(
adb_path=device.adb_path,
address=device.address,
screencap_methods=device.screencap_methods,
input_methods=device.input_methods,
config=device.config
)
controller.post_connection().wait()

tasker = Tasker()
# tasker = Tasker(notification_handler=MyNotificationHandler())
tasker.bind(resource, controller)

if not tasker.inited:
print("Failed to init MAA.")
exit()
tasker.post_pipeline("weapons-fabricate").wait().get()

class MyNotificationHandler(NotificationHandler):
def on_resource_loading(
self,
noti_type: NotificationType,
detail: NotificationHandler.ResourceLoadingDetail,
):
print(f"on_resource_loading: {noti_type}, {detail}")

def on_controller_action(
self,
noti_type: NotificationType,
detail: NotificationHandler.ControllerActionDetail,
):
print(f"on_controller_action: {noti_type}, {detail}")

def on_tasker_task(
self, noti_type: NotificationType, detail: NotificationHandler.TaskerTaskDetail
):
print(f"on_tasker_task: {noti_type}, {detail}")

def on_task_next_list(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskNextListDetail,
):
print(f"on_task_next_list: {noti_type}, {detail}")

def on_task_recognition(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskRecognitionDetail,
):
print(f"on_task_recognition: {noti_type}, {detail}")

def on_task_action(
self, noti_type: NotificationType, detail: NotificationHandler.TaskActionDetail
):
print(f"on_task_action: {noti_type}, {detail}")


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions assets/resource/data/config/maa_option.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"logging": true,
"recording": false,
"save_draw": false,
"show_hit_draw": false,
"stdout_level": 2
}
84 changes: 84 additions & 0 deletions assets/resource_picli/data/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from maa.toolkit import Toolkit
from maa.resource import Resource
from maa.controller import AdbController
from maa.tasker import Tasker

from maa.notification_handler import NotificationHandler, NotificationType



def main():
user_path = "./"
Toolkit.init_option(user_path)

resource = Resource()
res_job = resource.post_path("./resource_picli/base")
res_job.wait()

adb_devices = Toolkit.find_adb_devices()
if not adb_devices:
print("No ADB device found.")
exit()

# for demo, we just use the first device
device = adb_devices[0]
controller = AdbController(
adb_path=device.adb_path,
address=device.address,
screencap_methods=device.screencap_methods,
input_methods=device.input_methods,
config=device.config
)
controller.post_connection().wait()

tasker = Tasker()
# tasker = Tasker(notification_handler=MyNotificationHandler())
tasker.bind(resource, controller)

if not tasker.inited:
print("Failed to init MAA.")
exit()
tasker.post_pipeline("weapons-fabricate").wait().get()

class MyNotificationHandler(NotificationHandler):
def on_resource_loading(
self,
noti_type: NotificationType,
detail: NotificationHandler.ResourceLoadingDetail,
):
print(f"on_resource_loading: {noti_type}, {detail}")

def on_controller_action(
self,
noti_type: NotificationType,
detail: NotificationHandler.ControllerActionDetail,
):
print(f"on_controller_action: {noti_type}, {detail}")

def on_tasker_task(
self, noti_type: NotificationType, detail: NotificationHandler.TaskerTaskDetail
):
print(f"on_tasker_task: {noti_type}, {detail}")

def on_task_next_list(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskNextListDetail,
):
print(f"on_task_next_list: {noti_type}, {detail}")

def on_task_recognition(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskRecognitionDetail,
):
print(f"on_task_recognition: {noti_type}, {detail}")

def on_task_action(
self, noti_type: NotificationType, detail: NotificationHandler.TaskActionDetail
):
print(f"on_task_action: {noti_type}, {detail}")


if __name__ == "__main__":
main()
85 changes: 85 additions & 0 deletions py/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from maa.toolkit import Toolkit
from maa.resource import Resource
from maa.controller import AdbController
from maa.tasker import Tasker

from maa.notification_handler import NotificationHandler, NotificationType



def main():
user_path = "./"
Toolkit.init_option(user_path)

resource = Resource()
res_job = resource.post_path("./resource_picli/base")
res_job.wait()

adb_devices = Toolkit.find_adb_devices()
if not adb_devices:
print("No ADB device found.")
exit()

# for demo, we just use the first device
device = adb_devices[0]
print(device)
controller = AdbController(
adb_path=device.adb_path,
address=device.address,
screencap_methods=device.screencap_methods,
input_methods=device.input_methods,
config=device.config
)
controller.post_connection().wait()

tasker = Tasker()
# tasker = Tasker(notification_handler=MyNotificationHandler())
tasker.bind(resource, controller)

if not tasker.inited:
print("Failed to init MAA.")
exit()
tasker.post_pipeline("weapons-fabricate").wait().get()

class MyNotificationHandler(NotificationHandler):
def on_resource_loading(
self,
noti_type: NotificationType,
detail: NotificationHandler.ResourceLoadingDetail,
):
print(f"on_resource_loading: {noti_type}, {detail}")

def on_controller_action(
self,
noti_type: NotificationType,
detail: NotificationHandler.ControllerActionDetail,
):
print(f"on_controller_action: {noti_type}, {detail}")

def on_tasker_task(
self, noti_type: NotificationType, detail: NotificationHandler.TaskerTaskDetail
):
print(f"on_tasker_task: {noti_type}, {detail}")

def on_task_next_list(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskNextListDetail,
):
print(f"on_task_next_list: {noti_type}, {detail}")

def on_task_recognition(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskRecognitionDetail,
):
print(f"on_task_recognition: {noti_type}, {detail}")

def on_task_action(
self, noti_type: NotificationType, detail: NotificationHandler.TaskActionDetail
):
print(f"on_task_action: {noti_type}, {detail}")


if __name__ == "__main__":
main()
48 changes: 48 additions & 0 deletions pypicli/NotificationHandler/MwaNotificationHandler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from maa.notification_handler import NotificationHandler, NotificationType


#自定义通知处理器类
class MwaNotificationHandler(NotificationHandler):
# 处理资源加载的通知
def on_resource_loading(
self,
noti_type: NotificationType,
detail: NotificationHandler.ResourceLoadingDetail,
):
print(f"资源加载中: {noti_type}, {detail}")

# 处理控制器动作的通知
def on_controller_action(
self,
noti_type: NotificationType,
detail: NotificationHandler.ControllerActionDetail,
):
print(f"控制器动作: {noti_type}, {detail}")

# 处理任务器任务的通知
def on_tasker_task(
self, noti_type: NotificationType, detail: NotificationHandler.TaskerTaskDetail
):
print(f"任务器任务: {noti_type}, {detail}")

# 处理任务的下一个列表的通知
def on_task_next_list(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskNextListDetail,
):
print(f"下一个任务: {noti_type}, {detail}")

# 处理任务识别的通知
def on_task_recognition(
self,
noti_type: NotificationType,
detail: NotificationHandler.TaskRecognitionDetail,
):
print(f"任务识别: {noti_type}, {detail}")

# 处理任务动作的通知
def on_task_action(
self, noti_type: NotificationType, detail: NotificationHandler.TaskActionDetail
):
print(f"任务动作: {noti_type}, {detail}")
Empty file.
48 changes: 48 additions & 0 deletions pypicli/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import json
from maa.toolkit import Toolkit
from maa.resource import Resource
from maa.controller import AdbController
from maa.tasker import Tasker

from NotificationHandler.MwaNotificationHandler import MwaNotificationHandler


def tasker_init():
user_path = "./"
Toolkit.init_option(user_path)

resource = Resource()
resource.set_cpu()

res_job = resource.post_path("./resource_picli/base")
res_job.wait()

adb_devices = Toolkit.find_adb_devices()
if not adb_devices:
print("No ADB device found.")
exit()

# for demo, we just use the first device
device = adb_devices[0]
controller = AdbController(
adb_path=device.adb_path,
address=device.address,
screencap_methods=device.screencap_methods,
input_methods=device.input_methods,
config=device.config
)
controller.post_connection().wait()

# tasker = Tasker()
tasker = Tasker(notification_handler=MwaNotificationHandler())
tasker.bind(resource, controller)

if not tasker.inited:
print("Failed to init MAA.")
exit()
return tasker


if __name__ == "__main__":
# main()
pass
7 changes: 7 additions & 0 deletions pypicli/config/maa_option.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"logging": true,
"recording": false,
"save_draw": false,
"show_hit_draw": false,
"stdout_level": 2
}
Empty file added pypicli/deal_tasks/__init__.py
Empty file.
Loading

0 comments on commit 0381b3f

Please sign in to comment.