function add2EmptyLocation() {//put on the open space
/*
var emptyList=findMultiImgMax("empty_location.jpg", "empty location", 0.7,3,false,true);
if(emptyList.length>=1) { var chouJiangImg =findImgPosition("chou_jiang.jpg","Lottery Draw",0.7); if(chouJiangImg) { var y=chouJiangImg.y; click(device.width/2,y); } }*/ var addCount=4; while( addCount>0){ var addImg=findImgPosition("add_plane.jpg","add",0.7); if(addImg) { click(device.width/2,addImg.y); sleep(2000); addCount--; }else { break;
}
}
}
function collectionShou() {//collect hand coordinates
if(true) { return true; } var fingerTryCount=0; while(true) { var shouImg=findImgPosition("finger_head.jpg","finger",0.7) ; if(shouImg) { fingerList.push(shouImg); noHandleCount=-20; } fingerTryCount++; if(fingerList.length>=4) { performCombineAction(fingerList); break; } if(fingerTryCount>10) { tip("only "+fingerList.length+" hand");
if(fingerList.length<=1) { tip("No hand, add plane"); add2EmptyLocation(); var redPacketImg=findImgPosition("red_packet.jpg", "red envelope", 0.7); if(redPacketImg) { click( redPacketImg.x,redPacketImg.y); } } break; } //sleep(500); } } function performCombineAction(imgList) {//If there is a synthesized aircraft, synthesize var isSucc=false; var shouXLeft=device.width ; var shouYLeft=0; var shouXRight=0; var shouYRight=0; var measureCount=0;
var measureCountMax=3;
var xList=[];
var yList=[];
var imgIndex=0;
while(true)
{ var shouView=null; if(imgIndex<imgList.length) { shouView=imgList[imgIndex]; }else { tip("The hand corner mark is not enough"); break; } //var shouView=findImgPosition("finger_head.jpg","finger",0.7);//findImgPositionCustomDiff if(shouView) { shouView.x=shouView.x -shouView.width/2;//Correct to the center position of the small fish shouView.y=shouView.y-shouView.height/2; //tip("point after correcting coordinates by hand = " + shouView);
if(shouView.y<device.height/3) {
tip("应该是分红的手");
click(shouView.x,shouView.y);
continue;
}
xList.push(shouView.x);
yList.push(shouView.y);
imgIndex++;
if(shouView.x<shouXLeft)
{
shouXLeft=shouView.x;
shouYLeft=shouView.y;
}
if(shouView.x>shouXRight)
{
shouXRight=shouView.x;
shouYRight=shouView.y;
}
measureCount++;
tip("recognized"+measureCount+"times");
if(measureCount==measureCountMax)
{ if(Math.abs(xList[0]-xList[1])<20&&Math.abs(xList[0]-xList[2 ])<20) { tip("should be vertical fingers"); for(var i=0;i<xList.length;i++) { var key=xList[i]; var value=yList[i]; if(value<shouYLeft) { shouXLeft=key; shouYLeft=value; } if(value>shouYRight)
{
shouXRight=key;
shouYRight=value;
}
tip(i+"("+key+","+value+")");
}
}
else
{
tip("xList[0]="+xList[0]+",xList[1]="+xList[1]);
}
break;
}
}
else
{
break;
}
}
if(measureCount==measureCountMax)
{
var swipeTime=calculateSwipeTime(shouXLeft,shouYLeft,shouXRight,shouYRight);
tip("swipe time = "+swipeTime);
if(swipeTime>0) { uiUtil.addPointColor(shouXLeft,shouYLeft, false,"#0000ff"); uiUtil .addPointColor(shouXRight,shouYRight,true,"#0000ff"); if(shouYLeft<shouYRight)//Both of these are not allowed to slide up to prevent the plane from being sold { tip("slide,x1="+shouXLeft+ ",y1="+shouYLeft+",x2="+shouXRight+",y2="+shouYRight); swipe (shouXLeft,shouYLeft,shouXRight,shouYRight,swipeTime);//random(400,800)); } else {
tip("swipe, x1="+shouXRight+", y1="+shouYRight+", x2="+shouXLeft+", y2="+shouYLeft); swipe(shouXRight, shouYRight, shouXLeft, shouYLeft, swipeTime);//random
( 400,800));
}
isSucc=true;
}else {//should be the bottom hand
tip("There are no planes to match");
}
forbidClickRedPacketCount--;
fingerList=[];
}
else { tip("hand Not enough quantity = "+measureCount); } return isSucc; } function calculateSwipeTime(x1,y1,x2,y2)//Calculate the synthetic time of sliding, because the two distances are different, it is better to use different times, which should improve the success Rate it { var diffX=x1-x2; var diffY=y1-y2;
var tempDistance=Math.sqrt(diffX*diffX+diffY*diffY);
return 400*tempDistance/(device.width/5);
}
Develop a series of synthetic algorithms
Guess you like
Origin blog.csdn.net/yeziyfx/article/details/125055424
Ranking