mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-16 03:33:25 +08:00
JS : 尘歌壶一条龙1.2 (#2505)
* 尘歌壶一条龙1.2 補充固定脚本环境的游戏分辨率 開放不领取角色好感、不领取洞天宝钱選項 開放自定義 週几進入尘歌壶運行尘歌壶流程 開放自定義 週几進入尘歌壶后购买物品、烹饪、锻造 * CRLF to LF
This commit is contained in:
@@ -1,17 +1,51 @@
|
||||
async function main() {
|
||||
setGameMetrics(1920, 1080, 1);
|
||||
|
||||
const today = new Date().getDay();
|
||||
const isMonday = today === 1;
|
||||
// 获取调整后的周几
|
||||
const dayOfWeek = getAdjustedDayOfWeek();
|
||||
|
||||
// 检查是否需要跳过整个尘歌壶流程
|
||||
if (settings.week) {
|
||||
const weekArray = validateAndStoreNumbers(settings.week);
|
||||
|
||||
if (!weekArray) {
|
||||
log.error("周设置格式错误,请使用类似'0,1,3,5,7'的格式(0表示每天运行),将跳过周检查");
|
||||
} else if (weekArray.length > 0) {
|
||||
// 如果设置了0,表示每天运行,跳过周检查
|
||||
if (weekArray.includes(0)) {
|
||||
log.info("周设置中包含0,每天运行尘歌壶流程");
|
||||
} else if (!weekArray.includes(dayOfWeek)) {
|
||||
log.info(`今天是周 ${dayOfWeek},不在设置的周 ${settings.week} 中,跳过尘歌壶流程`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否为周一,周三或周六
|
||||
if (!isScheduledDay()) {
|
||||
log.info("今日非周一,周三或周六,脚本不执行");
|
||||
return;
|
||||
// 解析exchangeWeek设置,判断今天是否兑换物品
|
||||
let exchangeWeekArray = [1]; // 默认周一
|
||||
if (settings.exchangeWeek) {
|
||||
const result = validateAndStoreNumbers(settings.exchangeWeek);
|
||||
if (result) {
|
||||
exchangeWeekArray = result;
|
||||
} else {
|
||||
log.error("exchangeWeek设置格式错误,将使用默认值(周一)");
|
||||
}
|
||||
}
|
||||
|
||||
let shouldExchange = false;
|
||||
if (exchangeWeekArray.includes(0)) {
|
||||
shouldExchange = true;
|
||||
log.info("exchangeWeek设置为0,每天兑换物品");
|
||||
} else if (exchangeWeekArray.includes(dayOfWeek)) {
|
||||
shouldExchange = true;
|
||||
}
|
||||
|
||||
// 检查配置
|
||||
checkSettings();
|
||||
|
||||
await genshin.returnMainUi();
|
||||
await sleep(1000);
|
||||
|
||||
// 打开背包并切换到小道具
|
||||
await openBackpack();
|
||||
|
||||
@@ -33,8 +67,8 @@ async function main() {
|
||||
// 领取好感度以及洞天宝钱
|
||||
await collectRewards();
|
||||
|
||||
if (isMonday) {
|
||||
log.info("今天是周一,兑换物品");
|
||||
if (shouldExchange) {
|
||||
log.info(`今天是周 ${dayOfWeek},兑换物品`);
|
||||
// 兑换物品
|
||||
await exchangeItems();
|
||||
}
|
||||
@@ -45,11 +79,11 @@ async function main() {
|
||||
await sleep(1000);
|
||||
click(960, 540);
|
||||
|
||||
// 周一执行锻造任务和烹饪任务
|
||||
if (isMonday) {
|
||||
log.info("今天是周一,执行锻造任务");
|
||||
// 周N执行锻造任务和烹饪任务
|
||||
if (shouldExchange) {
|
||||
log.info(`今天是周 ${dayOfWeek},执行锻造任务`);
|
||||
if (settings.forgingRoute) await handleForging();
|
||||
log.info("今天是周一,执行烹饪任务");
|
||||
log.info(`今天是周 ${dayOfWeek},执行烹饪任务`);
|
||||
if (settings.cookingRoute) await handleCooking();
|
||||
keyDown("a");
|
||||
await sleep(2000);
|
||||
@@ -113,11 +147,43 @@ async function handleForging() {
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前是否为周一,周三或周六
|
||||
function isScheduledDay() {
|
||||
const today = new Date().getDay(); // 0=周日, 1=周一, ..., 6=周六
|
||||
return today === 1 || today === 3 || today === 6; // 周一,周三或周六
|
||||
}
|
||||
// 获取当前周(考虑00:00~04:00视为前一天)
|
||||
function getAdjustedDayOfWeek() {
|
||||
const now = new Date();
|
||||
let dayOfWeek = now.getDay(); // 0-6 (0是周日)
|
||||
const hours = now.getHours();
|
||||
|
||||
// 如果时间在00:00~04:00之间,视为前一天
|
||||
if (hours < 4) {
|
||||
dayOfWeek = dayOfWeek === 0 ? 6 : dayOfWeek - 1; // 前一天
|
||||
log.info(`当前时间 ${now.getHours()}:${now.getMinutes()},视为前一天(周 ${dayOfWeek === 0 ? 7 : dayOfWeek})`);
|
||||
} else {
|
||||
log.info(`当前时间 ${now.getHours()}:${now.getMinutes()},使用当天(周 ${dayOfWeek === 0 ? 7 : dayOfWeek})`);
|
||||
}
|
||||
|
||||
// 转换为1-7格式(7代表周日)
|
||||
return dayOfWeek === 0 ? 7 : dayOfWeek;
|
||||
}
|
||||
|
||||
// 验证周设置格式
|
||||
function validateAndStoreNumbers(input) {
|
||||
if (!input) return false;
|
||||
|
||||
// 去除所有空格
|
||||
const cleanedInput = input.replace(/\s/g, '');
|
||||
|
||||
// 使用正则表达式检测是否符合期望格式
|
||||
const regex = /^([0-7])(,([0-7]))*$/;
|
||||
|
||||
// 检测输入字符串是否符合正则表达式
|
||||
if (regex.test(cleanedInput)) {
|
||||
// 将输入字符串按逗号分割成数组
|
||||
const numbers = cleanedInput.split(',');
|
||||
return numbers.map(Number);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function exchangeItems() {
|
||||
if (!settings.itemsToBuy) {
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "尘歌壶一条龙",
|
||||
"version": "1.1",
|
||||
"version": "1.2",
|
||||
"description": "自动放置并进入尘歌壶,寻找阿圆,领取洞天宝钱和好感,做饭,锻造(需要配置进入尘歌壶以后的路线),支持自动购买指定物品。推荐洞天摹数81708444664",
|
||||
"tags": ["尘歌壶","模拟点击"],
|
||||
"authors": [
|
||||
{
|
||||
"name": "miludelongwang",
|
||||
"links": "https://github.com/miludelongwang"
|
||||
},
|
||||
{
|
||||
"name": "蜜柑魚",
|
||||
"links": "https://github.com/this-Fish"
|
||||
}
|
||||
],
|
||||
"settings_ui": "settings.json",
|
||||
|
||||
@@ -18,5 +18,27 @@
|
||||
"name": "cookingRoute",
|
||||
"type": "input-text",
|
||||
"label": "烹饪路径(格式同上),示例:W 1000\n周一自动执行"
|
||||
},
|
||||
{
|
||||
"name": "skipCharacterReward",
|
||||
"type": "checkbox",
|
||||
"label": "不领取角色好感(注意是不领取)"
|
||||
},
|
||||
{
|
||||
"name": "skipTreasureReward",
|
||||
"type": "checkbox",
|
||||
"label": "不领取洞天宝钱(注意是不领取)"
|
||||
},
|
||||
{
|
||||
"name": "week",
|
||||
"type": "input-text",
|
||||
"label": "指定周几执行\n(使用\",\"分割多个周几)\n例:输入\"2,3,4,5,6,7\",会在周2,3,4,5,6,日才运行尘歌壶流程",
|
||||
"default": "1,3,6"
|
||||
},
|
||||
{
|
||||
"name": "exchangeWeek",
|
||||
"type": "input-text",
|
||||
"label": "指定在周几购买物品、烹饪、锻造\n(使用\",\"分割多个周几,0表示每天)\n例:输入\"1,3,5\",会在周一、三、五购买物品、烹饪、锻造\n默认:1(周一)",
|
||||
"default": "1"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user