generated from MaaXYZ/MaaPracticeBoilerplate
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
633 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.