Commit Graph

12 Commits

Author SHA1 Message Date
火山
46d00e0373 AutoFriendshipFight 稳定性重构:资源清理、异步收口、配置统一(v1.5.8) (#3197)
* 战斗好感js:释放前增加延迟,并简化清理逻辑

通过等待 500 毫秒的休眠操作,为.NET 任务在释放 V8 对象后预留额外执行时间,以此避免触发对象已释放异常(ObjectDisposedException)。简化finally代码块中battleTask的清理逻辑:仅当battleTask和awaitBattleTask均已赋值时才执行清理操作;将任务与等待超时设置为竞争执行;清理过程中静默忽略所有错误,防止因取消操作或超时问题导致finally代码块阻塞

* Bump version to 1.5.5 and update changelog

Update manifest version to 1.5.5 and add a v1.5.5 entry to the README changelog. The release notes mention stability improvements: add a short delay after releasing resources to reduce ObjectDisposedException likelihood and optimize fight task cleanup to avoid stuck cleanup phases.

* v1.5.6:移除游泳状态持久化监测,统一使用 Assets/ 路径

将资源 / 路径引用从 assets/ 重命名为 Assets/(涉及 README 文档、main.js 路径加载逻辑、AutoPath 查找逻辑)。
移除持久化游泳追踪功能及相关设置 / 逻辑:删除 DEFAULT_SWIM_CONSECUTIVE_LIMIT 常量、SwimTracker 实现代码、游泳相关错误码 / 提示信息,以及 settings.json 中的 swimConsecutiveLimit 配置项。
简化游泳处理逻辑:检测到盗宝团进入游泳状态时,立即恢复至雕像状态,并将该回合判定为失败。
在释放图像素材前添加 500 毫秒的异步等待休眠,降低对象已释放异常(ObjectDisposedException)的触发风险。
更新 README 文档的更新日志,记录移除持久化游泳追踪功能、修改 Assets/ 路径的变更。

* AutoFriendshipFight: resource cleanup & swim fix

Bump version to v1.5.7 and add changelog entry. Improve resource lifecycle handling by making template recognition objects mutable, extending post-exit sleep, explicitly disposing template/mat objects, and nulling references to reduce ObjectDisposedException risk. Add SwimTracker helper to centralize swim/statue recovery detection for 盗宝团. Harden executeBattleTasks: introduce awaitBattleTask flag and longer wait, better race/cleanup semantics for background AutoFight tasks, improved error handling/logging, and ensure path promises are caught when timing out. README and manifest updated accordingly.

* Make swim recovery per-enemy configurable

Introduce a swimRecoveryEnabled flag in the enemy config and change SwimTracker to read that flag (falling back to previous behaviour: only 武盗/盗宝团 enabled). Replace the hardcoded enemyType === "盗宝团" check in executeSingleFriendshipRound with SwimTracker(enemyType).enabled. Remove the now-unused getTodayKey helper and delete swim_stats.json as part of cleanup. This centralizes the swim-recovery toggle so it can be extended per enemy and removes obsolete daily swim stats storage.

* Force recover flag on statue recovery

When battleResult.status is "recovered_to_statue", always call recoverAfterFailure with a true second argument and add a Chinese comment explaining the game auto-returned to the seven-day statue. This simplifies the previous conditional (enemyType === "盗宝团") and ensures consistent recovery handling for this status.

* Make disableAsyncFight apply to all enemies

Respect the disableAsyncFight setting for all enemy types (including 盗宝团). main.js now only uses the async/ocr detect flow for 盗宝团 when disableAsyncFight is false. README and settings.json labels were updated to reflect that disabling async fights makes synchronous mode apply to every enemy, improving stability and unifying behavior across encounters.

* Toggle battle path flag for 盗宝团

Pass a conditional flag to runBattlePathToBattlePoint so it receives true when enemyType === "盗宝团" (previously always false). This enables a special path/behavior for the 盗宝团 enemy during executeSingleFriendshipRound to handle its unique movement/positioning.

* Update repo/js/AutoFriendshipFight/README.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix README quotes and assets path casing

Replace ASCII quotes with Chinese-style quotes around “战斗结束检测” for typographic consistency, and correct the assets directory name from `Assets/AutoPath/` to `assets/AutoPath/` in the README to match repository naming and avoid confusion.

* Use lowercase 'assets' paths

Normalize asset path casing in repo/js/AutoFriendshipFight/main.js by replacing "Assets" with "assets" for image and AutoPath JSON references. Updated template image loads (exp.png, mora.png) and pathing file accesses in AutoPath, getBattlePointFromBattlePath, and runBattlePathToBattlePoint to avoid file-not-found issues on case-sensitive filesystems. No behavioral logic changes.

* Add managed game region caching and OCR helpers

Introduce a gameRegionManager to centralize screenshot capture/caching and lifecycle management (retain/release, disposeOldGameRegions, flushGameRegionCache, getManagedGameRegion) to reduce ObjectDisposedException risks and enforce minimum capture intervals. Add OCR utilities (normalizeOcrText, readActivityListText, readActivityListTextFromCapture) and replace direct captureGameRegion usages in task detection, result waiting and exp/mora detection with the managed API. Add SWIM_RECOVERED error message constant and use it for swim-recovery paths. Bump manifest version to 1.5.8 and update README (note stability/paths change and assets path case). Misc: small style/robustness fixes (logging, null checks, cancellation handling) and ensure cache is flushed on exit.

* Improve flushGameRegionCache disposal and timeouts

Add timeouts and safer disposal logic to flushGameRegionCache to avoid indefinite waits. Wait for capturing/disposing flags with a short deadline and log+abort if exceeded; during flush only remove regions that are not currently borrowed (borrowCount<=0), with a secondary deadline to avoid blocking. Preserve borrow counts for still-borrowed regions, remove stale borrowCount entries for regions no longer in cache, and reset lastCaptureTs when cache becomes empty. Adds warning logs for timeout cases.

* Refactor formatting and resource handling

Reformat code for readability and tighten resource management: multiline/enhanced formatting for ENEMY_CONFIG and template matches, normalize indentation/spacing across functions. Improve gameRegionManager lifecycle (clearer isCapturing/isDisposing handling), add waits and timeout warnings in flushGameRegionCache, ensure borrowCountByRegion is cleaned for removed regions, and make getManagedGameRegion capture/dispose flow more robust. Also standardize safeDispose and empty-catch behavior, tidy OCR/battle/task related flows and error handling. These changes aim to reduce resource leaks, race conditions and improve maintainability without altering core logic.

* Refactor battle flow and naming; add helpers

Refactor battle execution and main loop for clarity and robustness. Renamed core functions for clarity (AutoFriendshipDev -> runFriendshipLoop, LogTimeTaken -> formatElapsedTime, CalculateEstimatedCompletion -> estimateCompletionTime) and added numerous helper utilities to centralize behavior: cancellation/silence helpers, timeout/error detection, wrapper helpers, cleanup logic, and separate sync/async battle execution paths. Extracted specialized flows (treasure hoarder async round, swim-recovery-aware path runner, and unified battle result handling) to reduce duplication and improve error/recovery handling (including auto-return-to-statue logic). Overall changes improve async coordination, avoid unhandled promise rejections, and make time formatting/logging consistent.

* Improve battle timeout & party switch error handling

Propagate battle timeouts and rejection errors as exceptions and map timeouts to a script error code for consistent reporting. In executeBattleTasksSyncMode, throw a battle_timeout instead of returning a false result. In executeBattleTasksAsyncMode, always throw battle_rejected errors (removed the cancellation-only check). In executeBattleTasks catch, convert battle_timeout to a standardized script error (ERROR_CODES.BATTLE_TIMEOUT).

Enhance switchPartyIfNeeded: after teleporting to the Statue of The Seven, verify the switch result and if it still fails, log and notify the user, return to the main UI and throw an error instead of silently continuing. Also ensure cancellation errors are rethrown and other errors are propagated instead of being swallowed.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-05-10 09:53:20 +08:00
火山
d3165db775 更新战斗好感js (#3164)
* 更新战斗好感js

尝试优化了一下

* 修正代码

* 补充JSDoc

* Update main.js
2026-04-28 12:31:15 +08:00
火山
8e4b02d627 改进 AutoFriendshipFight 的稳定性与错误处理 (#3161)
* 改进 AutoFriendshipFight 的稳定性与错误处理

改进 AutoFriendshipFight 的稳定性与错误处理:

- 新增 swimConsecutiveLimit 设置项,并通过 swim_stats.json 记录每日/连续触发“游泳”事件的次数。
- 重构战斗流程: runBattlePathAndFight 、 executeBattleTasks 、 waitForBattleResult 现在返回明确的状态(success/failure/out_of_area/cancelled),并更好地处理取消/超时等情况。
- 改进 OCR 与资源管理:复用并释放经验/摩拉模板 Mat(exp/mora),安全释放截图/OCR 对象,减少循环中的资源泄露风险。
- 增加 AutoPath 封装与安全的文件/路径工具( fileExistsSafe 、 normalizePathForCompare ),避免路径执行/ runFile 出错时出现未处理异常。
- 增加通用工具:安全读取地图坐标、取消检测辅助函数、每日游泳统计的加载/保存/重置,以及战斗点缓存等。
- 其它修复:超时参数校验、正确声明 runTimes 、改进切队逻辑,以及更健壮的日志与通知输出等。
这些改动旨在防止后台残留导致的资源占用问题,更好地检测与处理游泳相关失败,并让战斗/OCR 循环更确定、更可恢复。

* Change fight timeout default from 120 to 30 seconds

* Update fight timeout default value to 120 seconds

* 更改版本号
2026-04-26 21:00:34 +08:00
mno
a0254b66e3 js:狗粮批发2.1.0 战斗好感1.5.1 锄地一条龙 2.2.9部分战斗策略调整 (#2864)
* js:狗粮批发2.1.0

移除路径内调时,改为自定义配置控制

* js:战斗好感

1.更新了版本号
2.修复摩拉识别使用的错误模板图片路径
3.增加1000Stars选项

* combat:战斗策略

1.新增仅用于盗宝团好感的那维莱特策略
2.为不适合锄地的策略添加-副本后缀
3.删除可完全被万能策略上位替代的策略:月草c,伊芙爱万玛,芙茜万夏
4.删除完全不合理的莱爱万夜和莱爱万夜.只用战技(并不适合锄地却写适合锄地)

* 改为归档

* js:锄地一条龙

修改触发分配结果不合理的触发条件

* 移除小怪2000部分的json5文件

锄地规划纯害人来的
2026-02-12 14:38:30 +08:00
秋云
004449fef8 remove: 回退超时取消特性 移除卡时间功能 2026-02-07 22:55:02 +08:00
mno
2ac6146248 js锄地,战斗好感更新,combat 万能策略龙王更新,统一逗号格式 (#2845)
* Update 万能战斗策略(萌新推荐).txt

1.龙王策略修正,增加等待防止打不开l
2.按火山老师要求批量将,,替换为,

* js:战斗好感

1.允许禁用异步战斗,改为使用正常的战斗结束检测
2.允许开启经验和摩拉检测,连续两轮未识别到经验或摩拉将提前终止
3.修改盗宝团战斗点至不会被怪物提前锁定的地点,防止被肘飞
4.修复了一些问题,曾导致意外的提前终止或使用快捷键终止时仍然循环50次

* js:锄地一条龙

修改西格德路线
加入利亚姆路线
地图为sift时不再尝试进行泥头车
修改部分路线

* js:采集cd管理

更新物品cd,修正黑名单持久化逻辑
2026-02-05 17:09:49 +08:00
秋云
972fae3ebf fix(好感): 默认值失效问题 2025-08-23 19:21:03 +08:00
this-Fish
bd5fc7aca5 JS:战斗好感:自动好感度&卡时间 1.4.2 (#1602)
v1.4.2新增拾取模式,能选择不拾取
避免每天运行,拾取過多不能分解的掉落物,导至不能分解的掉落物逹致上限
2025-08-16 09:41:17 +08:00
秋云
dec490208d add(好感js):雷萤术士 2025-06-14 22:19:53 +08:00
秋云
24154fd13e feat: 蕈兽好感 2025-06-11 07:18:11 +08:00
秋云
b39e6cca65 add: 鳄鱼好感 2025-05-31 20:53:54 +08:00
秋云
12f439dab4 feat: 盗宝团好感 -> 战斗好感,添加愚人众好感 2025-05-25 16:40:58 +08:00