c1_lua/lua/app/module/battle/controller/battle_controller_arena.lua
2023-06-28 21:24:15 +08:00

123 lines
3.8 KiB
Lua

local BattleControllerPVP = require "app/module/battle/controller/battle_controller_pvp"
local BattleControllerArena = class("BattleControllerArena", BattleControllerPVP)
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
function BattleControllerArena:getBoardConfig()
return ConfigManager:getConfig("arena_board")
end
function BattleControllerArena:getChapterConfig()
return ConfigManager:getConfig("arena_rank")
end
function BattleControllerArena:getChapterId()
return 101 -- 临时
end
function BattleControllerArena:getBuffs()
if not self.initBuffs then
self.initBuffs = {}
local buffList = {}
local config = self:getChapterConfig()[self.chapterId]
if config and config.effect then
for _, effect in ipairs(config.effect) do
local atkBuffInfo = {
buff = GFunc.getTable(effect),
obj = GConst.BattleConst.SIDE_ATK
}
local defBuffInfo = {
buff = GFunc.getTable(effect),
obj = GConst.BattleConst.SIDE_DEF
}
table.insert(buffList, atkBuffInfo)
table.insert(buffList, defBuffInfo)
end
end
for _, info in ipairs(buffList) do
local buffEntity = BattleBuffEntity:create()
buffEntity:init(info.buff)
buffEntity:setTargetSide(info.obj)
buffEntity:setIsCantRemove(true)
buffEntity:setNotShowIcon(true)
table.insert(self.initBuffs, {buffEntity = buffEntity, effect = info.buff})
end
end
return self.initBuffs
end
-- 战斗结束
function BattleControllerArena:controllBattleEnd()
end
-- 一共有多少波
function BattleControllerArena:getMaxWave()
return 1
end
function BattleControllerArena:getMaxRoundCount()
if not self.arenaMaxRound then
self.arenaMaxRound = GFunc.getConstIntValue("arena_max_round")
end
return self.arenaMaxRound
end
function BattleControllerArena:findNextDefUnit()
self:enterRoundEnd(true)
end
function BattleControllerArena:postWaveOver(atkDead, isQuit)
end
function BattleControllerArena:postFightStart()
end
function BattleControllerArena:getAtkMinRow()
return GConst.BattleConst.PVP_ROW_COUNT // 2
end
function BattleControllerArena:getInitBoard()
if not self.boradList then
self.boradList = {}
self.fixedRandomGrid = {}
self.mysteryBoxIndexMap = {}
local config = self:getChapterConfig()[self.chapterId]
local boardCfg = self:getBoardConfig()
local boardId = config.rand_board[math.random(1, #config.rand_board)]
local cfg = boardCfg[boardId]
if cfg then
local board = GFunc.getTable(cfg.board)
for index, info in ipairs(board) do
if info[2] == GConst.BattleConst.ELEMENT_TYPE.NONE then
board[index][2] = math.random(1, GConst.BattleConst.ELEMENT_TYPE_COUNT)
end
end
table.insert(self.boradList, {board = board, mysteryBoard = GFunc.getTable(cfg.mystery_box_board)})
table.insert(self.fixedRandomGrid, GFunc.getTable(cfg.control_element))
end
end
return self.boradList, self.fixedRandomGrid, self.mysteryBoxIndexMap
end
function BattleControllerArena:onTouchEvent(eventType, posId, isVirtual)
local isAtkAction = self.curActionSide == GConst.BattleConst.SIDE_ATK
local r = ModuleManager.BattleManager:getPosRC(posId).r
if isAtkAction then
if r <= self:getAtkMinRow() then
return
end
else
if r > self:getAtkMinRow() then
return
end
end
BattleControllerPVP.onTouchEvent(self, eventType, posId, isVirtual)
end
return BattleControllerArena