From 9c8e948242667e1a5fe81be06aa477d343a60d69 Mon Sep 17 00:00:00 2001 From: zhouhaihai Date: Wed, 16 Sep 2020 20:35:15 +0800 Subject: [PATCH] buff 被动 限定地图 --- src/adv/AdvBuff.lua | 25 +++++++++++++++++++++++-- src/adv/AdvPassive.lua | 21 +++++++++++++++++++-- src/adv/AdvPlayer.lua | 24 ++++++++++++------------ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/adv/AdvBuff.lua b/src/adv/AdvBuff.lua index 680419e..fb026d4 100644 --- a/src/adv/AdvBuff.lua +++ b/src/adv/AdvBuff.lua @@ -434,6 +434,9 @@ function Buff:initNew(release, data) if self.buffData.effectTime > 0 then self.count = self.buffData.effectTime end + if self.buffData.mapLock == 1 then + self.mapId = self.owner.battle.adv:getCurMap().mapId + end end function Buff:createAfter() @@ -456,6 +459,9 @@ function Buff:initByDB(data) if data.count then self.count = data.count end + if data.mapId then + self.mapId = data.mapId + end self.layer = data.layer or 1 if self._initDB then self:_initDB(data) @@ -464,7 +470,7 @@ end function Buff:afterRound() - if self.isDel or self.owner.isDead then return end + if self.owner.isDead or self:isHide() then return end -- keepTerm 检查 if not self:checkKeep() then @@ -533,7 +539,7 @@ function Buff:checkKeep() end checkFunc[5] = function(_, buffId) local buff = self.owner:getBuffById(buffId) - if buff and not buff.isDel then + if buff then return true end return false @@ -574,6 +580,18 @@ function Buff:effect() return self:_effectValue() end end + +-- 在当前阶段不可用 小透明 < 不会回合遍历 不会查找遍历 可以删除遍历 可以下层遍历 > +function Buff:isHide() + if self.isDel then + return false + end + if self.buffData.mapLock == 1 and self.mapId and self.owner.battle.adv:getCurMap().mapId ~= self.mapId then + return false + end + return true +end + --删除buff 时调用 function Buff:endBuff() if self._endBuff then @@ -678,6 +696,9 @@ function Buff:getDB() if self.count ~= -1 then db.count = self.count end + if self.mapId then + db.mapId = self.mapId + end db.layer = self.layer if self.buffData.keepTerm:toArray(true, "=")[1] == 1 then db.releId = self.releaseId diff --git a/src/adv/AdvPassive.lua b/src/adv/AdvPassive.lua index 158faa4..7f0ee40 100644 --- a/src/adv/AdvPassive.lua +++ b/src/adv/AdvPassive.lua @@ -265,6 +265,9 @@ function Passive:ctor(owner, data) self.round = data.round or 0 --触发剩余回合数 self.count = data.count or self.passiveData.count --触发剩余次数 self.delay = data.delay or self.passiveData.delayRound --触发延迟回合数 + if self.passiveData.mapLock == 1 and not self.mapId then + self.mapId = self.owner.battle.adv:getCurMap().mapId + end self.effects = self.passiveData.effect:toTableArray(true) self.filters = {} @@ -331,7 +334,7 @@ function Passive:effect(triggerPms) end function Passive:afterRound() - if self.isDel or self.owner.isDead or self.owner.lock then return end + if self.isDel or self.owner.isDead or self.owner.lock or self:isHide() then return end if self.round > 0 then --回合触发的 self.round = self.round - 1 end @@ -349,9 +352,20 @@ function Passive:afterLayer() end end +-- 在当前阶段不可用 小透明 < 不会回合遍历 不会查找遍历 可以删除遍历 可以下层遍历 > +function Passive:isHide() + if self.isDel then + return false + end + if self.passiveData.mapLock == 1 and self.mapId and self.owner.battle.adv:getCurMap().mapId ~= self.mapId then + return false + end + return true +end + -- 可以触发 function Passive:canTrigger( ) - return self.count > 0 and self.delay <= 0 + return self.count > 0 and self.delay <= 0 and not self:isHide() end function Passive:trigger(condType, params) --触发检查 @@ -393,6 +407,9 @@ function Passive:getDB() db.round = self.round db.count = self.count db.delay = self.delay + if self.mapId then + db.mapId = self.mapId + end return db end diff --git a/src/adv/AdvPlayer.lua b/src/adv/AdvPlayer.lua index 804c11a..2f87d5b 100644 --- a/src/adv/AdvPlayer.lua +++ b/src/adv/AdvPlayer.lua @@ -124,7 +124,7 @@ end function BaseObject:getDisablePassiveCount() local count for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff:getType() == Buff.DISABLE_BUFF then + if not buff:isHide() and buff:getType() == Buff.DISABLE_BUFF then if buff:effect() == 0 then return 0 end @@ -138,7 +138,7 @@ function BaseObject:addBuff(buffId, releaser) local buffData = csvdb["adv_map_buffCsv"][buffId] if not buffData then return end for _, buff in ipairs(self.buffs) do - if not buff.isDel and (buff:getType() == Buff.CLEAR_BUFF or buff:getType() == Buff.IMMNUE_BUFF) then + if not buff:isHide() and (buff:getType() == Buff.CLEAR_BUFF or buff:getType() == Buff.IMMNUE_BUFF) then if buff:canEffect(buffId) then buff:effect() return @@ -166,7 +166,7 @@ end function BaseObject:getBuffById(bId) for idx, buff in ipairs(self.buffs) do - if buff.id == bId then + if buff.id == bId and not buff:isHide() then return buff end end @@ -196,7 +196,7 @@ end function BaseObject:hadBuff(bType) for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff:getType() == bType then + if not buff:isHide() and buff:getType() == bType then return buff end end @@ -204,7 +204,7 @@ end function BaseObject:hadBuffById(bId) for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff.id == bId then + if not buff:isHide() and buff.id == bId then return buff end end @@ -218,7 +218,7 @@ end function BaseObject:getCommonBuffEffect(bType, otherCond) local effect, count = {[0] = 0, [1] = 0}, 0 for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff:getType() == bType then + if not buff:isHide() and buff:getType() == bType then local cType, value, cond = buff:effect() if cType and (not otherCond or otherCond == cond) then effect[cType] = effect[cType] + value @@ -233,7 +233,7 @@ end function BaseObject:getBackHurtBuff() local effect = {[0] = 0, [1] = 0} for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff:getType() == Buff.BACK_HURT then + if not buff:isHide() and buff:getType() == Buff.BACK_HURT then local cType, value = buff:effect() -- aType 0 全部 1 普通攻击 if cType then effect[cType] = effect[cType] + value @@ -268,7 +268,7 @@ function BaseObject:getBuffEffectChange(classify) end local effect = 0 for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff:getType() == Buff.Buff_EFFECT_CHANGE then + if not buff:isHide() and buff:getType() == Buff.Buff_EFFECT_CHANGE then local cType, value = buff:effect() if cType and had[cType] then effect = effect + value @@ -286,7 +286,7 @@ function BaseObject:getAttrBuffChange(attr) } local effect, count = {[0] = 0, [1] = 0}, 0 for _, buff in ipairs(self.buffs) do - if not buff.isDel and AttrBuff[buff:getType()] then + if not buff:isHide() and AttrBuff[buff:getType()] then local cType, value, attrName = buff:effect() if cType and attr == attrName then effect[cType] = effect[cType] + value @@ -310,7 +310,7 @@ end function BaseObject:reSetHpMax() self.hpMax = self._hpMax for _, buff in ipairs(self.buffs) do - if not buff.isDel and buff:getType() == Buff.HP_MAX_CHANGE then + if not buff:isHide() and buff:getType() == Buff.HP_MAX_CHANGE then local cv = buff:effect() if cv then self.hpMax = self.hpMax + cv @@ -665,7 +665,7 @@ end --战斗结束了扣战斗buff次数 function Player:effectBattleBuff() for _, buff in ipairs(self.buffs) do - if not buff.isDel and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then + if not buff:isHide() and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then buff:effect() end end @@ -699,7 +699,7 @@ end function Player:attrChangeCondBuffCheck(etype, cond) local effect = {} for _, buff in ipairs(self.buffs) do - if not buff.isDel and (buff:getType() == Buff.ATTR_CHANGE_COND) then + if not buff:isHide() and (buff:getType() == Buff.ATTR_CHANGE_COND) then local _et, _attr, _co = buff:getEffectBy() if etype == _et and (not _co or _co == cond) then effect[_attr] = 1 -- libgit2 0.21.2