提交第一版查找死局算法
This commit is contained in:
parent
073b4cceab
commit
cf7799e633
@ -1255,6 +1255,109 @@ function BattleController:snapshotBoard()
|
|||||||
return snapshot
|
return snapshot
|
||||||
end
|
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)
|
function BattleController:addBattleExp(exp)
|
||||||
if not self.battleData or not exp then
|
if not self.battleData or not exp then
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user