local this = class("trainTaskTpl")

function this:init(config)
  self.data = config
  self._typeData = {}
  self._dungeon2TaskId = {}
  for i, v in pairs(config) do
    self._typeData[v.taskType] = self._typeData[v.taskType] or {}
    table.insert(self._typeData[v.taskType], v)
    self._dungeon2TaskId[v.dungeonId] = v.taskid
  end
end

function this:getTplById(id)
  return self.data[id]
end

function this:getPassReward(tpl)
  return L_DataUtil.parseRewardConfig(tpl.passReward)
end

function this:getDungeonId(tpl)
  return tpl.dungeonId
end

function this:getTaskid(tpl)
  return tpl.taskid
end

function this:getUnlockCondition(tpl)
  return tpl.unlockCondition
end

function this:getTasktype(tpl)
  return tpl.Tasktype
end

function this:getTaskName(tpl)
  return L_Config:provider(tpl.taskName)
end

function this:getSortId(tpl)
  return tpl.sortId
end

function this:getDesc(tpl)
  return L_Config:provider(tpl.dec)
end

function this:getTplListByTrainTaskType(type)
  return self._typeData[type] or {}
end

function this:getTaskIdByDungeonId(dungeonId)
  if not self._dungeon2TaskId[dungeonId] then
    error("\230\137\190\228\184\141\229\136\176dungeonId\239\188\154", dungeonId, "\229\175\185\229\186\148\231\154\132taskId")
  end
  return self._dungeon2TaskId[dungeonId]
end

return this
