local this = class("pageTestBattleScene", G_UIPageBase)

function this.bind()
  return {
    scrollScene = {
      moduleName = "pages/bugWorld/cellItem/cellTestClickItem"
    }
  }
end

function this.methods()
  return {
    onClick_close = function(self)
      L_UI:close(self.pageName)
    end,
    scrollScene = {
      onClick = function(self, bind)
        local id = bind.id
        L_UI:close(self.pageName)
        AzurWorld.proxyCenter:ToSimulate(id, CS.Azur.Gameplay.Flows.ESimulateType.BattleSimulate)
      end
    },
    onValueChanged_scene = function(self, index)
      self:refreshSceneList(index + 1)
    end
  }
end

function this:ctor()
  this.super.ctor(self)
end

function this:open(options)
  this.super.open(self, options)
  self:refreshSceneList()
end

function this:refreshSceneList(index)
  index = index or self.sceneIndex or 1
  if self.sceneIndex == index then
    return
  end
  self.sceneIndex = index
  local sceneList = {}
  self.bind.scrollScene:clear()
  if self.sceneIndex == 1 then
    table.merge(sceneList, L_GameTpl:getWorldCityTpl().data)
    for _, v in pairs(sceneList) do
      self.bind.scrollScene:insert({
        id = v.id,
        txt_name = L_GameTpl:getWorldCityTpl():getCity(v)
      })
    end
  else
    local dungeonTpl = L_GameTpl:getDungeonTpl()
    for i, v in pairs(dungeonTpl.data) do
      if not dungeonTpl:getIsRandomDungeon(v) then
        table.insert(sceneList, v)
      end
    end
    local dungeonRandomTpl = L_GameTpl:getDungeonRandomTpl()
    table.merge(sceneList, dungeonRandomTpl.data)
    for _, v in pairs(sceneList) do
      self.bind.scrollScene:insert({
        id = L_GameTpl:getDungeonTpl():getId(v),
        txt_name = L_Config:provider(v.name or v.dungeonRandomName)
      })
    end
  end
end

function this:close(options)
  this.super.close(self, options)
end

return this
