@@ -2,8 +2,8 @@ var icon = [];
22var iconMargin = [ ] ;
33
44function setMarginIcon ( ) {
5- if ( isDebug ) {
6- console . log ( "setMarginIcon " + server ) ;
5+ if ( isDebug ) {
6+ console . log ( "setMarginIcon " + server ) ;
77 }
88 if ( server == "TW" ) {
99 icon [ "boxNoPoint" ] = [ 360 , 630 , 195 , 82 ] ;
@@ -13,7 +13,7 @@ function setMarginIcon() {
1313 icon [ "friendPointFree" ] = [ 787 , 740 , 337 , 75 ] ;
1414 } else {
1515 icon [ "boxNoPoint" ] = [ 470 , 530 , 200 , 100 ] ;
16- icon [ "settingDialog" ] = [ 750 , 220 , 350 , 60 ] ;
16+ icon [ "settingDialog" ] = [ 750 , 140 , 350 , 70 ] ;
1717 icon [ "stageFailed" ] = [ 750 , 160 , 300 , 60 ] ;
1818 icon [ "stageRestart" ] = [ 1140 , 836 , 240 , 75 ] ;
1919 icon [ "friendPointFree" ] = [ 810 , 740 , 300 , 75 ] ;
@@ -110,11 +110,14 @@ function setMarginIcon() {
110110 icon [ "itemPage" ] [ 0 ] = 160 ;
111111 iconMargin [ "itemPage" ] = true ;
112112}
113- function checkIconListInScreen ( iconList , allPass , threshold ) {
113+ function checkIconListInScreen ( iconList , allPass , threshold , sharedScreenshot ) {
114114 if ( threshold == undefined ) {
115115 threshold = 0.85 ;
116116 }
117- var screenshot = getScreenshotResize ( ) ;
117+ var screenshot = sharedScreenshot ;
118+ if ( screenshot == undefined || screenshot == null ) {
119+ screenshot = getScreenshotResize ( ) ;
120+ }
118121 if ( screenshot == null ) {
119122 return false ;
120123 }
@@ -147,27 +150,35 @@ function checkIconListInScreen(iconList, allPass, threshold) {
147150 console . log ( "checkIconInScreen result " + result ) ;
148151 }
149152 if ( result && ! allPass ) {
150- releaseImage ( screenshot ) ;
153+ if ( sharedScreenshot == undefined || sharedScreenshot == null ) {
154+ releaseImage ( screenshot ) ;
155+ }
151156 return true ;
152157 }
153158 if ( ! result && allPass ) {
154- releaseImage ( screenshot ) ;
159+ if ( sharedScreenshot == undefined || sharedScreenshot == null ) {
160+ releaseImage ( screenshot ) ;
161+ }
155162 return false ;
156163 }
157164 }
158- releaseImage ( screenshot ) ;
165+
166+ if ( sharedScreenshot == undefined || sharedScreenshot == null ) {
167+ releaseImage ( screenshot ) ;
168+ }
159169 return allPass ;
160170}
161171
162- function checkIconInScreen ( iconName , threshold , screenshot ) {
172+ function checkIconInScreen ( iconName , threshold , sharedScreenshot ) {
163173 if ( ! isScriptRunning ) {
164174 return false ;
165175 }
166176 if ( icon [ iconName ] == undefined ) {
167177 console . log ( "checkIconInScreen no icon " + iconName ) ;
168178 return false ;
169179 }
170- if ( screenshot == undefined ) {
180+ var screenshot = sharedScreenshot ;
181+ if ( screenshot == undefined || screenshot == null ) {
171182 screenshot = getScreenshotResize ( ) ;
172183 }
173184 if ( screenshot == null ) {
@@ -195,22 +206,30 @@ function checkIconInScreen(iconName, threshold, screenshot) {
195206 icon [ iconName ] [ 3 ] ,
196207 threshold
197208 ) ;
198- releaseImage ( screenshot ) ;
209+ if ( sharedScreenshot == undefined || sharedScreenshot == null ) {
210+ releaseImage ( screenshot ) ;
211+ }
199212 releaseImage ( iconImage ) ;
200213 if ( isDebug ) {
201214 console . log ( "checkIconInScreen result " + result ) ;
202215 }
203216 return result ;
204217}
205218
206- function clickIcon ( iconName ) {
219+ function clickIcon ( iconName , xOffset , yOffset ) {
207220 var margin = 0 ;
221+ if ( xOffset == undefined ) {
222+ xOffset = 0 ;
223+ }
224+ if ( yOffset == undefined ) {
225+ yOffset = 0 ;
226+ }
208227 if ( iconMargin [ iconName ] != true ) {
209228 margin = defaultMarginX ;
210229 }
211230 tapScale (
212- icon [ iconName ] [ 0 ] + icon [ iconName ] [ 2 ] / 2 + margin ,
213- icon [ iconName ] [ 1 ] + icon [ iconName ] [ 3 ] / 2 ,
231+ icon [ iconName ] [ 0 ] + icon [ iconName ] [ 2 ] / 2 + margin + xOffset ,
232+ icon [ iconName ] [ 1 ] + icon [ iconName ] [ 3 ] / 2 + yOffset ,
214233 100 ,
215234 0
216235 ) ;
@@ -306,10 +325,10 @@ function isUseItemDialog() {
306325 return false ;
307326}
308327
309- function isTeamMemberCheckDialog ( ) {
328+ function isTeamMemberCheckDialog ( ) {
310329 if ( server == "TW" ) {
311330 //TODO
312- return false
331+ return false ;
313332 }
314333 return checkIconInScreen ( "teamMemberCheckDialog" ) ;
315334}
@@ -341,14 +360,14 @@ icon["emiyaColor"] = [690, 240, 540, 90];
341360icon [ "dubaiSkill" ] = [ 760 , 220 , 395 , 90 ] ;
342361icon [ "dubaiSkill2" ] = [ 760 , 220 , 395 , 90 ] ;
343362icon [ "dubaiSkill3" ] = [ 760 , 220 , 395 , 90 ] ;
344- icon [ "rabbitSkill" ] = [ 765 , 600 , 370 , 60 ] ;
345- icon [ "rabbitSkill2" ] = [ 1245 , 600 , 370 , 60 ] ;
346- icon [ "kishinamiSkill" ] = [ 660 , 600 , 260 , 60 ] ;
347- icon [ "kishinamiSkill2" ] = [ 1000 , 600 , 260 , 60 ] ;
348- icon [ "kishinamiSkill3" ] = [ 1360 , 600 , 260 , 60 ] ;
363+ icon [ "rabbitSkill" ] = [ 765 , 600 , 370 , 60 ] ;
364+ icon [ "rabbitSkill2" ] = [ 1245 , 600 , 370 , 60 ] ;
365+ icon [ "kishinamiSkill" ] = [ 660 , 600 , 260 , 60 ] ;
366+ icon [ "kishinamiSkill2" ] = [ 1000 , 600 , 260 , 60 ] ;
367+ icon [ "kishinamiSkill3" ] = [ 1360 , 600 , 260 , 60 ] ;
349368icon [ "ultFailed" ] = [ 900 , 637 , 123 , 60 ] ;
350369icon [ "skillFailed" ] = [ 870 , 802 , 180 , 60 ] ;
351- icon [ "settingDialog" ] = [ 750 , 220 , 350 , 60 ] ;
370+ icon [ "settingDialog" ] = [ 750 , 140 , 350 , 60 ] ;
352371
353372function isBattleMainPage ( ) {
354373 if (
@@ -362,16 +381,16 @@ function isBattleMainPage() {
362381 return true ;
363382 //}
364383 /*
365- // double check ring color
366- var screenshot = getScreenshotResize();
367- if(checkPixel(1075,665,163,146,121,screenshot)
368- && checkPixel(1135,690,191,175,150,screenshot)
369- && checkPixel(1200,665,163,146,121,screenshot)){
370- releaseImage(screenshot);
371- return true;
372- }
373- releaseImage(screenshot);
374- */
384+ // double check ring color
385+ var screenshot = getScreenshotResize();
386+ if(checkPixel(1075,665,163,146,121,screenshot)
387+ && checkPixel(1135,690,191,175,150,screenshot)
388+ && checkPixel(1200,665,163,146,121,screenshot)){
389+ releaseImage(screenshot);
390+ return true;
391+ }
392+ releaseImage(screenshot);
393+ */
375394 }
376395 return false ;
377396}
@@ -385,65 +404,79 @@ function isBattleCardPage() {
385404 return false ;
386405}
387406
388- function isBattleServantDialog ( ) {
407+ function isBattleServantDialog ( screenshot ) {
389408 return checkIconListInScreen (
390409 [ "battleServant1" , "battleServant2" ] ,
391410 false ,
392- 0.9
411+ 0.9 ,
412+ screenshot
393413 ) ;
394414}
395415
396- function isBattleSkillFailedDialog ( ) {
397- return checkIconInScreen ( "skillFailed" ) ;
416+ function isBattleSkillFailedDialog ( screenshot ) {
417+ return checkIconInScreen ( "skillFailed" , 0.85 , screenshot ) ;
398418}
399419
400420function isBattleUltFailedDialog ( ) {
401421 return checkIconInScreen ( "ultFailed" ) ;
402422}
403423
404- function isBattleSkillDetailDialog ( ) {
405- return checkIconInScreen ( "battleSkill" ) ;
424+ function isBattleSkillDetailDialog ( screenshot ) {
425+ return checkIconInScreen ( "battleSkill" , 0.85 , screenshot ) ;
406426}
407427
408- function isBattleKklDialog ( ) {
409- return checkIconListInScreen ( [ "kkl" , "kkl2" ] , true ) ;
428+ function isBattleKklDialog ( screenshot ) {
429+ return checkIconListInScreen ( [ "kkl" , "kkl2" ] , true , 0.85 , screenshot ) ;
410430}
411431
412- function isBattleSkillTargetDialog ( ) {
413- return checkIconInScreen ( "battleTarget" ) ;
432+ function isBattleSkillSpaceDialog ( screenshot ) {
433+ return checkIconInScreen ( "spaceColor" , 0.75 , screenshot ) ;
414434}
415435
416- function isBattleSkillSpaceDialog ( ) {
417- if ( isBattleSkillEmiyaDialog ( ) ) {
418- return false ;
419- }
420- return checkIconInScreen ( "spaceColor" , 0.75 ) ;
436+ function isBattleSkillEmiyaDialog ( screenshot ) {
437+ //Warning: will conflic with Space, shoude run before isBattleSkillSpaceDialog
438+ return checkIconInScreen ( "emiyaColor" , 0.75 , screenshot ) ;
421439}
422440
423- function isBattleSkillEmiyaDialog ( ) {
424- return checkIconInScreen ( "emiyaColor" , 0.75 ) ;
425- }
426-
427- function isBattleSkillDubaiDialog ( ) {
441+ function isBattleSkillDubaiDialog ( screenshot ) {
428442 if ( server == "TW" ) {
429443 return false ;
430444 }
431- return checkIconListInScreen ( [ "dubaiSkill" , "dubaiSkill2" , "dubaiSkill3" ] , false ) ;
445+ return checkIconListInScreen (
446+ [ "dubaiSkill" , "dubaiSkill2" , "dubaiSkill3" ] ,
447+ false ,
448+ 0.85 ,
449+ screenshot
450+ ) ;
432451}
433452
434- function isBattleSkillRabbitDialog ( ) {
453+ function isBattleSkillRabbitDialog ( screenshot ) {
435454 //Warning: will conflic with kkl, shoude run before isBattleKklDialog
436455 if ( server == "TW" ) {
437456 return false ;
438457 }
439- return checkIconListInScreen ( [ "rabbitSkill" , "rabbitSkill2" ] , true ) ;
458+ return checkIconListInScreen (
459+ [ "rabbitSkill" , "rabbitSkill2" ] ,
460+ true ,
461+ 0.85 ,
462+ screenshot
463+ ) ;
440464}
441465
442- function isBattleSkillKishinamiDialog ( ) {
466+ function isBattleSkillKishinamiDialog ( screenshot ) {
443467 if ( server == "TW" ) {
444468 return false ;
445469 }
446- return checkIconListInScreen ( [ "kishinamiSkill" , "kishinamiSkill2" , "kishinamiSkill3" ] , true ) ;
470+ return checkIconListInScreen (
471+ [ "kishinamiSkill" , "kishinamiSkill2" , "kishinamiSkill3" ] ,
472+ true ,
473+ 0.85 ,
474+ screenshot
475+ ) ;
476+ }
477+
478+ function isBattleSkillTargetDialog ( ) {
479+ return checkIconInScreen ( "battleTarget" ) ;
447480}
448481
449482//finish-----------------------------------------------
@@ -513,10 +546,10 @@ function isFriendPointFree() {
513546}
514547
515548function isFriendPointTen ( ) {
516- return checkIconListInScreen (
517- [ "friendPointTen" , "friendPointTenEvent" , "friendPointHundred" ] ,
518- false
519- ) ;
549+ return checkIconListInScreen (
550+ [ "friendPointTen" , "friendPointTenEvent" , "friendPointHundred" ] ,
551+ false
552+ ) ;
520553}
521554
522555function isFriendPointNew ( ) {
@@ -534,7 +567,7 @@ function isFriendPointFull() {
534567}
535568
536569function isFriendPointContinue ( ) {
537- return checkIconInScreen ( "friendPointContinue" ) ;
570+ return checkIconInScreen ( "friendPointContinue" ) ;
538571}
539572
540573function isPresentBoxFull ( ) {
0 commit comments