local this = class("conditionNode_12045", require(L_R.condition .. "conditionNode"))
local _taskStepTpl = L_GameTpl:getTaskStepTpl()
local _taskTpl = L_GameTpl:getTaskTpl()

function this:ctor(condition)
  this.super.ctor(self, condition)
  L_TaskStore:listenCallFunc(L_TaskStore.event.refreshTask, self.refresh, self)
end

function this:onDestroy()
  this.super.onDestroy(self)
  L_TaskStore:unListenCallFunc(L_TaskStore.event.refreshTask, self.refresh, self)
end

function this.checkFunc(condition)
  local taskId = condition[2]
  local nodeId = condition[3]
  local isFinish = L_TaskStore:checkTaskIsFinished(taskId)
  if not isFinish then
    local tpl = _taskStepTpl:getTplByNode(taskId, nodeId)
    if tpl then
      isFinish = C_TaskManager.CheckTaskNodeIsFinished(taskId, nodeId)
    else
      error(string.format("conditionNode_12045 [%s_%s] : task step tpl not exist!", taskId, nodeId))
    end
  end
  return isFinish
end

function this.descFunc(key, codData)
  local taskId = codData[2]
  local taskTpl = _taskTpl:getTplById(taskId)
  local taskName = _taskTpl:getName(taskTpl)
  return L_Lang:get(key, {questName = taskName})
end

return this
