local this = class("rogueResearchTpl")

function this:init(config)
  self.data = config
  self.treeData = {}
end

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

function this:getResearchPointNeed(tpl)
  return tpl.researchPointNeed
end

function this:getId(tpl)
  return tpl.id
end

function this:getNote(tpl)
  return L_Config:provider(tpl.note)
end

function this:getAbilityPara(tpl)
  return tpl.abilityPara
end

function this:getResearchName(tpl)
  return L_Config:provider(tpl.researchName)
end

function this:getResearchNeed(tpl)
  return tpl.researchNeed
end

function this:getAbility(tpl)
  return tpl.ability
end

function this:getIcon(tpl)
  return L_Config:getPathByHash(tpl.icon)
end

function this:getIconUnlock(tpl)
  return L_Config:getPathByHash(tpl.iconUnlock)
end

function this:getUiPos(tpl)
  local pos = L_Vector3.new(tpl.coordinate[1], tpl.coordinate[2], 0)
  return pos
end

function this:getBrother(tpl)
  local father = tpl.researchNeed
  local res = {}
  for i, fa in pairs(father) do
    for i1, tpl1 in pairs(self.data) do
      local father_tmp = tpl1.researchNeed
      local node, index = table.ipairsFind(father_tmp, function(v)
        return v == fa
      end)
      if index then
        if not res[fa] then
          res[fa] = {}
        end
        table.insert(res[fa], tpl1.id)
      end
    end
  end
  for i, v in pairs(res) do
    table.sort(v, function(a, b)
      return a < b
    end)
  end
  return res
end

return this
