@@ -89,13 +89,13 @@ function TaskManager() {
8989 var task_list = this . getTaskList ( ) ;
9090 this . task_no = task_list . indexOf ( engines . myEngine ( ) ) ;
9191 log ( Object . keys ( task_list ) ) ;
92- } . bind ( this ) ;
92+ } ;
9393
9494 this . getTaskList = function ( ) {
9595 return engines . all ( ) . sort ( function ( e1 , e2 ) {
9696 return e1 . getTag ( this . time_tag ) - e2 . getTag ( this . time_tag ) ;
9797 } . bind ( this ) ) ;
98- } . bind ( this ) ;
98+ } ;
9999
100100 this . listen = function ( ) {
101101 // 子线程
@@ -107,7 +107,7 @@ function TaskManager() {
107107 exit ( ) ;
108108 } ) ;
109109 } ) ;
110- } . bind ( this ) ;
110+ } ;
111111
112112 this . waitFor = function ( ) {
113113 while ( 1 ) {
@@ -122,7 +122,7 @@ function TaskManager() {
122122 break ;
123123 }
124124 }
125- } . bind ( this ) ;
125+ } ;
126126}
127127
128128/**
@@ -141,13 +141,15 @@ function AntForest(robot, options) {
141141 max_swipe_times : 100 , // 好友列表最多滑动次数
142142 min_time : "7:14:00" , // 检测时段
143143 max_time : "7:15:50" ,
144- check_within_time : 5
144+ check_within_time : 5 ,
145+ help_img : ""
145146 } ;
146147 this . options = Object . assign ( settings , options ) ;
147148 this . package = "com.eg.android.AlipayGphone" ; // 支付宝包名
148149 this . state = { } ;
149150 this . capture = null ;
150151 this . bounds = [ 0 , 0 , WIDTH , 1100 ] ;
152+ this . icon_num = 1 ;
151153
152154 toastLog ( "即将收取能量,按音量上键停止" ) ;
153155
@@ -276,10 +278,18 @@ function AntForest(robot, options) {
276278 var power = this . getPower ( ) - startPower ;
277279 if ( power > 0 ) toastLog ( "收取了" + power + "g自己的能量" ) ;
278280
281+ var icon_list = [ ] ;
279282 var icon = images . read ( this . options . takeImg ) ;
280283 if ( null === icon ) {
281284 throw new Error ( "缺少图片文件,请仔细查看使用方法的第一条!!!" ) ;
282285 }
286+ icon_list = [ icon ] ;
287+ var icon2 ;
288+ if ( this . options . help_img && ( icon2 = images . read ( this . options . help_img ) ) ) {
289+ icon_list [ 1 ] = icon2 ;
290+ }
291+ this . icon_num = icon_list . length ;
292+
283293 // 截图权限申请
284294 threads . start ( function ( ) {
285295 var remember ;
@@ -301,9 +311,8 @@ function AntForest(robot, options) {
301311 sleep ( 500 ) ;
302312 log ( "开始收取好友能量" ) ;
303313
304- var total = 0 ;
305314 var bottom = 0 ;
306- total + = this . takeOthers ( icon , 500 , function ( ) {
315+ var total_list = this . takeOthers ( icon_list , 500 , function ( ) {
307316 var rect = desc ( "合种" ) . findOnce ( ) . bounds ( ) ;
308317
309318 if ( rect . bottom === bottom ) {
@@ -329,11 +338,11 @@ function AntForest(robot, options) {
329338 this . robot . swipe ( WIDTH / 2 , y , WIDTH / 2 , 0 ) ;
330339 sleep ( 500 ) ;
331340
332- var page , min_minute , swipe_sleep = 500 ;
341+ var page , min_minute , add_total_list , swipe_sleep = 500 ;
333342 for ( ; ; ) {
334343 log ( "往下翻页" ) ;
335344 page = 0 ;
336- total + = this . takeOthers ( icon , swipe_sleep , function ( ) {
345+ add_total_list = this . takeOthers ( icon_list , swipe_sleep , function ( ) {
337346 /*var selector = desc("没有更多了");
338347 if (!selector.exists()) return false;
339348
@@ -342,6 +351,7 @@ function AntForest(robot, options) {
342351 return ( page > this . options . max_swipe_times )
343352 || ( findColorEquals ( this . capture , "#30BF6C" , WIDTH - 300 , 0 , 200 , HEIGHT ) !== null ) ;
344353 } . bind ( this ) ) ;
354+ this . addTotal ( total_list , add_total_list ) ;
345355
346356 minuteList = this . statisticsNextTime ( ) ;
347357 this . filterMinuteList ( minuteList ) ;
@@ -362,11 +372,12 @@ function AntForest(robot, options) {
362372
363373 log ( "往上翻页" ) ;
364374 page = 0 ;
365- total + = this . takeOthers ( icon , swipe_sleep , function ( ) {
375+ add_total_list = this . takeOthers ( icon_list , swipe_sleep , function ( ) {
366376 page ++ ;
367377 return ( page > this . options . max_swipe_times )
368378 || ( findColorEquals ( this . capture , "#EFAE44" , 0 , 0 , 110 , HEIGHT / 2 ) !== null ) ;
369379 } . bind ( this ) , "prev" ) ;
380+ this . addTotal ( total_list , add_total_list ) ;
370381 }
371382
372383 this . back ( ) ;
@@ -389,7 +400,11 @@ function AntForest(robot, options) {
389400 added = Math . max ( 0 , added ) ;
390401
391402 this . back ( ) ;
392- toastLog ( "收取完毕,共" + total + "个好友," + added + "g能量" ) ;
403+ var message = "收取完毕,共" + total_list [ 0 ] + "个好友," + added + "g能量" ;
404+ if ( this . icon_num > 1 ) {
405+ message += ",帮了" + total_list [ 1 ] + "个好友收取" ;
406+ }
407+ toastLog ( message ) ;
393408 sleep ( 1500 ) ;
394409
395410 // 统计部分,可以删除
@@ -407,6 +422,12 @@ function AntForest(robot, options) {
407422 }
408423 } ;
409424
425+ this . addTotal = function ( total_list , add_total_list ) {
426+ for ( var i = 0 ; i < this . icon_num ; i ++ ) {
427+ total_list [ i ] += add_total_list [ i ] ;
428+ }
429+ } ;
430+
410431 this . statisticsNextTime = function ( ) {
411432 var minuteList = [ ] ;
412433 descMatches ( / \d + ’ / ) . find ( ) . forEach ( function ( o ) {
@@ -535,15 +556,16 @@ function AntForest(robot, options) {
535556
536557 /**
537558 * 收取好友能量
538- * @param icon
559+ * @param icon_list
539560 * @param isEndFunc
540561 * @param swipe_sleep
541562 * @param scroll
542- * @returns {number }
563+ * @returns {Array }
543564 */
544- this . takeOthers = function ( icon , swipe_sleep , isEndFunc , scroll ) {
565+ this . takeOthers = function ( icon_list , swipe_sleep , isEndFunc , scroll ) {
545566 var row = ( 192 * ( HEIGHT / 1920 ) ) | 0 ;
546- var total = 0 ;
567+ var total_list = [ ] ;
568+ var take_num = icon_list . length ;
547569 var x1 , y1 , x2 , y2 ;
548570 x2 = x1 = WIDTH / 2 ;
549571 switch ( scroll ) {
@@ -557,8 +579,14 @@ function AntForest(robot, options) {
557579 y2 = HEIGHT - row ;
558580 break ;
559581 }
582+ for ( var i = 0 ; i < take_num ; i ++ ) {
583+ total_list [ i ] = 0 ;
584+ }
560585 while ( 1 ) {
561- total += this . takeFromImage ( icon ) ;
586+ for ( var i = 0 ; i < take_num ; i ++ ) {
587+ var icon = icon_list [ i ] ;
588+ total_list [ i ] += this . takeFromImage ( icon ) ;
589+ }
562590
563591 if ( isEndFunc ( ) ) {
564592 break ;
@@ -568,7 +596,7 @@ function AntForest(robot, options) {
568596 sleep ( swipe_sleep ) ; // 等待滑动动画
569597 }
570598
571- return total ;
599+ return total_list ;
572600 } ;
573601
574602 /**
0 commit comments