-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathchallengeAnswer.js
79 lines (75 loc) · 2.71 KB
/
challengeAnswer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
importClass(android.database.sqlite.SQLiteDatabase);
var questionCommon = require("./questionCommon.js");
var lCount = 1; //挑战答题轮数
var qCount = random(6, 8); //挑战答题每轮答题数
/**
* @description: 挑战答题
* @param: null
* @return: null
*/
function challengeQuestion(lNum) {
let conNum = 0; //连续答对的次数
// let lNum = 0;//轮数
while (true) {
// sleep(1000)
if (!className("RadioButton").exists()) {
console.error("没有找到题目!请检查是否进入答题界面!");
console.log("停止");
break;
}
// while(!className("ListView").exists());
questionCommon.challengeQuestionLoop(conNum, qCount);
sleep(questionCommon.randomNum(2, 5) * 1000);
// sleep(4000);
if (text("v5IOXn6lQWYTJeqX2eHuNcrPesmSud2JdogYyGnRNxujMT8RS7y43zxY4coWepspQkvw" +
"RDTJtCTsZ5JW+8sGvTRDzFnDeO+BcOEpP0Rte6f+HwcGxeN2dglWfgH8P0C7HkCMJOAAAAAElFTkSuQmCC").exists()) //遇到❌号,则答错了,不再通过结束本局字样判断
{
if (conNum >= qCount) {
lNum++;
if (lNum >= lCount) {
console.verbose("挑战答题结束!");
} else {
console.verbose("等5秒开始下一轮...");
}
back();
sleep(1000);
back();
break;
} else {
console.error("出现错误,等5秒重新开始...");
sleep(3000); //等待5秒才能开始下一轮
back();
//desc("结束本局").click();//有可能找不到结束本局字样所在页面控件,所以直接返回到上一层
sleep(2000);
text("再来一局").click();
sleep(4000);
conNum = 0;
}
} else //答对了
{
conNum++;
}
}
}
function main() {
console.setPosition(0, device.height / 2); //部分华为手机console有bug请注释本行
console.show();
if (text("每日答题").exists()) {
for (i = 0; i < lCount; i++) {
let myImage = className("android.view.View").text("每日答题").findOne();
// console.log(myImage.parent().parent().childCount());
myImage = myImage.parent().parent().child(10);
myImage.click();
console.warn("第" + (i + 1) + "轮挑战答题");
sleep(6000);
challengeQuestion(i);
}
} else {
console.verbose("开始挑战答题");
sleep(1000);
challengeQuestion(1);
}
// answerWrong();
console.hide()
}
module.exports = main;