战斗系数
This commit is contained in:
parent
1035873eef
commit
e7c6c45f0d
@ -251,7 +251,13 @@ end
|
||||
|
||||
function BattleControllerPVP:checkDefBoard()
|
||||
if self:getCurActionSide() == SIDE_DEF then
|
||||
local path = board_heler:findPvpLinkOptimalSolution(self, self:getAtkMinRow(), 1)
|
||||
local elementTypeCoefficient = {}
|
||||
local teamEntity = self.battleData:getDefTeam()
|
||||
local members = teamEntity:getAllMembers()
|
||||
for k, v in pairs(members) do
|
||||
elementTypeCoefficient[v:getMatchType()] = v:getAtk()
|
||||
end
|
||||
local path = board_heler:findPvpLinkOptimalSolution(self, self:getAtkMinRow(), 1, elementTypeCoefficient)
|
||||
if path and #path >= self:getMinEliminationCount() then
|
||||
if self.showCheckDefBoardSeq then
|
||||
self.showCheckDefBoardSeq:Kill()
|
||||
|
||||
@ -21,7 +21,7 @@ function BoardHelper:recycleedEmptyTable(emptyTable)
|
||||
end
|
||||
end
|
||||
|
||||
function BoardHelper:findPvpLinkOptimalSolution(battleController, startRow, endRow)
|
||||
function BoardHelper:findPvpLinkOptimalSolution(battleController, startRow, endRow, elementTypeCoefficient)
|
||||
local battleData = battleController.battleData
|
||||
local gridMap = BoardHelper:getEmptyTable()
|
||||
local gridEntities = BoardHelper:getEmptyTable()
|
||||
@ -43,6 +43,11 @@ function BoardHelper:findPvpLinkOptimalSolution(battleController, startRow, endR
|
||||
|
||||
local maxPath
|
||||
local maxPathCount = 0
|
||||
local newHaveSkill = false
|
||||
local lastMainElementType
|
||||
if not elementTypeCoefficient then
|
||||
elementTypeCoefficient = BoardHelper:getEmptyTable()
|
||||
end
|
||||
for _, posId in pairs(gridEntities) do
|
||||
local entity = gridMap[posId]
|
||||
local mainElementType
|
||||
@ -50,15 +55,33 @@ function BoardHelper:findPvpLinkOptimalSolution(battleController, startRow, endR
|
||||
mainElementType = entity:getElementType()
|
||||
local tree = BoardHelper:getEmptyTable()
|
||||
self:getCanlinkTree(posId, gridMap, tree, mainElementType)
|
||||
|
||||
|
||||
local checked = BoardHelper:getEmptyTable()
|
||||
local haveSkill = false
|
||||
local path = self:findMaxPath(posId, tree, checked, haveSkill, gridMap)
|
||||
local path, getSkill = self:findMaxPath(posId, tree, checked, haveSkill, gridMap)
|
||||
local count = #path
|
||||
if count > maxPathCount then
|
||||
if getSkill and not newHaveSkill then
|
||||
maxPath = path
|
||||
maxPathCount = count
|
||||
newHaveSkill = getSkill
|
||||
lastMainElementType = mainElementType
|
||||
else
|
||||
local curCoefficient = elementTypeCoefficient[mainElementType] or 0
|
||||
local lastCoefficient = elementTypeCoefficient[lastMainElementType] or 0
|
||||
if not getSkill and newHaveSkill then
|
||||
BoardHelper:recycleedEmptyTable(path)
|
||||
else
|
||||
if count * curCoefficient > maxPathCount * lastCoefficient then
|
||||
maxPath = path
|
||||
maxPathCount = count
|
||||
newHaveSkill = getSkill
|
||||
lastMainElementType = mainElementType
|
||||
else
|
||||
BoardHelper:recycleedEmptyTable(path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for posId, info in pairs(tree) do
|
||||
BoardHelper:recycleedEmptyTable(info)
|
||||
end
|
||||
@ -67,6 +90,7 @@ function BoardHelper:findPvpLinkOptimalSolution(battleController, startRow, endR
|
||||
end
|
||||
end
|
||||
|
||||
BoardHelper:recycleedEmptyTable(elementTypeCoefficient)
|
||||
BoardHelper:recycleedEmptyTable(gridMap)
|
||||
|
||||
return maxPath
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user