连连看

close_llk();
// toast("开始运行");
// while (true) {
//     sleep(200);
//     let img = images.captureScreen();
//     let color = images.pixel(img, 410, 615);
//     // let color = images.pixel(img, 390, 615);
//     if (colors.isSimilar(color, color_target, 5, "rgb+")) break;
// }
// // sleep(4000)
// let img = images.captureScreen();
// let img = images.read("/sdcard/Samsung Flow/llk2.png");
// llk();

var w = floaty.rawWindow(
    <frame gravity="center" w="226" h="70" alpha="0.6">
        <horizontal>
            <button id="b_run" w="113" h="70" text="准备中"></button>
            <button id="b_auto" w="113" h="70" text="准备中"></button>
        </horizontal>
    </frame >
);
w.setPosition(330, 2590);
auto.waitFor();
images.requestScreenCapture();
events.on("exit", function () {
    img.recycle();
    icon_block.recycle();
    for (let k = 1; k <= 28; ++k) {
        imgIcons[k].recycle();
        imgIcons_ice[k].recycle();
    }
    log("recycle imgs done!")
});
let icon_block = images.read("/sdcard/Samsung Flow/icon_block.png");
let imgIcons = new Array(29);
let imgIcons_ice = new Array(29);
for (let k = 1; k <= 28; ++k) {
    imgIcons[k] = images.read("/sdcard/Samsung Flow/llk1/" + k + ".png");
    imgIcons_ice[k] = images.read("/sdcard/Samsung Flow/llkice1/" + k + ".png");
}

let color_target = colors.parseColor("#F6A85E");
let llk_running = false;
let manual_run = false;
let llk_auto_run = true;
// llk_auto_run = false;
let llk_no_dfs = true;

w.b_run.click(() => {
    if (!llk_running) {
        manual_run = true;
        w.b_run.setText("队列中");
    }
});

w.b_auto.click(() => {
    if (llk_auto_run) {
        llk_auto_run = false;
        w.b_auto.setText("已关闭自动运行");
    } else {
        llk_auto_run = true;
        w.b_auto.setText("已开启自动运行");
    }
});

w.b_run.setText("手动启动");
w.b_auto.setText("已开启自动运行");
log("init done!");

while (true) {
    if (llk_auto_run) {
        img = images.captureScreen();
        let color = images.pixel(img, 410, 615);
        // let color = images.pixel(img, 390, 615);
        if (colors.isSimilar(color, color_target, 5, "rgb+")) {
            sleep(20);
            img = images.captureScreen();
            llk_running = true;
            // llk_auto_run = false;
            manual_run = false;
            // w.b_auto.setText("已关闭自动运行");
            w.b_run.setText("自动运行中");
            llk();
            llk_running = false;
            w.b_run.setText("手动启动");
            // sleep(300);
        }
    } else if (manual_run) {
        llk_running = true;
        manual_run = false;
        w.b_run.setText("手动运行中");
        img = images.captureScreen();
        llk();
        llk_running = false;
        w.b_run.setText("手动启动");
    }
    sleep(100);
}

function llk() {
    const map = {
        r: 8,          //地图行数
        c: 7,          //地图列数
        start_x: 0,    //方块起始点x坐标
        start_y: 808   //方块起始点y坐标
    }
    map.start_x = map.c == 8 ? 48 : 132;
    const arrLen = { r: (map.r + 2), c: (map.c + 2) };//数组大小
    const _region = [map.start_x, map.start_y, map.c * 168, map.r * 168]; //找图区间
    const _threshold = 0.85; //找图精确度
    const log_icons = ["⬛", "⬜", "
上一篇:Pytorch1.7报错 Output 0 of UnbindBackward is a view and is being modified inplace


下一篇:k8s 安装 kubeadmin