diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 2760a9bc..cb333483 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -692,6 +692,7 @@ BattleConst.SKILL_TYPE = { SHUFFLE_BOARD = 7, RANDOM_KILL_ROW_OR_COLUMN = 8, KILL_MAX_ELEMENT_AND_HEAL = 9, + KILL_ROW_AND_COLUMN = 10, } BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = { @@ -701,6 +702,7 @@ BattleConst.ATTACK_OVER_ACTIVE_SKILL_TYPE = { [BattleConst.SKILL_TYPE.SHUFFLE_BOARD] = true, [BattleConst.SKILL_TYPE.RANDOM_KILL_ROW_OR_COLUMN] = true, [BattleConst.SKILL_TYPE.KILL_MAX_ELEMENT_AND_HEAL] = true, + [BattleConst.SKILL_TYPE.KILL_ROW_AND_COLUMN] = true, } BattleConst.SKILL_METHOD_TYPE = { diff --git a/lua/app/module/battle/skill/battle_board_skill_handle.lua b/lua/app/module/battle/skill/battle_board_skill_handle.lua index e2464026..b1e88890 100644 --- a/lua/app/module/battle/skill/battle_board_skill_handle.lua +++ b/lua/app/module/battle/skill/battle_board_skill_handle.lua @@ -245,6 +245,73 @@ local function _takeKillMaxElementAndHeal(atkUnitComp, skillEntity, battleContro battleController:killGrids(list) end + +local function _takeKillRowAndColumn(atkUnitComp, skillEntity, battleController) + local battleData = battleController.battleData + if not battleData or not battleData:getGridEnties() or not skillEntity:getEliminateSkillParameter() then + return + end + + local params = skillEntity:getEliminateSkillParameter() + local rCount, cCount = params[1], params[2] + if rCount <= 0 and cCount <= 0 then + return + end + + local rowMap = {} + local columnMap = {} + local rList = {} + local rListCount = 0 + local cList = {} + local cListCount = 0 + for posId, entity in pairs(battleData:getGridEnties()) do + if entity:isEmptyIdle() then + local rc = ModuleManager.BattleManager:getPosRC(posId) + local r = rc.r + local c = rc.c + if not rowMap[r] then + table.insert(rList, r) + rListCount = rListCount + 1 + rowMap[r] = {} + end + if not columnMap[c] then + table.insert(cList, c) + cListCount = cListCount + 1 + columnMap[c] = {} + end + table.insert(rowMap[r], posId) + table.insert(columnMap[c], posId) + end + end + + local infoList = {} + rCount = math.min(rCount, rListCount) + cCount = math.min(cCount, cListCount) + for i = 1, rCount do + local r = table.remove(rList, math.random(1, rListCount)) + rListCount = rListCount - 1 + if rowMap[r] then + table.insert(infoList, { + r = r, + posList = rowMap[r] + }) + end + end + + for i = 1, cCount do + local c = table.remove(cList, math.random(1, cListCount)) + cListCount = cListCount - 1 + if columnMap[c] then + table.insert(infoList, { + c = c, + posList = columnMap[c] + }) + end + end + + battleController:killRowOrColumn(infoList) +end + BattleBoardSkillHandle._activeBoardSkill = { [SKILL_TYPE.ELIMINATION] = _takeElimination, [SKILL_TYPE.CHANGE_AROUND] = _takeChangeAround, @@ -258,6 +325,7 @@ BattleBoardSkillHandle._activeAttackOverSkill = { [SKILL_TYPE.SHUFFLE_BOARD] = _takeShuffleBoard, [SKILL_TYPE.RANDOM_KILL_ROW_OR_COLUMN] = _takeRandomKillRowOrColumn, [SKILL_TYPE.KILL_MAX_ELEMENT_AND_HEAL] = _takeKillMaxElementAndHeal, + [SKILL_TYPE.KILL_ROW_AND_COLUMN] = _takeKillRowAndColumn, } function BattleBoardSkillHandle.activeBoardSkill(posId, skillEntity, gridEntities, sequenceEntities, battleController)