diff --git a/src/adv/AdvPassive.lua b/src/adv/AdvPassive.lua index 1f2dcaf..649d340 100644 --- a/src/adv/AdvPassive.lua +++ b/src/adv/AdvPassive.lua @@ -1,6 +1,11 @@ local Filter = class("Filter") Filter.HP_UP_WITH_EQUAL = 1 -- 血量>=value% +Filter.HP_UP = 2 -- 血量>value% +Filter.HP_LOW_WITH_EQUAL = 3 -- 血量<=value% +Filter.HP_LOW = 4 -- 血量= self.value * target.hpMax / 100 end end +FilterFactory[Filter.HP_UP] = function (_Filter) + _Filter._execute = function (self, target) + return target.hp > self.value * target.hpMax / 100 + end +end +FilterFactory[Filter.HP_LOW_WITH_EQUAL] = function (_Filter) + _Filter._execute = function (self, target) + return target.hp <= self.value * target.hpMax / 100 + end +end +FilterFactory[Filter.HP_LOW] = function (_Filter) + _Filter._execute = function (self, target) + return target.hp < self.value * target.hpMax / 100 + end +end +FilterFactory[Filter.BUFF_BY_TYPE] = function (_Filter) + _Filter._execute = function (self, target) + return target:hadBuff(self.value) + end +end +FilterFactory[Filter.BUFF_BY_ID] = function (_Filter) + _Filter._execute = function (self, target) + return target:hadBuffById(self.value) + end +end function Filter:ctor(params) self.owner = params.owner diff --git a/src/adv/AdvPlayer.lua b/src/adv/AdvPlayer.lua index a6b2180..7fec597 100644 --- a/src/adv/AdvPlayer.lua +++ b/src/adv/AdvPlayer.lua @@ -105,6 +105,14 @@ function BaseObject:hadBuff(bType) end end +function BaseObject:hadBuffById(bId) + for _, buff in ipairs(self.buffs) do + if not buff.isDel and buff.id == bId then + return true + end + end +end + -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 function BaseObject:getCommonBuffEffect(bType) local effect, count = {[0] = 0, [1] = 0}, 0 -- libgit2 0.21.2