* 战斗好感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>