bettergi-scripts-list/repo/js/AutoLeyLineOutcrop/utils/loadSettings.js
yuling 7dad5733f8
自动地脉花掉落物主动捡取 (#3473)
* 新增两个简单的脚本

* 1

* 移除重复功能的脚本,把新功能添加到现有脚本上

* 署名顺带更新文档

* bug fix

* 清理了忘记处理的调试代码,修复了识别不到浓缩的bug,修复树脂耗尽模式+刷取次数取小值的情况下,当OCR计算次数>手动设置刷取次数时无法正确终止脚本的bug

* 修复AI留下的作用域bug

* 调整设置缩进

* 设置文案修改

* 调整缩进

* fix typo.

* 清理新增脚本提交

* 修复双倍模式下可能会用到浓缩的bug,统一了错误处理逻辑

---------

Co-authored-by: 起个名字好难的喵 <[email protected]>
2026-08-18 17:07:29 +08:00

109 lines
No EOL
4.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 加载、验证、输出用户设置
* @returns {Object} 处理过的设置对象
*/
this.loadSettings =
function () {
try {
// 直接使用全局settings对象而不是重新创建
// 这样能保留原始设置内容
// 验证必要的设置
if (!settings.start) {
throw new Error("请仔细阅读脚本介绍和手册,并在调度器内进行配置,如果你是直接运行的脚本,请将脚本加入调度器内运行!");
}
if (!settings.leyLineOutcropType) {
throw new Error("请选择你要刷取的地脉花类型(经验书/摩拉)");
}
if (!settings.country) {
throw new Error("请在游戏中确认地脉花的第一个点的位置,然后在js设置中选择地脉花所在的国家。");
}
if (settings.friendshipTeam && !settings.team) {
throw new Error("未配置战斗队伍!当配置了好感队时必须配置战斗队伍!");
}
if (settings.isResinExhaustionMode && settings.onlySurgeMode) {
throw new Error("树脂耗尽模式和只刷双倍模式是互斥选项,不能同时开启!\n请根据需求选择其中一种模式");
}
// 为了向后兼容,确保某些设置有默认值
//settings.timeout = settings.timeout * 1000 || 120000;
// 处理刷取次数
if (!settings.count || !/^-?\d+\.?\d*$/.test(settings.count)) {
log.warn(`刷取次数 ${settings.count} 不是数字,使用默认次数6次`);
settings.timesValue = 6;
} else {
// 转换为数字
const num = parseFloat(settings.count);
// 范围检查
if (num < 1) {
settings.timesValue = 1;
log.info(`⚠️ 次数 ${num} 小于1,已调整为1`);
} else {
// 处理小数
if (!Number.isInteger(num)) {
settings.timesValue = Math.floor(num);
log.info(`⚠️ 次数 ${num} 不是整数,已向下取整为 ${settings.timesValue}`);
} else {
settings.timesValue = num;
}
}
}
// 记录使用的设置
log.info(`地脉花类型:${settings.leyLineOutcropType}`);
log.info(`国家:${settings.country}`);
if (settings.friendshipTeam) {
log.info(`好感队:${settings.friendshipTeam}`);
}
if (settings.isResinExhaustionMode) {
log.warn("树脂耗尽模式已开启,若统计成功将覆盖设置的刷取次数");
} else if (settings.onlySurgeMode) {
log.info(`只刷双倍模式已开启(双倍次数用尽后将提前退出)`);
} else {
log.info(`刷取次数:${settings.timesValue}`);
}
// 设置通知状态
isNotification = settings.isNotification;
// 设置一条龙模式
oneDragonMode = settings.oneDragonMode;
// 设置拾取材料时间
if (!settings.pickDropsSeconds || !/^\d+$/.test(settings.pickDropsSeconds) || parseInt(settings.pickDropsSeconds) < 1) {
settings.pickDropsSecondsValue = 25;
if (settings.pickDropsSeconds && !/^\d+$/.test(settings.pickDropsSeconds)) {
log.warn(`拾取时间 "${settings.pickDropsSeconds}" 不是有效数字,已使用默认值 25 秒`);
} else if (settings.pickDropsSeconds && parseInt(settings.pickDropsSeconds) < 1) {
log.warn(`拾取时间 ${settings.pickDropsSeconds} 小于 1,已使用默认值 25 秒`);
}
} else {
settings.pickDropsSecondsValue = parseInt(settings.pickDropsSeconds);
}
if (settings.pickDropsAfterReward) {
log.info(`战斗后拾取材料:开启,拾取时间 ${settings.pickDropsSecondsValue} 秒`);
}
if (settings.monsterMaterialMode) {
log.info(`20树脂模式:开启`);
}
if (settings.onlySurgeMode && !settings.isResinExhaustionMode) {
log.info(`只刷双倍模式:开启(建议配合"使用冒险之证寻找地脉花"选项)`);
}
if (isNotification) {
notification.send(`全自动地脉花开始运行,以下是本次运行的配置:\n\n地脉花类型:${settings.leyLineOutcropType}\n国家:${settings.country}\n刷取次数:${settings.timesValue}`);
}
} catch (error) {
throw error;
}
}