js: 地脉花3.0:地脉花寻找和战斗更新 (#633)

* 地脉花寻找和战斗更新 (#2)

* 初版,只改了蒙德1

* 添加纳塔7-烟谜主的路径和战斗超时设置,更新相关配置文件

* 优化寻找地脉花与开始战斗 (#1)

* fix bug

---------

Co-authored-by: 秋云 <physligl@gmail.com>

* fix typos. (#3)

* fix:交叉循环递归导致retryCount不自增

* refactor(AutoLeyLineOutcrop): 优化地脉花处理逻辑并更新配置文件

- 将 `errorThreshold` 从 100 调整为 50,提高位置判断的精确度
- 更新 `manifest.json` 的版本号和描述,适配 BetterGI 0.44.7
- 修复 `processLeyLineOutcrop` 函数中出现的重复调用
- 移除 `openOutcrop` 函数中的无用代码

* add: 稻妻2-海祇岛 路线

* fix locate&find LeyLineOutcrop

* fix retryCount导致index取值异常

* add: 璃月2-地中之盐 璃月3-瑶光滩 线路

* fix: 开启地脉花后的OCR识别逻辑

* feat: 增加两处导航领奖

1. 领取脚本运行前就已完成但未领奖励的本条线路中的第一个地脉花
2. attemptReward方法中,切换队伍后超出距离,导致无法按领奖按钮

* feat: 双倍产出支持

* feat: 非路线起始地脉花支持

* 更新 readme

* add: 踏鞴砂和药蝶谷

* add: 纳塔2-流晶支脉 线路

* fix: dobuleReward is not defined

* add: target json file.

* feat: create_LeyLinePositions_json

* 更新地脉花数量和怪物详情

* fix typos.

* 新的数据结构

* refactor: 移除强制运行模式,更新README

- 移除强制运行模式及其相关配置和逻辑
- 更新README,添加更新日志

* feat: 纳塔9-翘枝崖

* add: 纳塔10

* fix typos.

* Update config.json

* Update readme.md

* add: 八酝岛,彩石顶全部路线

* Update config.json

* add: 枫丹神像,容错改为40

* add: 纳塔8-花羽会 线路

* fix: 误触发领取,导致无法切换队伍

* fix: 前进超时时先挪远点角色再调整视野

* fix typos.

* add: 稻妻:鸣神岛

* add: 稻妻5-清籁岛 路径

* add: 稻妻5-清籁岛 路径

* style: 校验已有路径

* fix: 稻妻2-踏鞴砂 线路缺失

* Refactor: 调整函数顺序并补充变量说明,无功能变更

* refactor: 优化好感队切换逻辑,优化标记开关,更新README

* add: 蒙德最后一朵

* fix: 掉落物品导致前进的死循环;调整视野导致的鼠标移出屏幕外

* fix: 树脂耗尽时无法判断误触发领取页面

* add: 轻策庄、奥摩斯港、阿如村、荼诃落谷

* add: 无郁稠林

* feat: 支持非传送起点的路线,支持选择执行次数

* fix: typos.

---------

Co-authored-by: 秋云 <physligl@gmail.com>
Co-authored-by: 起个名字好难 <25520958+MisakaAldrich@users.noreply.github.com>
This commit is contained in:
ddaodan
2025-05-02 21:56:23 +08:00
committed by GitHub
parent b076c4072b
commit 5c1f27cce4
405 changed files with 18502 additions and 5158 deletions

View File

@@ -0,0 +1,74 @@
import os
import json
import re
from collections import defaultdict
# 配置
current_dir = os.path.dirname(os.path.abspath(__file__))
input_folder = os.path.join(current_dir, "assets", "pathing", "target")
template_path = os.path.join(current_dir, "assets", "mapPositions.json")
output_folder = os.path.join(current_dir)
os.makedirs(output_folder, exist_ok=True)
# 读取模板文件(人工维护的 mapPositions
with open(template_path, 'r', encoding='utf-8') as f:
template_data = json.load(f)
# 先把所有采集路线分类到子类下面
subclass_data = defaultdict(list)
for filename in os.listdir(input_folder):
if filename.endswith('.json'):
filepath = os.path.join(input_folder, filename)
with open(filepath, 'r', encoding='utf-8') as f:
data = json.load(f)
name = data['info']['name']
positions = data['positions']
# 解析名字
match = re.match(r'(\D+)(\d*)-(.+)-(\d+)', name)
if not match:
print(f"无法解析文件名: {name}")
continue
big_category = match.group(1) # 纳塔
subclass_number = match.group(2) # 2
subclass_name = match.group(3) # 硫晶支脉
order = int(match.group(4)) # 文件名里的 order
subclass_fullname = f"{big_category}{subclass_number}-{subclass_name}"
for pos in positions:
subclass_data[subclass_fullname].append({
"big_category": big_category,
"x": int(pos['x']),
"y": int(pos['y']),
"order": order
})
# 整理最终 leyLinePositions
leyLinePositions = defaultdict(list)
for subclass_name, points in subclass_data.items():
steps = max(p['order'] for p in points)
for p in points:
leyLinePositions[p['big_category']].append({
"x": p['x'],
"y": p['y'],
"strategy": subclass_name,
"steps": steps,
"order": p['order']
})
# 把 leyLinePositions 写回到模板数据里
template_data['leyLinePositions'] = leyLinePositions
# 输出最终合成文件
final_output_path = os.path.join(output_folder, 'config.json')
with open(final_output_path, 'w', encoding='utf-8') as f:
json.dump(template_data, f, ensure_ascii=False, indent=2)
print(f"已生成最终文件: {final_output_path}")