MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / runFarmAutomation

Method runFarmAutomation

wxapp/junpinhui.js:462–503  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

460 }
461
462 async runFarmAutomation() {
463 const maxRounds = Number(process.env.junpinhui_farm_rounds || 5);
464 let anyAction = false;
465 for (let round = 1; round <= maxRounds; round++) {
466 $.log(`账号[${this.index}] 农场自动化第${round}轮`);
467 await this.queryMember();
468 let lands = await this.queryFarm();
469
470 const harvested = await this.harvestFarm(lands);
471 if (harvested) {
472 anyAction = true;
473 await this.queryMember();
474 lands = await this.queryFarm();
475 }
476
477 const seeded = await this.seedFarm(lands);
478 if (seeded) {
479 anyAction = true;
480 await this.queryMember();
481 lands = await this.queryFarm();
482 }
483
484 const watered = await this.waterFarm(lands);
485 if (watered) {
486 anyAction = true;
487 await this.queryMember();
488 lands = await this.queryFarm();
489 }
490
491 const manured = await this.manureFarm(lands);
492 if (manured) {
493 anyAction = true;
494 await this.queryMember();
495 await this.queryFarm();
496 }
497
498 if (!harvested && !seeded && !watered && !manured) break;
499 await $.wait(800, 1600);
500 }
501 if (!anyAction) $.log(`账号[${this.index}] 农场暂无可执行动作`);
502 return anyAction;
503 }
504
505 async queryTasks() {
506 const data = await this.gardenGet("/garden/tasks/index");

Callers 1

runMethod · 0.95

Calls 8

queryMemberMethod · 0.95
queryFarmMethod · 0.95
harvestFarmMethod · 0.95
seedFarmMethod · 0.95
waterFarmMethod · 0.95
manureFarmMethod · 0.95
logMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected