Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2cea270
feat(activity-updater): Add activity updater to automatically fetch a…
Nanboom233 Jun 22, 2025
6f2a934
feat(activity-updater): Add Blue Archive EN wiki as a source, and tra…
Nanboom233 Jun 22, 2025
cfafd6d
fix(explore-task): refactor preset row finding method by using cv2
Nanboom233 Jul 3, 2025
d69d04f
Merge branch 'refs/heads/pr-activity' into pr-activity-refactor
Nanboom233 Jul 16, 2025
3131f0f
chore(uiautomator2): bump uiautomator2 version to 3.4.0
Nanboom233 Sep 3, 2025
69e370e
chore(uiautomator2): detele unused atx-agent binaries
Nanboom233 Sep 3, 2025
c1463c2
chore: remove a accidentally commited file
Nanboom233 Sep 5, 2025
bef6934
chore(uiautomator2): bump uiautomator2 version to 3.4.0 in requiremen…
Nanboom233 Sep 6, 2025
bab268c
fix(uiautomator2): fix ui2 do not offer original screenshot
Nanboom233 Sep 6, 2025
2ffe4ce
build(uiautomator2): bump adbutils dependency to version 2.9.3
Nanboom233 Sep 7, 2025
0ba5d7f
build: bump ui2 version to 3.4.0 in pyproject.toml
Nanboom233 Sep 7, 2025
8342af3
build: bump ui2 version to 3.4.0 in pyproject.toml
Nanboom233 Sep 7, 2025
15e621e
Merge branch 'pr-u2-update' into pr-activity-refactor
Nanboom233 Sep 9, 2025
b77583c
feat(activity-updater): add more activities detection from ba_wiki an…
Nanboom233 Sep 9, 2025
1519e70
feat(activity-updater): add SchaleDB as another activity data source.
Nanboom233 Sep 9, 2025
9d2fed4
Merge branch 'pur1fying:master' into pr-activity-refactor
Nanboom233 Sep 9, 2025
ca5ceb5
refactor: Organize activity modules and update updater dependencies (…
Nanboom233 Sep 9, 2025
3c683b9
chore(activity-updater): Enable module to be run as script
Nanboom233 Sep 9, 2025
273461b
feat(ci): Add a basic scheduled workflow for activity synchronization…
Nanboom233 Sep 9, 2025
113837f
chore: Shorten sync activity workflow name (pr-activity-refactor)
Nanboom233 Sep 9, 2025
41e22d5
feat(activity-updater): unify the output of three methods
Nanboom233 Sep 9, 2025
e32dc6b
feat(activity-updater): Unify activity data from multiple sources and…
Nanboom233 Sep 9, 2025
e6b73c2
feat(activity-updater): Improve activity update logging and output fo…
Nanboom233 Sep 9, 2025
d21d949
chore(activity-updater): ignore temporary activity data file
Nanboom233 Sep 9, 2025
2d6c279
ci(activity-sync): Automate activity.json updates with PR creation
Nanboom233 Sep 9, 2025
01846b4
ci(activity-sync): remove test logging step
Nanboom233 Sep 9, 2025
2c459a1
ci(activity-updater): fix error output and logging upload
Nanboom233 Sep 9, 2025
e51c1ae
fix(activity-updater): fix logging and path handling (pr-activity-ref…
Nanboom233 Sep 9, 2025
1aa2cf5
chore(activity): sync activity.json (auto-update by workflow)
Nanboom233 Sep 9, 2025
dd213d1
fix(activity-updater): fix workflow handling to avoid unnecessary fai…
Nanboom233 Sep 10, 2025
71063d6
chore(activity): sync activity.json (auto-update by workflow)
Nanboom233 Sep 10, 2025
e21227d
fix(activities): remove 'Stages' field to final data maps (pr-activit…
Nanboom233 Sep 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/sync_activity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: sync_game_activity

on:
schedule:
- cron: '30 20 * * *'
workflow_dispatch:

permissions:
contents: write
pull-requests: write


jobs:
sync-activities:
runs-on: ubuntu-latest
steps:
- name: Checkout activities repository
uses: actions/checkout@v4
with:
sparse-checkout: |
module/activities/
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r module/activities/requirements-activity-updater.txt
- name: Run activity updater
run: python3 module/activities/activity_updater.py
- name: Upload update log as artifact
uses: actions/upload-artifact@v4
with:
name: activity-update-log
path: module/activities/activity_update_log.md
- name: Copy updated activity.json if changed
if: success() && (hashFiles('module/activities/tmp_activity.json') != '')
# Only upload and create PR if any new updates to the existing activity data
run: cp module/activities/tmp_activity.json module/activities/activity.json
- name: Set the output log as PR body
if: success() && (hashFiles('module/activities/tmp_activity.json') != '')
id: pr_body
run: |
echo "body<<EOF" >> $GITHUB_OUTPUT
cat module/activities/activity_update_log.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Pull Request if updated
if: success() && (hashFiles('module/activities/tmp_activity.json') != '')
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore(activity): sync activity.json (auto-update by workflow)"
title: "CI/sync activity.json (auto-update by workflow)"
body: "${{ steps.pr_body.outputs.body }}"
branch: "auto-sync-activity"
54 changes: 8 additions & 46 deletions core/Baas_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import cv2
import numpy as np
import psutil
import requests

import module.ExploreTasks.explore_task
from core import position, picture, utils
Expand All @@ -22,7 +21,6 @@
from core.device.Screenshot import Screenshot
from core.device.connection import Connection
from core.device.emulator_manager import process_api
from core.device.uiautomator2_client import BAAS_U2_Initer, __atx_agent_version__
from core.device.uiautomator2_client import U2Client
from core.exception import RequestHumanTakeOver, FunctionCallTimeout, PackageIncorrect, LogTraceback
from core.notification import notify, toast
Expand Down Expand Up @@ -378,27 +376,6 @@ def _read_DeviceOption_ocr_language(self, _p):
else:
raise Exception("Global Server Invalid Language : " + game_lan + ".")

def check_atx(self):
self.logger.info("--------------Check ATX install ----------------")
_d = self.u2._wait_for_device()
if not _d:
raise RuntimeError("USB device %s is offline " + self.serial)
self.logger.info("Device [ " + self.serial + " ] is online.")

version_url = self.u2.path2url("/version")
try:
version = requests.get(version_url, timeout=3).text
if version != __atx_agent_version__:
raise EnvironmentError("atx-agent need upgrade")
except (requests.RequestException, EnvironmentError):
self.set_up_atx_agent()
self.wait_uiautomator_start()
self.logger.info("Uiautomator2 service started.")

def set_up_atx_agent(self):
init = BAAS_U2_Initer(self.u2._adb_device, self.logger)
init.install()

def send(self, msg, task=None):
if msg == "start":
if self.button_signal is not None:
Expand Down Expand Up @@ -863,8 +840,8 @@ def daily_config_refresh(self):
last_refresh_hour = last_refresh.hour
daily_reset = 4 - (self.server == 'JP' or self.server == 'Global')
if now.day == last_refresh.day and now.year == last_refresh.year and now.month == last_refresh.month and \
((hour < daily_reset and last_refresh_hour < daily_reset) or (
hour >= daily_reset and last_refresh_hour >= daily_reset)):
((hour < daily_reset and last_refresh_hour < daily_reset) or (
hour >= daily_reset and last_refresh_hour >= daily_reset)):
return
else:
self.config.last_refresh_config_time = time.time()
Expand Down Expand Up @@ -981,9 +958,10 @@ def handle_resolution_dynamic_change(self):
_new = self.connection.app_process_window.get_resolution()
if self.resolution[0] == _new[0] and self.resolution[1] == _new[1]:
return
self.logger.warning("Screen Resolution change detected, we don't recommend you to change screen resolution while running the script.")
self.logger.warning(
"Screen Resolution change detected, we don't recommend you to change screen resolution while running the script.")

_new = self._wait_resolution_change_finish(_new,10, 0.3)
_new = self._wait_resolution_change_finish(_new, 10, 0.3)
if self.resolution[0] == _new[0] and self.resolution[1] == _new[1]:
self.logger.info("Resolution unchanged.")
return
Expand Down Expand Up @@ -1020,7 +998,6 @@ def _wait_resolution_change_finish(self, last_res, static_cnt=10, interval=0.3):
latest_res = _new
time.sleep(interval)


@staticmethod
def _accept_resolution(x, y, std_x=16, std_y=9, threshold=0.05):
return abs(x / y - std_x / std_y) <= threshold
Expand All @@ -1030,7 +1007,8 @@ def check_screen_ratio(self, width, height):
screen_ratio = width // gcd, height // gcd
if screen_ratio == (16, 9):
return
self.logger.warning(f"Screen Ratio: {width}:{height} is not a precise 16:9 screen, we recommend you to use a precise 16:9 screen.")
self.logger.warning(
f"Screen Ratio: {width}:{height} is not a precise 16:9 screen, we recommend you to use a precise 16:9 screen.")
if self._accept_resolution(width, height, 16, 9, 0.05):
self.logger.info(f"Screen Ratio close to 16:9. Accept it.")
return
Expand All @@ -1040,15 +1018,13 @@ def check_screen_ratio(self, width, height):
def _get_android_device_resolution(self):
self.u2_client = U2Client.get_instance(self.serial)
self.u2 = self.u2_client.get_connection()
self.check_atx()
self.last_refresh_u2_time = time.time()
return self.resolution_uiautomator2()

def resolution_uiautomator2(self):
for i in range(0, 3):
try:
info = self.u2.http.get('/info').json()
w, h = info['display']['width'], info['display']['height']
w, h = self.u2.info['displayWidth'], self.u2.info['displayHeight']
if w < h:
w, h = h, w
return w, h
Expand All @@ -1060,17 +1036,3 @@ def main_page_update_data(self):
self.get_ap(True)
self.get_creditpoints(True)
self.get_pyroxene(True)


if __name__ == '__main__':
print(os.path.exists(
"D:\\github\\bass\\blue_archive_auto_script\\src\\atx_app\\atx-agent_0.10.1_linux_386\\atx-agent"))
# "D:\\github\\bass\\blue_archive_auto_script\\src\\atx_app\\atx-agent_0.10.0_linux_386\\atx-agent"
import uiautomator2

u2 = uiautomator2.connect("127.0.0.1:16512")
from core.utils import Logger

logger = Logger(None)
init = BAAS_U2_Initer(u2._adb_device, logger)
init.uninstall()
4 changes: 3 additions & 1 deletion core/device/screenshot/uiautomator2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def __init__(self, conn):
def screenshot(self):
for i in range(5):
try:
return self.u2.screenshot()
screenshot = self.u2.screenshot()
if screenshot is not None:
return screenshot
except Exception as e:
print(e)
Loading