diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 3e315fa8..39ae332b 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -477,8 +477,35 @@ function BattleController:enterElimination(needDelay) self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION end) else - Logger.logHighlight("----- 处于无法消除状态 -----") - self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION + local resetList = {} + for posId, entity in pairs(self.battleData:getGridEnties()) do + if entity:isEmptyIdle() then + table.insert(resetList, posId) + end + end + local resetInfo = self:resetGrids(resetList) + if resetInfo then + if EDITOR_MODE then + Logger.logHighlight("----- 处于无法消除状态 -----") + end + self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION + else + if self.resetGridSid then + ModuleManager.BattleManager:unscheduleGlobal(self.resetGridSid) + self.resetGridSid = nil + end + + self.resetGridSid = ModuleManager.BattleManager:performWithDelayGlobal(function() + local count = 1 + for posId, info in pairs(resetInfo) do + self.battleData:setGridInfo(posId, info) + self.battleUI:playChangeElementSfx(posId, count) + count = count + 1 + end + self.resetGridSid = nil + self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_ELIMINATION + end, 0.5) + end end else self.attentionList = pathList @@ -1685,7 +1712,7 @@ function BattleController:changeElementType(count, elementType) end local entity = table.remove(list, math.random(1, #list)) if entity then - entity:setElementType(elementType) + self.battleData:setGridInfo(entity:getPosId(), {gridType = entity:getGridType(), elementType = elementType}) self.battleUI:playChangeElementSfx(entity:getPosId(), i) end end @@ -1935,6 +1962,81 @@ function BattleController:findAttention() return find, pathList end +function BattleController:resetGrids(posList) + local needCount = self:getMinEliminationCount() + if not posList[needCount] then + return + end + + local posMap = {} + for _, posId in ipairs(posList) do + posMap[posId] = true + end + local useMap = {} + local gotPosList = false + for _, posId in ipairs(posList) do + useMap = {} + local count = 0 + local findPodId = posId + gotPosList = false + while true do + local aounrdList = BattleConst.GRID_OUT_LINE_POS_ID[findPodId] + if not aounrdList then + break + end + local got = false + for id, status in pairs(aounrdList) do + if posMap[id] and not useMap[id] then + count = count + 1 + useMap[id] = true + findPodId = id + got = true + break + end + end + if not got then + break + end + if count >= needCount then + gotPosList = true + break + end + end + + if gotPosList then + break + end + end + + if not gotPosList then + return + end + + local canRandomElmentList = {} + for typeName, typeNum in pairs(BattleConst.ELEMENT_TYPE) do + if not self:getSealElementType()[typeNum] and self.battleData:getSkillEntityByElement(typeNum) then + table.insert(canRandomElmentList, typeNum) + end + end + + if not canRandomElmentList[1] then + return + end + + local elementCount = #canRandomElmentList + local mainElement = canRandomElmentList[math.random(1, elementCount)] + local resetPosInfo = {} + for posId, _ in pairs(posMap) do + if useMap[posId] then + resetPosInfo[posId] = {gridType = BattleConst.GRID_TYPE.EMPTY, elementType = mainElement} + else + resetPosInfo[posId] = {gridType = BattleConst.GRID_TYPE.EMPTY, elementType = canRandomElmentList[math.random(1, elementCount)]} + end + end + + return resetPosInfo +end + function BattleController:findLinkLine(posId, posIdMap, hadSkill, mainElementType, lineList) posIdMap[posId] = true table.insert(lineList, posId) @@ -2067,6 +2169,7 @@ function BattleController:clear() BattlePool:clear() self:unBindAll() DataManager.BattleData:resetTimeSpeed() + ModuleManager.BattleManager:unscheduleAll() end function BattleController:endBattleAndExit() diff --git a/lua/app/server/data/server_item_data.lua b/lua/app/server/data/server_item_data.lua index c5e1a5dc..0faffa5c 100644 --- a/lua/app/server/data/server_item_data.lua +++ b/lua/app/server/data/server_item_data.lua @@ -58,23 +58,23 @@ function ServerItemData:checkRecoveries() table.insert(self.data.recoveries, {cfg_id = k, ts = Time:getServerTime()}) end end - self:recoveryItems() + self:recoveryItems(true) end -function ServerItemData:recoveryItems() +function ServerItemData:recoveryItems(isInit) if not self.data.recoveries then return end for i,v in ipairs(self.data.recoveries) do if v.cfg_id == GConst.ItemConst.ITEM_ID_VIT then local maxCount = self:getMaxVit() - self:recoveryItem(v, maxCount) + self:recoveryItem(v, maxCount, isInit) end end end -function ServerItemData:recoveryItem(data, maxCount) +function ServerItemData:recoveryItem(data, maxCount, isInit) if not CS.BF.BFMain.IsGotServerTime then return end @@ -116,6 +116,10 @@ function ServerItemData:recoveryItem(data, maxCount) addCount = maxCount - currentCount end self:_addItem(data.cfg_id, addCount) + + if data.cfg_id == GConst.ItemConst.ITEM_ID_VIT then + BIReport:postItemGet(addCount, data.cfg_id) + end ServerDataManager:saveData() end