Skip to content

Commit

Permalink
Merge pull request #12 from Night-stars-1/main
Browse files Browse the repository at this point in the history
feat: 添加研学资源包
  • Loading branch information
Ritesmith authored Sep 8, 2024
2 parents 49f7cb2 + bbbbbbf commit 25e2f30
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: res_build
on:
push:
branches: [ main ]
paths:
- 'assets/resource_picli/**'
- 'assets/interface.json'
workflow_dispatch:

jobs:
Expand Down
39 changes: 39 additions & 0 deletions assets/resource_picli/data/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"神秘快递": "拆开",
"科研助力": "立刻联系附近基金会的驻点询问。",
"氧气瓶": "抽!",
"画性大发": "我正好有带",
"样本搜集": "拿出采样套装进行采集",
"群山之巅": "拿出氧气瓶",
"手杖妙用": "抓起登山杖去够",
"珍贵笔记": "还好有研学笔记本",
"寒雾": "主动跟上那位器者。",
"风雪之途": "与雪景寒林图喝茶。",
"山雪之约": "前往常去的茶馆。",
"巡山雪": "到路途中去。",
"再遇寒雪": "顺势聊起山水画的事情。",
"山之形": "潮流文化集市和商场。",
"青绿争端": "安静地等待他。",
"小小风波": "去符合心境的地方",
"幻梦成景": "“非常有趣”的兴奋之情。",
"传达之声": "尽自己所能推荐。",
"神秘传闻": "寻找有人的落脚处。",
"山中之兽": "由你调查消息来源。",
"出行必备": "询问溪山行旅图的意见。",
"探索之夜": "在野外扎营。",
"山间来信": "你找错了地方?",
"浪漫收集": "去有故事的地方!",
"奇怪的画作": "找找草稿的主人吧。",
"线路规划": "请她帮忙指一个方向。",
"奇诡志异": "和他们一起聊故事。",
"游客照": "向茶叶生产画请教技巧。",
"时间与画": "关于一日山景。",
"小心脚下": "拿起来仔细观察",
"护林小屋": "询问护林员",
"杂学之用": "询问千里江山图",
"日出东山": "来到民宿的屋顶",
"解惑": "帮助回答",
"润水": "上前询问",
"游学所得": "讲旅行趣事",
"建议": "提出你的想法"
}
13 changes: 10 additions & 3 deletions py/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-07-18 23:52:39
LastEditors: Night-stars-1 nujj1042633805@gmail.com
LastEditTime: 2024-09-08 15:52:35
"""
'''
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-07-18 23:52:39
Expand Down Expand Up @@ -54,7 +60,7 @@ async def main():

maa_inst.register_recognizer("event_select", event_select)

await maa_inst.run_task("war_one")
await maa_inst.run_task("MyCustomRecTask")


class EventSelect(CustomRecognizer):
Expand All @@ -67,6 +73,7 @@ def analyze(
{"OCR": {"recognition": "OCR", "expected": "识别事件名称", "roi": [593, 113, 516, 46]}},
)
pos_data = json.loads(pos_data)
print(pos_data)
if len(pos_data["all"]) < 1:
print("事件标题获取失败")
return False, (0, 0, 100, 100), "事件标题获取失败"
Expand All @@ -81,8 +88,8 @@ def analyze(
{"OCR": {"recognition": "OCR", "expected": option, "roi": [598, 383, 478, 217]}},
)
print(f"识别结果: {status}, 坐标: {option_rect}")
context.click(int(option_rect[0] + option_rect[2] / 2), int(option_rect[1] + option_rect[3] / 2))
return status, (0, 0, 100, 100), "事件选择"
# context.click(int(option_rect[0] + option_rect[2] / 2), int(option_rect[1] + option_rect[3] / 2))
return False, (0, 0, 100, 100), "事件选择"
else:
print("事件标题获取失败")
return False, (0, 0, 100, 100), "事件标题获取失败"
Expand Down
Binary file modified res.zip
Binary file not shown.
15 changes: 12 additions & 3 deletions res_zip.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-09-07 22:31:32
LastEditors: Night-stars-1 nujj1042633805@gmail.com
LastEditTime: 2024-09-08 16:16:33
"""
import os
import subprocess
import zipfile
Expand All @@ -12,10 +18,11 @@ def add_folder_to_zip(zipf: zipfile.ZipFile, folder_path: str):
:param folder_path: 要添加到 ZIP 文件中的文件夹路径
"""
for foldername, subfolders, filenames in os.walk(folder_path):
print(filenames)
for filename in filenames:
file_path = os.path.join(foldername, filename)
# 在 ZIP 文件中创建相对路径
relative_path = file_path.replace(r"assets\resource\base", "")
relative_path = file_path.replace(r"/assets/resource_picli/base", "")
zipf.write(file_path, relative_path)

def get_git_commit_count():
Expand All @@ -40,8 +47,10 @@ def get_git_commit_count():

# 创建压缩包并添加文件
with zipfile.ZipFile(zip_filename, 'w', zipfile.ZIP_DEFLATED) as zipf:
add_folder_to_zip(zipf, r'assets\resource\base\pipeline')
add_folder_to_zip(zipf, r'assets\resource\base\image')
add_folder_to_zip(zipf, './assets/resource_picli/base/pipeline')
add_folder_to_zip(zipf, './assets/resource_picli/base/image')
add_folder_to_zip(zipf, './assets/resource_picli/data')
zipf.write('./assets/interface.json', 'interface.json')

with open('version.txt', 'w', encoding='utf-8') as f:
f.write(get_git_commit_count())
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1
52

0 comments on commit 25e2f30

Please sign in to comment.