local this = class("cellDuelKillResult", G_UIModuleBase)
local petTpl = L_GameTpl:getPetTpl()

function this.bind()
  return {txt_winPetName = "", txt_losePetName = ""}
end

function this.methods()
  return {}
end

function this:open()
end

function this:close()
  self:disposeOutTimer()
end

function this:refresh()
  if not self.isBind then
    return
  end
  local data = self.bind
  local enemyTpl = petTpl:getTplById(data.enemy.petConfigId)
  local playerTpl = petTpl:getTplById(data.player.petConfigId)
  local slotId = L_KiBoDuelManager:getSlotIdByGuid(data.player.guid)
  if data.isWin then
    self.bind.txt_winPetName = L_GameUtil.fillColor(L_KiBoDuelManager:getPetNameBySlot(slotId), L_Const.colorHtml.blue010)
    self.bind.txt_losePetName = L_GameUtil.fillColor(petTpl:getName(enemyTpl, false), L_Const.colorHtml.red009)
  else
    self.bind.txt_losePetName = L_GameUtil.fillColor(L_KiBoDuelManager:getPetNameBySlot(slotId), L_Const.colorHtml.blue010)
    self.bind.txt_winPetName = L_GameUtil.fillColor(petTpl:getName(enemyTpl, false), L_Const.colorHtml.red009)
  end
  if string.isEmpty(self.bind.txt_winPetName) or string.isEmpty(self.bind.txt_losePetName) then
    printf("\229\135\186\231\142\176\229\165\135\230\179\162\231\169\186\229\144\141\229\173\151\228\186\134", data)
  end
end

function this:petIsSpecial(guid)
  if guid then
    local petItem = L_PetStore:getPetItem(guid)
    if petItem then
      return petItem:isSpecialPet()
    end
  end
  return false
end

function this:disposeOutTimer()
  if self.outTimer ~= nil then
    Timer.remove(self.outTimer)
    self.outTimer = nil
  end
end

function this:playShowAnimation(isWin)
  if not self.isBind or not self.bind.cellAnimation then
    return
  end
  if isWin then
    self.bindComponents.cellAnimation:Play("anim_petbattle_killtip_B")
  else
    self.bindComponents.cellAnimation:Play("anim_petbattle_killtip_R")
  end
  self:disposeOutTimer()
  self.outTimer = Timer.once(2.5, function()
    if not self.isBind or not self.bind.cellAnimation then
      return
    end
    self.bindComponents.cellAnimation:Play("anim_petbattle_killtip_out")
  end, self)
end

function this:playMove()
end

return this
