buff数值上线

This commit is contained in:
xiekaidong 2023-09-05 17:14:49 +08:00
parent 180c12435f
commit f839dc3b57
3 changed files with 70 additions and 0 deletions

View File

@ -1352,6 +1352,10 @@ function BattleUnitComp:addBuff(buffEffect, conditionResult)
return self.team:addBuff(buffEffect)
end
function BattleUnitComp:judgeBuffEffectEffectNumOverflow(buffEntity)
return self.team:judgeBuffEffectEffectNumOverflow(buffEntity)
end
function BattleUnitComp:getBuffCountByName(buffName)
return self.team:getBuffCountByName(buffName)
end
@ -1553,6 +1557,9 @@ function BattleUnitComp:takeEffect(buff, target, conditionResult)
buffEffect.target = target
buffEffect.sender = self
buffEffect = target:addBuff(buffEffect, conditionResult)
if not buffEffect then -- 添加buff失败
return
end
end
if buffEffect and buffEffect.result then
return
@ -1584,6 +1591,9 @@ function BattleUnitComp:reTakeEffectByBuffEffect(buffEffect)
if round > 0 then
buffEffect.result = nil
buffEffect = target:addBuff(buffEffect)
if not buffEffect then -- 添加buff失败
return
end
end
if buffEffect and buffEffect.result then
return

View File

@ -11,6 +11,7 @@ function BattleTeam:init(side, battleController)
self.unitMap = {}
self.buffList = {}
self.sameBuffCount = {}
self.sameBuffEffectNum = {} -- 相同的buff参数用于判定buff数值上限
self.shieldBuffList = {}
self.loopFxMap = {}
self.comboCount = 0
@ -265,9 +266,14 @@ function BattleTeam:handleShield(reduceShield, unit)
if needReedRefreshBuff then
self.battleController:refreshBuff(self.side, self.buffList)
end
self:calSameBuffEffectNum()
end
function BattleTeam:addBuff(buffEffect)
if not self:judgeBuffEffectEffectNumOverflow(buffEffect.buff) then
return
end
local stack = buffEffect.buff:getStack()
local needRecycle
if not stack or stack == BattleConst.BUFF_STACK_TYPE.CANT_ADD then
@ -337,6 +343,7 @@ function BattleTeam:addBuff(buffEffect)
self.battleController:refreshBuff(self.side, self.buffList)
end
self:calSameBuffEffectNum()
return needRecycle
end
@ -364,6 +371,7 @@ function BattleTeam:removeAllBuff()
end
self.battleController:clearBuff(self.side)
self:calSameBuffEffectNum()
end
function BattleTeam:putCacheBuff(buffEffect)
@ -402,6 +410,8 @@ function BattleTeam:putCacheBuffByDecr(buffDecr)
if needRefresh then
self.battleController:refreshBuff(self.side, self.buffList)
end
self:calSameBuffEffectNum()
end
function BattleTeam:popCacheBuffByDecr(buffDecr)
@ -426,6 +436,48 @@ function BattleTeam:popCacheBuffByDecr(buffDecr)
if needRefresh then
self.battleController:refreshBuff(self.side, self.buffList)
end
self:calSameBuffEffectNum()
end
function BattleTeam:calSameBuffEffectNum()
if not self.buffList then
return
end
self.sameBuffEffectNum = table.clearOrCreate(self.sameBuffEffectNum)
for _, buffEffect in ipairs(self.buffList) do
local buffEntity = buffEffect.buff
if buffEntity then
local buffName = buffEntity:getName()
local buffNum = buffEntity:getEffectNum()
if buffName and buffNum then
self.sameBuffEffectNum[buffName] = (self.sameBuffEffectNum[buffName] or 0) + buffNum
end
end
end
end
function BattleTeam:judgeBuffEffectEffectNumOverflow(buffEntity)
if not buffEntity then
return true
end
local limitNum = buffEntity:getLimitParameter()
if not limitNum then
return true
end
local buffName = buffEntity:getName()
local buffNum = buffEntity:getEffectNum()
local curNum = self.sameBuffEffectNum[buffName] or 0
local remainNum = limitNum - curNum
if remainNum <= 0 then -- 已经超出上限了,直接返回失败
return false
end
if buffNum > remainNum then
buffEntity:setEffectNum(remainNum)
end
return true
end
function BattleTeam:doBuffWork()
@ -473,6 +525,8 @@ function BattleTeam:doBuffWork()
end
end
self.battleController:refreshBuff(self.side, self.buffList)
self:calSameBuffEffectNum()
end
-- 比如复活类需要最后触发buff
@ -514,6 +568,7 @@ function BattleTeam:doFinalBuffWork()
if refreshUI then
self.battleController:refreshBuff(self.side, self.buffList)
end
self:calSameBuffEffectNum()
end
function BattleTeam:removeBuffByName(buffName)
@ -531,6 +586,7 @@ function BattleTeam:removeBuffByName(buffName)
end
end
self.battleController:refreshBuff(self.side, self.buffList)
self:calSameBuffEffectNum()
end
function BattleTeam:updateBuffState(buff, num)

View File

@ -141,6 +141,10 @@ function BattleBuffEntity:needShowName()
return self.buffInfo.show_name
end
function BattleBuffEntity:getLimitParameter()
return self.buffInfo.limit_parameter
end
function BattleBuffEntity:isCantRemove()
return self.cantRemove
end