旅行蛙自动收四叶草

刚下载的,写了一个试试。。还不完善[0_1516883424998_Clover.js.js](正在上传 100%)

//version 1.0beta
//提供了自动收集四叶草功能
//TODO : 收集蛙发回来的明信片
//TODO : 不理会蛙的好友
//TODO : 将事件记录到日志中

const startApplication = function () {
let app = "jp.co.hit_point.tabikaeru";
launch(app);
}

const swipeToClover = function (device) {
let endx = device.width * 0.9;
let y = device.height / 5;
let startx = device.width * 0.1;
let sec = 500;
swipe(startx, y, endx, y, sec);
}

const collectClover = function (device) {
let xr = 0.45 * device.width;
let yr = 0;
for (let i = 0.02; i <= 0.2; i += 0.06) {
yr = i * device.height;
swipeArc(getCircle(device, xr, yr));
}
}

const getCircle = function (device, xradius, yradius, startx, starty) {
let sx = startx || device.width * 0.45;
let sy = starty || device.height * 0.55;
let c = {
startx: sx,
starty: sy,
xr: xradius,
yr: yradius
}
return c;
}

const swipeArc = function (circle) {
let xr = circle.xr;
let yr = circle.yr;
let sx = circle.startx;
let sy = circle.starty;
let p = Math.PI;
let points = [];
let step = 0.1;

for (let t = 0; t < p; t += step) {
    let x = sx + xr * Math.cos(t);
    let y = sy + yr * Math.sin(t);
    points.unshift([parseInt(x), parseInt(y)]);
}
points.unshift(800);

gesture.apply(null, points);

}

const getDeviceData = function () {
let d = {
width: device.width,
height: device.height
};
return d;
}

const isEnterGame = function () {

sleep(1000)

if (requestScreenCapture()) {

    setScreenMetrics(1080, 1920);
    let x = 965;
    let y = 985;
    let color = "#f9746b";

    while (!images.detectsColor(captureScreen(), color, x, y)) {
        sleep(1000);
    }

} else {
    let timeout = 10000;
    sleep(timeout);
}

}

const startMain = function () {

device.wakeUp();
let d = getDeviceData();
startApplication();
isEnterGame();
swipeToClover(d);
sleep(1000);
collectClover(d);
exit();

}

startMain();

公然月莫氵去?怕是要被纟卖-1s

有没有呱旅行刷车票刷幸运物的脚本啊!

我也写了一个差不多的,不过在device.wakeup那卡住了,手机不接通电源时,屏幕关上一会就没法自动唤醒……这个有解吗?

  • 6
    帖子
  • 887
    浏览