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

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.AWTException;

/**
 * 无尽-领奖
 */
@SceneAnnotation("SceneMain_Fight_Endless")
public class SceneMain_Fight_Endless_Reward extends BaseScene implements Scene {
    @JsonIgnore
    @Override
    public float getPriority() {
        return 1.0f;
    }
    private static String PathEnter = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\enter.png";
    private static String PathCheck = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\check.png";
    private static String PathBack = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\back.png";

    private static String PathTake = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\take.png";
    private static String PathEverweek = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\everweek.png";
    private static String PathCoin = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\coin.png";
    private static String PathCup = System.getProperty("user.dir") + "\\opencv\\scene\\fight\\endless\\reward\\cup.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(PathTake, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        randomToClick();//第二次是恭喜获得
        ThreadUtil.sleep(2000);

        moveToClick(PathEverweek, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);

        moveToClick(PathCoin, AiManage.getInstance().getCheckPoint());//TODO ice 这里优化一下 图片会动 改成固定图
        ThreadUtil.sleep(2000);

        moveToClick(PathCup, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);

        moveToClick(PathTake, AiManage.getInstance().getCheckPoint());
        ThreadUtil.sleep(2000);
        randomToClick();//第二次是恭喜获得
        ThreadUtil.sleep(2000);

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


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

}
