From 37f93d1cd127cae1c12951146cf41c68b7b50fc4 Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Fri, 15 Sep 2023 17:41:29 +0800 Subject: [PATCH] =?UTF-8?q?pvp=E6=88=98=E6=96=97=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E9=9A=8F=E6=9C=BA=E5=8A=A0=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/battle_controller_pvp.lua | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lua/app/module/battle/controller/battle_controller_pvp.lua b/lua/app/module/battle/controller/battle_controller_pvp.lua index edc3da4b..ef91dfb1 100644 --- a/lua/app/module/battle/controller/battle_controller_pvp.lua +++ b/lua/app/module/battle/controller/battle_controller_pvp.lua @@ -320,4 +320,37 @@ function BattleControllerPVP:refreshWave() self.battleUI:refreshWave(self.waveRoundCount[self:getWaveIndex()] or 0) end +function BattleControllerPVP:getRandomGridInfo() + local list, fixedRandomGrid = self:getInitBoard() + local fixedRandomList = fixedRandomGrid[self.curBoardIndex] + + local gridType = 0 + local elementType + if fixedRandomList and fixedRandomList[1] then + elementType = table.remove(fixedRandomList, 1) + else + local map = self.battleData:getElementTypeMap() + self.getRandomGridInfoIndexs = table.clearOrCreate(self.getRandomGridInfoIndexs) + self.getRandomGridInfoTypeList = table.clearOrCreate(self.getRandomGridInfoTypeList) + for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do + if not self:getSealElementType()[typeNum] and self:getSkillEntityByElement(typeNum) then + local weight = BattleConst.ELEMENT_WIGHT -- 改为平等权重 + if self.elementWeightMap and self.elementWeightMap[typeNum] then + weight = weight + self.elementWeightMap[typeNum] + end + if weight > BattleConst.MAX_ELEMENT_WIGHT then + weight = BattleConst.MAX_ELEMENT_WIGHT + end + table.insert(self.getRandomGridInfoIndexs, weight) + table.insert(self.getRandomGridInfoTypeList, typeNum) + end + end + + local index = GFunc.getRandomIndex(self.getRandomGridInfoIndexs) + elementType = self.getRandomGridInfoTypeList[index] + end + + return {gridType = gridType, elementType = elementType} +end + return BattleControllerPVP \ No newline at end of file