From cf7799e63329e82e3864abfc64f3e21f4da891df Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Wed, 19 Apr 2023 12:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=AC=AC=E4=B8=80=E7=89=88?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E6=AD=BB=E5=B1=80=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/controller/battle_controller.lua | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 9c5974c8..c4fdcf50 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -1255,6 +1255,109 @@ function BattleController:snapshotBoard() return snapshot end +function BattleController:findAttention() + local find = false + local posIdMap = {} + local pathList + for r = 1, GConst.BattleConst.ROW_COUNT do + for c = 1, GConst.BattleConst.COLUMN_COUNT do + local posId = ModuleManager.BattleManager:getPosId(r, c) + local gridEntity = self.battleData:getGridEntity(posId) + local skillId = gridEntity:getSkillId() + local mainElementType = gridEntity:getElementType() + if skillId then + local skillEntity = self.battleData:getSkillEntityBySkillId(skillId) + if skillEntity:ignoreElementType() then + mainElementType = nil + end + end + + pathList = {} + self:findLinkLine(posId, posIdMap, mainElementType == nil, mainElementType, pathList) + if table.nums(pathList) >= self:getMinEliminationCount() then + find = true + break + end + end + if find then + break + end + end + + return find, pathList +end + +function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementType, lineList) + posIdMap[posId] = true + table.insert(lineList, posId) + local list = BattleConst.GRID_OUT_LINE_POS_ID[posId] + if not list then + return hadSkill + end + + local lineCount = 0 + local maxLineList + local maxPosIdMap + local maxGotSkill + for aroundposId, _ in pairs(list) do + if not posIdMap[aroundposId] then + local gridEntity = self.battleData:getGridEntity(aroundposId) + if gridEntity then + if gridEntity:isEmptyIdle() then + if not mainElementType or gridEntity:getElementType() == mainElementType then + mainElementType = mainElementType or gridEntity:getElementType() + local tempIdMap = GFunc.getTable(posIdMap) + local newList = GFunc.getTable(lineList) + local gotSkill = self:findLinkLine(aroundposId, tempIdMap, hadSkill, mainElementType, newList) + local count = #newList + if count > lineCount then + lineCount = count + maxLineList = newList + maxPosIdMap = tempIdMap + maxGotSkill = gotSkill + end + end + elseif gridEntity:getSkillId() and not hadSkill and mainElementType then + local skillId = gridEntity:getSkillId() + local skillEntity = self.battleData:getSkillEntityBySkillId(skillId) + if skillEntity then + if skillEntity:ignoreElementType() or skillEntity:getPosition() == mainElementType then + local tempIdMap = GFunc.getTable(posIdMap) + local newList = GFunc.getTable(lineList) + local gotSkill = self:findLinkLine(aroundposId, tempIdMap, true, mainElementType, newList) + local count = #newList + if count > lineCount then + lineCount = count + maxLineList = newList + maxPosIdMap = tempIdMap + maxGotSkill = gotSkill + end + end + end + end + end + end + end + + if lineCount > 0 then + for index, id in ipairs(maxLineList) do + lineList[index] = id + end + + for _, id in pairs(maxPosIdMap) do + posIdMap[id] = true + end + + hadSkill = maxGotSkill + end + + return hadSkill +end + +function BattleController:randomDisruptionBoard() + +end + function BattleController:addBattleExp(exp) if not self.battleData or not exp then return