;(() => {
  // 全局注册器：供 Barn 任务逻辑文件注册 check 函数
  if (!global.cloudIslandBarnMission) {
    global.cloudIslandBarnMission = {}
  }

  const root = global.cloudIslandBarnMission
  if (!root.logicMap) root.logicMap = {}
  if (!root.submitMap) root.submitMap = {}

  root.registerLogic = function registerLogic(key, checker) {
    if (!key || typeof checker !== 'function') return
    root.logicMap[String(key)] = checker
  }

  root.getLogic = function getLogic(key) {
    return root.logicMap[String(key || '')] || null
  }

  // 提交型任务：只有显式执行命令时才触发
  root.registerSubmit = function registerSubmit(key, submitter) {
    if (!key || typeof submitter !== 'function') return
    root.submitMap[String(key)] = submitter
  }

  root.getSubmit = function getSubmit(key) {
    return root.submitMap[String(key || '')] || null
  }
})()
