Skip to content

Commit

Permalink
Merge pull request #162 from sanmusen214/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sanmusen214 authored Jan 15, 2025
2 parents e3e21d6 + 195c6bb commit 85bc0bc
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 43 deletions.
Binary file modified DATA/assets_cn/BUTTON/BUTTON_EVENT_FIRST.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion DATA/grid_solution/quest/26-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
{
"name": "B",
"type": "blue",
"position": "right"
"position": "right",
"click" : [869, 417]
}
],
"fight_plan": [
Expand Down
2 changes: 1 addition & 1 deletion DATA/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

"BAAH_desc": "BAAH can help you complete the dailies of Blue Archive in the JP server, Global server, CN official server, Bilibili server. All config files are in the BAAH_CONFIGS folder.",
"BAAH_get_version": "To get the latest version, download from Github or join the group to download",
"BAAH_attention": "Please set the emulator resolution to 1280*720, 240DPI! Game settings: the skill animation off, graph resolution low, black bars during battles off",
"BAAH_attention": "Please set the emulator resolution to 1280*720, 240DPI! Game settings: the skill animation off, black bars during battles off",

"notice_success": "Success",
"notice_fail": "Fail",
Expand Down
2 changes: 1 addition & 1 deletion DATA/i18n/jp_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

"BAAH_desc": "BAAHは、碧藍のアーカイブ/ウルトラブルーアーカイブの日本版、国際版、公式中国版、中国B版のデイリーミッションを自動的に実行します。設定ファイルはBAAH_CONFIGSフォルダに保存されます。",
"BAAH_get_version": "最新バージョンはGithubからダウンロードするか、グループ内からダウンロードできます",
"BAAH_attention": "エミュレータ解像度は1280*720、DPIは240に設定してください! ゲーム内設定オプション-ゲーム-スキルアニメーション-オフ、設定オプション-画像-解像度-低、設定オプション-画像-戦闘時の上下の黒帯-オフ",
"BAAH_attention": "エミュレータ解像度は1280*720、DPIは240に設定してください! ゲーム内設定オプション-ゲーム-スキルアニメーション-オフ、設定オプション-画像-戦闘時の上下の黒帯-オフ",

"notice_success": "成功",
"notice_fail": "失敗",
Expand Down
2 changes: 1 addition & 1 deletion DATA/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

"BAAH_desc":"BAAH可以帮助你完成碧蓝档案/蔚蓝档案的日服,国际服,国服官服,国服B服的每日任务。配置文件存放于BAAH_CONFIGS文件夹内。",
"BAAH_get_version":"获取最新版本可以到Github下载,或进群下载",
"BAAH_attention":"模拟器分辨率请设置为1280*720,240DPI! 游戏内 设置选项-游戏-技能动画-关,设置选项-图像-分辨率-低,设置选项-图像-战斗时上下黑边-关",
"BAAH_attention":"模拟器分辨率请设置为1280*720,240DPI! 游戏内 设置选项-游戏-技能动画-关,设置选项-图像-战斗时上下黑边-关",

"notice_success":"成功",
"notice_fail":"失败",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Fully English logging support and function enhancement from [@ly5519](https://gi

Linux platform suitable by [@lonzzi](https://github.com/lonzzi)

Docker support by [@rote66](https://github.com/rote66)

Besides, many of them have joined the continues development of BAAH, thanks.

Packages used in this project:
Expand Down
13 changes: 12 additions & 1 deletion docs/README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Discord: https://discord.com/invite/7cEvvfcd
- 如果你使用的Mumu模拟器,请在设置的底部关闭后台保活运行
2. BA游戏内设置:
- 游戏:技能动画关;
- 画面:分辨率低;战斗时上下黑边关,
- 画面:战斗时上下黑边关,
- 咖啡厅的摄像机视角手动拉到了最高,最好家具全堆在屏幕最右侧

## 使用方式
Expand Down Expand Up @@ -131,3 +131,14 @@ BAAH与ALAS,MAA兼容,只是:
## 10. 如何让BAAH能够定时自动运行

BAAH的本质是一个可以接受参数的应用程序,当我们打开cmd,cd到BAAH文件夹下,执行`BAAH.exe 你的配置名.json`即可运行该配置。在了解了如何使用windows的任务计划程序后(参见视频教程末尾),您就可以使用任务计划程序控制程序的定时自动运行,结合BAAH中的定时开启/关闭模拟器功能,即可做到解放双手完成BAAH的每日任务。

## 11. GUI运行时参数

你可以在GUI启动时指定参数以实现更多设置,比如 "BAAH_GUI.exe --token 123456" 来为GUI页面设置密码。以下是可使用的参数列表

| Param | Desc | Default |
|-|-|-|
| --host | GUI启动时的ip | 127.0.0.1 |
| --port | GUI启动时的端口 | 8000 (自动查找) |
| --token | GUI密码 | None |
| --no-show | 开关,指定时不自动打开浏览器 | |
5 changes: 3 additions & 2 deletions docs/README_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- BAAH.py 执行某一个用户配置的任务文件
- jsoneditor.py 为gui的入口文件
- main.py 为主程序的入口文件
- package.py 为打包文件
- requirements.txt 所有依赖
```

Expand Down Expand Up @@ -69,7 +70,7 @@ post_condition是任务的后置判断,主要判断此任务结束时的位置
2. 在DATA/assets/下的ButtonName.py或PageName.py或PopupName.py内用文件名注册此pattern。
3. 在modules/AllTask/下新建此任务的文件夹,并在其内部新建同名py文件,将ataskformat.py内的内容复制粘贴进去,修改类名与构造函数的name默认属性为你的task名字。在modules/AllTask/__init__内导入此任务类
4. 修改此新任务的py文件内容
5. 在modules/AllTask/myAllTask.py的task_dict里添加 用户配置项目文件内的任务名 与 此新任务的 实例间映射关系
6. 在gui/__init__的real_taskname_to_show_taskname里添加 用户配置项目文件内的任务名 与 gui里显示的文本间的对应关系
5. 在modules/AllTask/myAllTask.py的`TaskName`里添加 用户配置项目文件内的任务名, 在`TaskInstanceMap`里添加 `task_config_name` 对应的 `i18n_key_name`, `task_module`映射关系
6. 在gui/refactor_pages/json_set_panel.py的get_config_list里添加 用户配置项目文件内的任务名 与 gui里显示的文本间的对应关系
7. 在DATA/i18n里添加对应文本
8. 如要添加配置项,在modules/configs/defaultSettings.py里添加配置默认值以及映射函数,在modules/configs/settingMaps定义映射关系即可。
5 changes: 3 additions & 2 deletions docs/README_dev_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- BAAH.py Executes tasks specified by a user configuration file
- jsoneditor.py Entry point for the GUI
- main.py Entry point for the main program
- package.py is the package file
- requirements.txt All dependencies
```

Expand Down Expand Up @@ -69,6 +70,6 @@ All the Task folders in the modules/AllTask directory with the same name as the
2. Register this pattern in ButtonName.py, PageName.py, or PopupName.py under DATA/assets using the file name.
3. Create a new folder for this task in modules/AllTask/ and create a same-named .py file inside it. Copy and paste the contents of ataskformat.py into it, and modify the class name and the default attribute of the constructor's name to your task name. Import this task class in modules/AllTask/__init__.
4. Modify the content of this new task's .py file.
5. In the task_dict of modules/AllTask/myAllTask.py, add a mapping between the task name in the user configuration file and an instance of this new task.
6. In real_taskname_to_show_taskname in gui/__init__, add a correspondence between the task name in the user configuration file and the text displayed in the GUI.
5. Locate the `TaskName` in modules/AllTask/myAllTask.py, add a task name that will be stored in the config. And add corresponding `i18n_key_name` and `task_module` in `TaskInstanceMap` of this `task_config_name`
6. Modify the `get_config_list` in gui/refactor_pages/json_set_panel.py, add a correspondence between the task name in the user configuration file and the text displayed in the GUI.
7. Add corresponding text in DATA/i18n.
20 changes: 19 additions & 1 deletion docs/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Discord: https://discord.com/invite/7cEvvfcd
- If you are using Mumu emulator, please disable background activity running at the bottom of the settings.
2. BA Game Settings:
- Game: Turn off skill animations;
- Graphics: Set to low resolution; Turn off black bars at the top and bottom during battles,
- Graphics: Turn off black bars at the top and bottom during battles,
- In the café, manually adjust the camera angle to the highest and stack all furniture on the right side of the screen if possible.

## Usage
Expand Down Expand Up @@ -127,3 +127,21 @@ BAAH is compatible with ALAS and MAA, but:
## 9. After Extracting, BAAH.exe Disappears

Please set the BAAH folder as an exception in your antivirus software, then extract it again. BAAH is completely open source.


## 10. How to let BAAH run automatically

BAAH itself is an excutable application, you can cd to the BAAH folder and run `BAAH.exe urconfig.json` in cmd to run script. After getting in touch with the Windows task scheduled (google), you can set a task and let it run automatically.


## 11. GUI parameters

You can set more parameters before BAAH_GUI running to enable more settings. For example, run "BAAH_GUI.exe --token 123456" will protect your GUI webpage with a password. Following is the paremeter table that GUI can use:


| Param | Desc | Default |
|-|-|-|
| --host | GUI will bind on this IP | 127.0.0.1 |
| --port | GUI will bind on this port | 8000, auto find |
| --token | GUI password | None |
| --no-show | Switch, will not open explorer when GUI is started if it is given | |
35 changes: 9 additions & 26 deletions modules/AllTask/InEvent/EventStory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from modules.AllTask.Task import Task

from modules.utils import (click, swipe, match, page_pic, button_pic, popup_pic, sleep, ocr_area, config, screenshot,
match_pixel)
match_pixel, istr, CN, EN)


class EventStory(Task):
Expand All @@ -20,11 +20,11 @@ class EventStory(Task):
靠蒙版是否存在判断剧情是否看过,默认有9关剧情
"""

def __init__(self, name="EventStory") -> None:
def __init__(self, max_level = 9, name="EventStory") -> None:
super().__init__(name)
self.last_fight_level_ind = -1
# 最大关卡数,这里不是下标,是关卡序号
self.max_level = 9
self.max_level = max_level

def pre_condition(self) -> bool:
return Page.is_page(PageName.PAGE_EVENT)
Expand Down Expand Up @@ -81,32 +81,10 @@ def judge_whether_and_do_view(self, this_level_ind):
return "yes"
return "no"

def get_biggest_level(self):
"""
通过下滑到底ocr获取最大关卡数
-1表示没有找到
"""
self.scroll_right_down()
sleep(1)
screenshot()
reslist = ocr_area((695, 416), (752, 699), multi_lines=True)
temp_max = -1
logging.info({"zh_CN": "ocr结果:" + str(reslist), "en_US": "ocr result: " + str(reslist)})
# 将每一个字母尝试转换成数字,如果是数字就比较目前最大
for res in reslist:
try:
# 最大不过14
temp_max = min(max(temp_max, int(res[0])), 14)
except:
pass
self.max_level = temp_max
return temp_max

def on_run(self) -> None:
# 点击Story标签
click((766, 98))
max_level = self.get_biggest_level()
max_level = self.max_level
if max_level == -1:
logging.warn({"zh_CN": "无法获取最大关卡数,结束", "en_US": "Failed to get the max level, end"})
return
Expand Down Expand Up @@ -155,6 +133,11 @@ def on_run(self) -> None:
logging.info({"zh_CN": "需要推最后一关剧情",
"en_US": "Need to push the last stage of the plot"})
self.do_view()
else:
logging.info(istr({
CN: "无法匹配首次标签,结束",
EN: "Unable to match the first reward tag, end"
}))
# 如果没有需要看的剧情了,那么就结束
click(Page.MAGICPOINT)
click(Page.MAGICPOINT)
Expand Down
13 changes: 8 additions & 5 deletions modules/AllTask/InEvent/InEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,10 @@ def get_biggest_level(self):
# 将每一个字母尝试转换成数字,如果是数字就比较目前最大
for res in reslist:
try:
# 最大不过12
temp_max = min(max(temp_max, int(res[0])), 12)
# 最大不过14
temp_max = min(max(temp_max, int(res[0])), 14)
except:
pass
self.max_level = temp_max
return temp_max

def on_run(self) -> None:
Expand Down Expand Up @@ -235,9 +234,13 @@ def on_run(self) -> None:
logging.info({"zh_CN": "成功进入Event页面", "en_US": "Successfully entered the Event page"})
today = time.localtime().tm_mday

# 检测并跳过剧情,如果已经进入过活动一次了,就不用再跳过剧情了
# 检测并推剧情,如果已经进入过活动一次了,就不用再推剧情了
if config.userconfigdict["AUTO_EVENT_STORY_PUSH"] and not config.sessiondict["HAS_ENTER_EVENT"]:
EventStory().run()
# 点击Story标签
click((766, 98))
click((766, 98))
story_max_level = self.get_biggest_level()
EventStory(max_level=story_max_level).run()
# 推图任务,如果已经进入过活动一次了,就不用再推图了
if config.userconfigdict["AUTO_PUSH_EVENT_QUEST"] and not config.sessiondict["HAS_ENTER_EVENT"]:
# 点击Quest标签
Expand Down
2 changes: 1 addition & 1 deletion modules/configs/MyConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyConfigger:
"""
维护config字典,包含软件config,用户任务config,语言包
"""
NOWVERSION="1.8.11"
NOWVERSION="1.8.12"
USER_CONFIG_FOLDER="./BAAH_CONFIGS"
SOFTWARE_CONFIG_FOLDER="./DATA/CONFIGS"
LANGUAGE_PACKAGE_FOLDER="./DATA/i18n"
Expand Down
2 changes: 1 addition & 1 deletion modules/utils/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def mouse_callback_s(event, x, y, flags, param):
# 截图
global start_x, start_y, drawing, quick_return_data
if right_click and event == cv2.EVENT_RBUTTONDOWN: # 检查是否是鼠标右键键点击事件
print(f"点击位置: ({x}, {y})", f"BGR 数组: {screenshot[y, x]}")
print(f"click: [{x}, {y}]", f"BGR: {[p for p in screenshot[y, x]]}")
bgr_result[0].append(screenshot[y, x][0])
bgr_result[1].append(screenshot[y, x][1])
bgr_result[2].append(screenshot[y, x][2])
Expand Down

0 comments on commit 85bc0bc

Please sign in to comment.