local this = class("petItem")

function this:ctor()
  self.pet_name = nil
  self.guid = nil
  self.id = nil
  self.feature = nil
  self.comprehension = nil
  self.tpl = nil
  self.skills = nil
  self.lv = nil
  self.rank = nil
  self.exp = nil
  self.hero_id = nil
  self.petId = nil
  self.work_status = nil
  self.work_build = nil
  self.talent_id = {}
  self.capacity_id = nil
  self.roulette_pos = nil
  self.satiety_val = nil
  self.canteen_id = nil
  self.work_start_time = nil
  self.work_pause = nil
  self.base_lv = nil
  self.satiety = nil
  self.box_id = nil
  self.laborInfoList = {}
  self.special = L_Const.PetSpecialType.PST_NORMAL
end

function this:isWorking()
  return self.work_status == L_Const.PetStationedWorkStatusType.PSWST_HOME_WORK or self.work_status == L_Const.PetStationedWorkStatusType.PSWST_WILD_WORK
end

function this:isRest()
  return self.work_status == L_Const.PetStationedWorkStatusType.PSWST_HOME_REST or self.work_status == L_Const.PetStationedWorkStatusType.PSWST_WILD_REST or self.work_status == L_Const.PetStationedWorkStatusType.PSWST_FIELD_WORK or self.work_status == L_Const.PetStationedWorkStatusType.PSWST_RANCH_WORK or not math.isEmpty(self.canteen_id)
end

function this:isFreeWork()
  local csPetData = L_PetStore:getCsPetData(self.guid)
  return L_PetStore:getPetIsFreeWork(csPetData)
end

function this:isCollectionWorking()
  return self.work_status == L_Const.PetStationedWorkStatusType.PSWST_WILD_WORK or self.work_status == L_Const.PetStationedWorkStatusType.PSWST_WILD_REST
end

function this:isInMountRoulette()
  return not math.isEmpty(self.roulette_pos)
end

function this:isInCanteen()
  return not math.isEmpty(self.canteen_id)
end

function this:getGameplayStatus()
  if self:isWorking() then
    return L_Const.PetState.PET_WORKING
  elseif self:isRest() then
    return L_Const.PetState.PET_RESTING
  elseif self:isFreeWork() then
    return L_Const.PetState.PET_HUB
  elseif not math.isEmpty(self.roulette_pos) then
    return L_Const.PetState.PET_ROULETTE
  elseif not math.isEmpty(self.hero_id) then
    return L_Const.PetState.PET_HERO
  else
    return L_Const.PetState.PET_NORMAL
  end
end

function this:isSpecialPet()
  return self.color
end

function this:hasFlashGene()
  return self.special == L_Const.PetSpecialType.PST_FLASH or self.special == L_Const.PetSpecialType.PST_FLASH_COLOR
end

function this:getIsSpecialPet()
  return self.special == L_Const.PetSpecialType.PST_COLOR or self.special == L_Const.PetSpecialType.PST_FLASH_COLOR
end

function this:getPetName()
  return self.pet_name
end

function this:petCfgId()
  return self.id
end

function this:petGuid()
  return self.guid
end

function this:petLv()
  return self.lv
end

function this:getExp()
  return self.exp
end

function this:petCatchItemId()
  return self.catch_item or 0
end

function this:petFavorVal()
  return self.favor_val or 0
end

function this:petFavorLv()
  return self.favor_lv or 0
end

function this:getHeroId()
  return self.hero_id
end

function this:getIsTrial()
  return C_DataUtil.GetUuid2FightObjType(self.guid) == L_Const.FightObjType.FO_Trial_Pet
end

function this:getPetGrade()
  return self.grade or 0
end

function this:getTargetAttributeComprehension(attrEnumNum)
  if not self.comprehension then
    return nil
  end
  for _, comprehension in pairs(self.comprehension) do
    if comprehension.attr_id == attrEnumNum then
      return comprehension
    end
  end
  return nil
end

function this:getWorkBuilding()
  return self.work_build
end

function this:hasMutationGene()
  if table.isEmpty(self.mutation_info) then
    return false
  end
  return self.mutation_info.pos > 0
end

function this:getMutationInfo()
  return self.mutation_info
end

function this:getLaborInfoList()
  return self.laborInfoList
end

return this
