战斗系数

This commit is contained in:
xiekaidong 2023-06-29 21:56:47 +08:00
parent 1035873eef
commit e7c6c45f0d
2 changed files with 35 additions and 5 deletions

View File

@ -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()

View File

@ -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
@ -53,12 +58,30 @@ function BoardHelper:findPvpLinkOptimalSolution(battleController, startRow, endR
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