local this = class("gachaTpl")

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

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

function this:getGachaType(tpl)
  return tpl.gachaType
end

function this:getProbList(tpl)
  return tpl.probList
end

function this:getResourceId(tpl)
  return tpl.resourceId
end

function this:getChooseId(tpl)
  return tpl.chooseId
end

function this:getEndTime(tpl)
  return L_TimeUtil.parseConfigDatetime(tpl.endTime)
end

function this:getTenTimecostId(tpl)
  return tpl.tenTimecostId
end

function this:getOpenCondition(tpl)
  return tpl.openCondition
end

function this:getGachaLimit(tpl)
  return math.isEmpty(tpl.gachaLimit) and math.maxinteger or tpl.gachaLimit
end

function this:getGachaName(tpl)
  return L_Config:provider(tpl.gachaName)
end

function this:getCanUsedNum(tpl)
  return math.isEmpty(tpl.canUsedNum) and math.maxinteger or tpl.canUsedNum
end

function this:getIsChooseWeapon(tpl)
  return tpl.isChooseWeapon
end

function this:getGachaId(tpl)
  return tpl.gachaId
end

function this:getStartTime(tpl)
  return L_TimeUtil.parseConfigDatetime(tpl.startTime)
end

function this:getCostId(tpl)
  return tpl.costId
end

function this:getCostNum(tpl, times)
  if times == 1 then
    return tpl.costId[3]
  elseif times == 10 then
    return tpl.tenTimecostId[3]
  end
end

function this:getAllTpl()
  return self.data
end

function this:getIsInOpenTime(tpl)
  local startTime = L_TimeUtil.parseConfigDatetime(tpl.startTime)
  local endTime = L_TimeUtil.parseConfigDatetime(tpl.endTime)
  local nowTime = L_TimeUtil.getServerTime()
  local type = tpl.gachaType
  if type == 2 and (startTime > nowTime or endTime < nowTime and endTime ~= 0) then
    return false
  end
  if L_SystemUnlockStore:getSystemIsBan(tpl.systemId) then
    return false
  end
  return true
end

function this:getUpStuff(tpl)
  return tpl.upStuff
end

return this
