local this = class("modulePetFlashEft", G_UIModuleBase)
local specialEftIconPath = "UI/Icon/PetPixelSpecialEft/Sparkle_B_%d.png"

function this.bind()
  return {active_specialEft = false, img_specialEft = ""}
end

function this:setModulePetFlashEftData(guid)
  if not self.isBind then
    return
  end
  self._curFrame = 0
  L_TimerManager:clearTimer(self)
  if L_PetStore:judgePetHasSpecialGene(guid) then
    self:playPixelGif()
  else
    self.bind.active_specialEft = false
  end
end

function this:setModulePetHasFlashEft(bFlash)
  if not self.isBind then
    return
  end
  self._curFrame = 0
  L_TimerManager:clearTimer(self)
  if bFlash then
    self:playPixelGif()
  else
    self.bind.active_specialEft = false
  end
end

function this:playPixelGif()
  L_TimerManager:newOrResetTimer(self, "playGif", function()
    if not self.bind.active_specialEft then
      self.bind.active_specialEft = true
    end
    self._curFrame = self._curFrame % 24 + 1
    self.bind.img_specialEft = string.format(specialEftIconPath, self._curFrame)
  end, 0.1, -1)
end

function this:close()
  L_TimerManager:clearTimer(self)
end

return this
