local this = class("moduleSummonNotify", G_UIModuleBase)
local playerShow = L_Config:getConfig("game", "KIBO_DUEL_CUT_IN_PLAYER")
local enemyShow = L_Config:getConfig("game", "KIBO_DUEL_CUT_IN_ENEMY")

function this.bind()
  return {
    playerNotify = {
      moduleName = "pages/petDuel/modulePetNotify"
    },
    enemyNotify = {
      moduleName = "pages/petDuel/modulePetNotify"
    },
    playerActive = false,
    enemyActive = false
  }
end

function this.methods()
  return {}
end

function this:open()
  L_KiBoDuelManager:addListener(L_KiBoDuelManager.event.kiBoSummoned, self.onKiBoSummoned, self)
  L_KiBoDuelManager:addListener(L_KiBoDuelManager.event.restartKiBoDuel, self.restartKiBoDuel, self)
end

function this:close()
  L_KiBoDuelManager:removeListener(L_KiBoDuelManager.event.kiBoSummoned, self.onKiBoSummoned, self)
  L_KiBoDuelManager:removeListener(L_KiBoDuelManager.event.restartKiBoDuel, self.restartKiBoDuel, self)
end

function this:restartKiBoDuel()
  self.bind.playerActive = false
  self.bind.enemyActive = false
end

function this:onKiBoSummoned(data)
  if data.isPlayer then
    if not playerShow then
      return
    end
    self.modules.playerNotify:setPet(data.petConfigId, data.guid)
    self.bind.playerActive = false
    self.bind.playerActive = true
  else
    if not enemyShow then
      return
    end
    self.modules.enemyNotify:setPet(data.petConfigId)
    self.bind.enemyActive = false
    self.bind.enemyActive = true
  end
end

return this
