//节点从Start进入，开始前要确保农田已被标记
//节点从Exit离开，这里关联下一个阶段的节点，里面的无限循环需要靠Maptracker检测坐标来退出
{
    //节点出入口
    "_AutoEcoFarmMoveAndWorkStart": {
        "desc": "这块代码的目的是按下移动键，一边移动一边识别收菜菜单，识别到了就停下，点击收菜/播种/浇水",
        "next": [
            "_AutoEcoFarmGotoTarget",
            "_AutoEcoFarmJump"
        ]
    },
    "_AutoEcoFarmMoveAndWorkExit": {
        "next": [
            //在开启随机查找后会循环3次该任务增加全收集的概率
            //"_AutoEcoFarmFindValleyIVEcoFarmAny",
            "AutoEcoFarmMain"
        ]
    },
    //内部节点
    "_AutoEcoFarmJump": {
        "desc": "往前跳，防止被卡住，先按下w",
        "pre_delay": 0,
        "action": {
            "type": "KeyDown",
            "param": {
                "key": 87 //w键
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmJump2"
        ]
    },
    "_AutoEcoFarmJump2": {
        "desc": "按一下空格",
        "pre_delay": 0,
        "action": {
            "type": "LongPressKey",
            "param": {
                "duration": 500,
                "key": 32 //空格键
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmJump3"
        ]
    },
    "_AutoEcoFarmJump3": {
        "desc": "松开w",
        "action": {
            "type": "KeyUp",
            "param": {
                "key": 87 //w键
            }
        },
        //稍微加点延迟保证停稳
        "post_delay": 200,
        "next": [
            "_AutoEcoFarmFindMenuLoop",
            "_AutoEcoFarmMoveToTargetErr"
        ]
    },
    "_AutoEcoFarmLastJump": {
        "desc": "识别标记消失后最后往前跳一次",
        "pre_delay": 0,
        "action": {
            "type": "KeyDown",
            "param": {
                "key": 87 //w键
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmLastJump2"
        ]
    },
    "_AutoEcoFarmLastJump2": {
        "desc": "按一下空格",
        "pre_delay": 0,
        "action": {
            "type": "LongPressKey",
            "param": {
                "duration": 500,
                "key": 32 //空格键
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmLastJump3"
        ]
    },
    "_AutoEcoFarmLastJump3": {
        "desc": "松开w",
        "action": {
            "type": "KeyUp",
            "param": {
                "key": 87 //w键
            }
        },
        //稍微加点延迟保证停稳
        "post_wait_freezes": 200,
        "next": [
            //最后识别一次，这次要是没菜单了就结束任务，否则回到工作流程
            "_AutoEcoFarmFindMenuIcon",
            "_AutoEcoFarmCancelMove"
        ]
    },
    "_AutoEcoFarmFindMenuLoop": {
        "desc": "循环识别菜单",
        //最大连跑60秒，超过就直接结束任务
        "max_hit": 120,
        "next": [
            //识别设备界面，有的话关了
            "[JumpBack]_AutoEcoFarmCloseEquipment",
            //识别肥料界面，有的话关了
            "[JumpBack]_AutoEcoFarmCloseFertilizer",
            //识别工作按钮并点击
            "_AutoEcoFarmFindMenuIcon",
            //第二次保障，判断标记还在不在
            "_AutoEcoFarmTargetExists",
            //第三层保障，如果还在农田内则任不会结束
            "_AutoEcoFarmInAnyFarm",
            //所有条件都不满足的情况下，启动最后一跳，再给一次机会
            "_AutoEcoFarmLastJump",
            //意外错误的话直接退出任务
            "_AutoEcoFarmCancelMove"
        ]
    },
    "_AutoEcoFarmTargetExists": {
        "desc": "确定农场标记还在不在屏幕中，如果在的话继续循环",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    420,
                    100,
                    440,
                    300
                ],
                "template": "AutoEcoFarm/AutoEcoFarmFarmland.png",
                "threshold": 0.4
            }
        },
        "pre_delay": 0,
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmJump"
        ]
    },
    "_AutoEcoFarmCloseEquipment": {
        "desc": "识别到设备界面则关掉,带Jumpback",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    1081,
                    107,
                    68,
                    63
                ],
                "template": "AutoEcoFarm/AutoecofarmBlackcloseWhitegrouund.png",
                "threshold": 0.7
            }
        },
        "action": "Click",
        "next": [
            "_AutoEcoFarmJumpBack"
        ]
    },
    "_AutoEcoFarmCloseFertilizer": {
        "desc": "识别到肥料界面则关掉,带Jumpback",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    1074,
                    147,
                    37,
                    31
                ],
                "template": "AutoEcoFarm/AutoecofarmWhitecloseblackgrouund.png",
                "threshold": 0.7
            }
        },
        "action": "Click",
        "next": [
            "_AutoEcoFarmJumpBack"
        ]
    },
    "_AutoEcoFarmInAnyFarm": {
        "desc": "确认是否在任意农场内,还在的话继续循环",
        "enabled": true,
        "recognition": {
            "type": "Or",
            "param": {
                "any_of": [
                    "_AutoEcoFarmInValleyIVFarm",
                    "_AutoEcoFarmInWulinFarm"
                ]
            }
        },
        "next": [
            "_AutoEcoFarmJump"
        ]
    },
    "_AutoEcoFarmInValleyIVFarm": {
        "desc": "确认是否在谷地农场内",
        "recognition": "Custom",
        "custom_recognition": "MapTrackerAssertLocation",
        "custom_recognition_param": {
            "expected": [
                {
                    "map_name": "map01_lv005",
                    "target": [
                        551,
                        322,
                        23,
                        23
                    ]
                }
            ],
            "precision": 1
        }
    },
    "_AutoEcoFarmInWulinFarm": {
        "desc": "确认是否在武陵农场内",
        "recognition": "Custom",
        "custom_recognition": "MapTrackerAssertLocation",
        "custom_recognition_param": {
            "expected": [
                {
                    "map_name": "map02_lv002",
                    "target": [
                        413,
                        164,
                        33,
                        32
                    ]
                }
            ],
            "precision": 1
        }
    },
    "_AutoEcoFarmFindMenuIcon": {
        "desc": "寻找采集、播种、浇水的文字",
        "recognition": {
            "type": "OCR",
            "param": {
                "roi": [
                    806,
                    340,
                    266,
                    266
                ],
                "expected": [
                    "收获|育苗|浇水",
                    "收穫|育苗|澆水",
                    "(?i)Harvest|Germinate|Water",
                    "収穫|栽培|水やり",
                    "수확|육묘|물 주기"
                ],
                "threshold": 0.7
            }
        },
        "next": [
            "_AutoEcoFarmWork1"
        ]
    },
    "_AutoEcoFarmWork1": {
        "desc": "按下alt",
        "action": {
            "type": "KeyDown",
            "param": {
                "key": 18 //alt键
            }
        },
        "next": [
            "_AutoEcoFarmWork2"
        ]
    },
    "_AutoEcoFarmWork2": {
        "desc": "按下鼠标左键,点击菜单",
        "pre_delay": 0,
        "action": {
            "type": "Click",
            "param": {
                "target": "_AutoEcoFarmFindMenuIcon"
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmWork3"
        ]
    },
    "_AutoEcoFarmWork3": {
        "desc": "松开alt",
        "pre_delay": 0,
        "action": {
            "type": "KeyUp",
            "param": {
                "key": 18 //alt键
            }
        },
        "next": [
            "AutoEcoFarmEnterCameraModeKeyDownR"
        ]
    },
    "_AutoEcoFarmCancelMove": {
        "desc": "退出任务前先松开w",
        "action": {
            "type": "KeyUp",
            "param": {
                "key": 87 //w键
            }
        },
        "next": [
            "_AutoEcoFarmMoveAndWorkExit"
        ]
    },
    //下面是单纯靠近标记的节点
    "_AutoEcoFarmGotoTarget": {
        "desc": "不工作，直接走到标记消失为止",
        "enabled": false,
        "next": [
            "_AutoEcoFarmJumpNotWork"
        ]
    },
    "_AutoEcoFarmJumpNotWork": {
        "desc": "不工作版往前跳，防止被卡住，先按下w",
        //加点限制免得bug导致无限循环
        "max_hit": 20,
        "pre_delay": 0,
        "action": {
            "type": "KeyDown",
            "param": {
                "key": 87 //w键
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmJumpNotWork2"
        ]
    },
    "_AutoEcoFarmJumpNotWork2": {
        "desc": "按一下空格",
        "pre_delay": 0,
        "action": {
            "type": "LongPressKey",
            "param": {
                "duration": 500,
                "key": 32 //空格键
            }
        },
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmJumpNotWork3"
        ]
    },
    "_AutoEcoFarmJumpNotWork3": {
        "desc": "松开w",
        "action": {
            "type": "KeyUp",
            "param": {
                "key": 87 //w键
            }
        },
        //稍微加点延迟保证停稳
        "post_delay": 200,
        "next": [
            "_AutoEcoFarmTargetNotExists",
            "_AutoEcoFarmJumpNotWork",
            //要是尝试次数过多则回到普通循环
            "_AutoEcoFarmJump"
        ]
    },
    "_AutoEcoFarmTargetNotExists": {
        "desc": "判断标记不在视野内则回到普通循环，从往前跳一下开始，这样尽量靠近标记目标",
        "recognition": {
            "type": "TemplateMatch",
            "param": {
                "roi": [
                    420,
                    100,
                    440,
                    300
                ],
                "template": "AutoEcoFarm/AutoEcoFarmFarmland.png",
                "threshold": 0.4
            }
        },
        "inverse": true,
        "pre_delay": 0,
        "post_delay": 0,
        "next": [
            "_AutoEcoFarmJump"
        ]
    }
}
