package com.sencorsta.rabs.obj.ai.scene.explore;

import cn.hutool.core.thread.ThreadUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sencorsta.rabs.annotation.SceneAnnotation;
import com.sencorsta.rabs.obj.ai.AiManage;
import com.sencorsta.rabs.obj.ai.api.BaseScene;
import com.sencorsta.rabs.obj.ai.api.Scene;

import java.awt.*;

/**
 * 探索-首领挑战
 */
@SceneAnnotation("SceneMain_Explore_Leader")
public class SceneMain_Explore_Leader_quick extends BaseScene implements Scene {
    @JsonIgnore
    @Override
    public float getPriority() {
        return 5.0f;
    }

    private static String PathEnter = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\enter.png";
    private static String PathCheck = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\check.png";
    private static String PathBack = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\back.png";
    private static String PathTime3 = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\time3.png";
    private static String PathStage7_12 = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\stage7_12.png";
    private static String PathStage13_18 = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\stage13_18.png";
    private static String PathCancel = System.getProperty("user.dir") + "\\opencv\\scene\\explore\\leader\\quick\\cancel.png";

    @Override
    public void back() throws AWTException {
        moveToClick(PathBack, AiManage.getInstance().getCheckPoint());
    }

    @Override
    public void open() throws AWTException {
        while (AiManage.getInstance().isRunning() && !check()) {
            AiManage.getInstance().updateWindow();
            ThreadUtil.sleep(2000);
            if (checkHas(PathEnter, AiManage.getInstance().getCheckPoint())) {
                moveToClick(PathEnter, AiManage.getInstance().getCheckPoint());
                continue;
            }
        }
    }

    @Override
    public boolean check() throws AWTException {
        if (checkHas(PathCheck, AiManage.getInstance().getCheckPoint())) {
            return true;
        }
        return false;
    }

    @Override
    public void think() throws AWTException {
        moveToClick(PathTime3, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        if (checkHas(PathCancel, AiManage.getInstance().getCheckPoint())) {
            moveToClick(PathCancel, AiManage.getInstance().getCheckPoint());
            ThreadUtil.sleep(2000);
        }else {
            ThreadUtil.sleep(1000);
            moveToClick(PathBack, AiManage.getInstance().getCheckPoint());
            ThreadUtil.sleep(10000);
        }
        moveToClick(PathStage7_12, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        moveToClick(PathTime3, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        if (checkHas(PathCancel, AiManage.getInstance().getCheckPoint())) {
            moveToClick(PathCancel, AiManage.getInstance().getCheckPoint());
            ThreadUtil.sleep(2000);
        }else {
            ThreadUtil.sleep(1000);
            moveToClick(PathBack, AiManage.getInstance().getCheckPoint());
            ThreadUtil.sleep(10000);
        }
        moveToClick(PathStage13_18, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        moveToClick(PathTime3, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        if (checkHas(PathCancel, AiManage.getInstance().getCheckPoint())) {
            moveToClick(PathCancel, AiManage.getInstance().getCheckPoint());
            ThreadUtil.sleep(2000);
        }else {
            ThreadUtil.sleep(1000);
            moveToClick(PathBack, AiManage.getInstance().getCheckPoint());
            ThreadUtil.sleep(10000);
        }

        getRecord().getData().setDone(true);
    }


    @Override
    public boolean isDone() {
        return getRecord().getData().isDone();
    }

}
