This commit is contained in:
wisz2021
2021-06-08 15:46:38 +08:00
parent 84818fef74
commit 6a72b9cfa0

View File

@@ -87,114 +87,118 @@ if ($.isNode()) {
}) })
async function pasture() { async function pasture() {
$.homeInfo = {}; try {
$.petidList = []; $.homeInfo = {};
$.crowInfo = {}; $.petidList = [];
await takeGetRequest('GetHomePageInfo'); $.crowInfo = {};
if (JSON.stringify($.homeInfo) === '{}') { await takeGetRequest('GetHomePageInfo');
return; if (JSON.stringify($.homeInfo) === '{}') {
} else {
if (!$.homeInfo.petinfo) {
console.log(`\n温馨提示:${$.UserName} 请先手动完成【新手指导任务】再运行脚本再运行脚本\n`);
return; return;
}
console.log('获取活动信息成功');
for (let i = 0; i < $.homeInfo.petinfo.length; i++) {
$.onepetInfo = $.homeInfo.petinfo[i];
$.petidList.push($.onepetInfo.petid);
if ($.onepetInfo.cangetborn === 1) {
console.log(`开始收鸡蛋`);
await takeGetRequest('GetEgg');
await $.wait(1000);
}
}
$.crowInfo = $.homeInfo.cow;
}
await $.wait(2000);
if ($.crowInfo.lastgettime) {
console.log('收奶牛金币');
await takeGetRequest('cow');
await $.wait(2000);
}
$.taskList = [];
$.dateType = ``;
for (let j = 2; j >= 0; j--) {
if (j === 0) {
$.dateType = ``;
} else { } else {
$.dateType = j; if (!$.homeInfo.petinfo) {
} console.log(`\n温馨提示:${$.UserName} 请先手动完成【新手指导任务】再运行脚本再运行脚本\n`);
await takeGetRequest('GetUserTaskStatusList'); return;
await $.wait(2000); }
await doTask(); console.log('获取活动信息成功');
await $.wait(2000); for (let i = 0; i < $.homeInfo.petinfo.length; i++) {
if (j === 2) { $.onepetInfo = $.homeInfo.petinfo[i];
//割草 $.petidList.push($.onepetInfo.petid);
console.log(`\n开始进行10次割草`); if ($.onepetInfo.cangetborn === 1) {
for (let i = 0; i < 10; i++) { console.log(`开始收鸡蛋`);
$.mowingInfo = {}; await takeGetRequest('GetEgg');
console.log(`开始第${i + 1}次割草`); await $.wait(1000);
await takeGetRequest('mowing');
await $.wait(2000);
if ($.mowingInfo.surprise === true) {
//除草礼盒
console.log(`领取除草礼盒`);
await takeGetRequest('GetSelfResult');
await $.wait(5000);
} }
} }
//横扫鸡腿 $.crowInfo = $.homeInfo.cow;
console.log(`\n开始进行10次横扫鸡腿`);
for (let i = 0; i < 10; i++) {
console.log(`开始第${i + 1}次横扫鸡腿`);
await takeGetRequest('jump');
await $.wait(2000);
}
} }
}
await takeGetRequest('GetHomePageInfo');
await $.wait(2000);
if (Number($.homeInfo.coins) > 5000) { await $.wait(2000);
let canBuyTimes = Math.floor(Number($.homeInfo.coins) / 5000); if ($.crowInfo.lastgettime) {
console.log(`\n共有金币${$.homeInfo.coins},可以购买${canBuyTimes}次白菜`); console.log('收奶牛金币');
for (let j = 0; j < canBuyTimes; j++) { await takeGetRequest('cow');
console.log(`${j + 1}次购买白菜`);
await takeGetRequest('buy');
await $.wait(2000); await $.wait(2000);
} }
$.taskList = [];
$.dateType = ``;
for (let j = 2; j >= 0; j--) {
if (j === 0) {
$.dateType = ``;
} else {
$.dateType = j;
}
await takeGetRequest('GetUserTaskStatusList');
await $.wait(2000);
await doTask();
await $.wait(2000);
if (j === 2) {
//割草
console.log(`\n开始进行10次割草`);
for (let i = 0; i < 10; i++) {
$.mowingInfo = {};
console.log(`开始第${i + 1}次割草`);
await takeGetRequest('mowing');
await $.wait(2000);
if ($.mowingInfo.surprise === true) {
//除草礼盒
console.log(`领取除草礼盒`);
await takeGetRequest('GetSelfResult');
await $.wait(5000);
}
}
//横扫鸡腿
console.log(`\n开始进行10次横扫鸡腿`);
for (let i = 0; i < 10; i++) {
console.log(`开始第${i + 1}次横扫鸡腿`);
await takeGetRequest('jump');
await $.wait(2000);
}
}
}
await takeGetRequest('GetHomePageInfo'); await takeGetRequest('GetHomePageInfo');
await $.wait(2000); await $.wait(2000);
}
let materialinfoList = $.homeInfo.materialinfo; if (Number($.homeInfo.coins) > 5000) {
for (let j = 0; j < materialinfoList.length; j++) { let canBuyTimes = Math.floor(Number($.homeInfo.coins) / 5000);
if (materialinfoList[j].type !== 1) { console.log(`\n共有金币${$.homeInfo.coins},可以购买${canBuyTimes}次白菜`);
continue; for (let j = 0; j < canBuyTimes; j++) {
} console.log(`${j + 1}次购买白菜`);
if (Number(materialinfoList[j].value) > 10) { await takeGetRequest('buy');
$.canFeedTimes = Math.floor(Number(materialinfoList[j].value) / 10);
console.log(`\n共有白菜${materialinfoList[j].value}每次喂10颗可以喂${$.canFeedTimes}`);
$.runFeed = true;
for (let k = 0; k < $.canFeedTimes && $.runFeed && k < 40; k++) {
$.pause = false;
console.log(`开始第${k + 1}次喂白菜`);
await takeGetRequest('feed');
await $.wait(2000); await $.wait(2000);
if ($.pause) { }
await takeGetRequest('GetHomePageInfo'); await takeGetRequest('GetHomePageInfo');
await $.wait(1000); await $.wait(2000);
for (let n = 0; n < $.homeInfo.petinfo.length; n++) { }
$.onepetInfo = $.homeInfo.petinfo[n]; let materialinfoList = $.homeInfo.materialinfo;
if ($.onepetInfo.cangetborn === 1) { for (let j = 0; j < materialinfoList.length; j++) {
console.log(`开始收鸡蛋`); if (materialinfoList[j].type !== 1) {
await takeGetRequest('GetEgg'); continue;
await $.wait(1000); }
if (Number(materialinfoList[j].value) > 10) {
$.canFeedTimes = Math.floor(Number(materialinfoList[j].value) / 10);
console.log(`\n共有白菜${materialinfoList[j].value}每次喂10颗可以喂${$.canFeedTimes}`);
$.runFeed = true;
for (let k = 0; k < $.canFeedTimes && $.runFeed && k < 40; k++) {
$.pause = false;
console.log(`开始第${k + 1}次喂白菜`);
await takeGetRequest('feed');
await $.wait(2000);
if ($.pause) {
await takeGetRequest('GetHomePageInfo');
await $.wait(1000);
for (let n = 0; n < $.homeInfo.petinfo.length; n++) {
$.onepetInfo = $.homeInfo.petinfo[n];
if ($.onepetInfo.cangetborn === 1) {
console.log(`开始收鸡蛋`);
await takeGetRequest('GetEgg');
await $.wait(1000);
}
} }
} }
} }
} }
} }
} catch (e) {
$.logErr(e)
} }
} }
@@ -356,11 +360,11 @@ function dealReturn(type, data) {
data = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]); data = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]);
if (data.ret === 0) { if (data.ret === 0) {
console.log(`投喂成功`); console.log(`投喂成功`);
} else if (data.ret === 2020 && data.data.maintaskId === 'pause') { } else if (data.ret === 2020) {
console.log(`投喂失败,需要先收取鸡蛋`); console.log(`投喂失败,需要先收取鸡蛋`);
$.pause = true; $.pause = true;
} else { } else {
console.log(`投喂失败,未知错误`); console.log(`投喂失败,${data.message}`);
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));
$.runFeed = false; $.runFeed = false;
} }