* 地脉花寻找和战斗更新 (#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>
77 lines
2.9 KiB
Python
77 lines
2.9 KiB
Python
import os
|
||
import json
|
||
import shutil
|
||
|
||
def create_target_jsons():
|
||
"""
|
||
Create modified JSON files in assets/pathing/target directory based on
|
||
JSON files in assets/pathing. Each new file will keep the info section
|
||
but contain only the last position with ID set to 1.
|
||
"""
|
||
# Get current directory and create paths
|
||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||
source_dir = os.path.join(current_dir, "assets", "pathing")
|
||
target_dir = os.path.join(source_dir, "target")
|
||
|
||
# Create target directory if it doesn't exist
|
||
if not os.path.exists(target_dir):
|
||
os.makedirs(target_dir)
|
||
print(f"创建目标文件夹: {target_dir}")
|
||
|
||
# Count variables
|
||
processed_count = 0
|
||
created_count = 0
|
||
|
||
# Process only the files directly in the assets/pathing folder (not subfolders)
|
||
for filename in os.listdir(source_dir):
|
||
file_path = os.path.join(source_dir, filename)
|
||
|
||
# Skip directories and non-JSON files
|
||
if os.path.isdir(file_path) or not filename.endswith('.json'):
|
||
continue
|
||
|
||
try:
|
||
with open(file_path, 'r', encoding='utf-8') as f:
|
||
data = json.load(f)
|
||
|
||
# Skip files that don't have the expected structure
|
||
if 'info' not in data or 'positions' not in data or not data['positions']:
|
||
print(f"跳过文件 {filename}: 文件结构不符")
|
||
continue
|
||
|
||
# Create new JSON with only the info section and last position
|
||
new_data = {
|
||
'info': data['info'],
|
||
'positions': []
|
||
}
|
||
|
||
# Get the last position and set its ID to 1
|
||
last_position = data['positions'][-1].copy()
|
||
last_position['id'] = 1
|
||
new_data['positions'] = [last_position]
|
||
|
||
# Save to target directory
|
||
target_path = os.path.join(target_dir, filename)
|
||
with open(target_path, 'w', encoding='utf-8') as f:
|
||
json.dump(new_data, f, indent=2, ensure_ascii=False)
|
||
|
||
processed_count += 1
|
||
created_count += 1
|
||
print(f"已处理: {filename} → {os.path.join('target', filename)}")
|
||
|
||
except Exception as e:
|
||
print(f"处理 {filename} 时出错: {e}")
|
||
|
||
print(f"\n任务完成!")
|
||
print(f"已处理 {processed_count} 个JSON文件")
|
||
print(f"已创建 {created_count} 个目标文件")
|
||
|
||
if __name__ == "__main__":
|
||
print("开始生成目标JSON文件...")
|
||
print("此脚本将:")
|
||
print("1. 读取 assets/pathing 下的所有JSON文件")
|
||
print("2. 为每个文件创建一个新版本,只保留最后一个点位并将其ID设为1")
|
||
print("3. 将新文件保存到 assets/pathing/target 目录")
|
||
print("="*50)
|
||
|
||
create_target_jsons() |