Commit 1cb78a242303bedc8bccb94a7bceb3f118011640
1 parent
c8ade4f6
passive的筛选
Showing
2 changed files
with
38 additions
and
0 deletions
Show diff stats
src/adv/AdvPassive.lua
1 | local Filter = class("Filter") | 1 | local Filter = class("Filter") |
2 | 2 | ||
3 | Filter.HP_UP_WITH_EQUAL = 1 -- 血量>=value% | 3 | Filter.HP_UP_WITH_EQUAL = 1 -- 血量>=value% |
4 | +Filter.HP_UP = 2 -- 血量>value% | ||
5 | +Filter.HP_LOW_WITH_EQUAL = 3 -- 血量<=value% | ||
6 | +Filter.HP_LOW = 4 -- 血量<value% | ||
7 | +Filter.BUFF_BY_TYPE = 5 -- 指定类型buff | ||
8 | +Filter.BUFF_BY_ID = 6 -- 指定id的buff | ||
4 | 9 | ||
5 | local FilterFactory = {} | 10 | local FilterFactory = {} |
6 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) | 11 | FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) |
@@ -8,6 +13,31 @@ FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) | @@ -8,6 +13,31 @@ FilterFactory[Filter.HP_UP_WITH_EQUAL] = function (_Filter) | ||
8 | return target.hp >= self.value * target.hpMax / 100 | 13 | return target.hp >= self.value * target.hpMax / 100 |
9 | end | 14 | end |
10 | end | 15 | end |
16 | +FilterFactory[Filter.HP_UP] = function (_Filter) | ||
17 | + _Filter._execute = function (self, target) | ||
18 | + return target.hp > self.value * target.hpMax / 100 | ||
19 | + end | ||
20 | +end | ||
21 | +FilterFactory[Filter.HP_LOW_WITH_EQUAL] = function (_Filter) | ||
22 | + _Filter._execute = function (self, target) | ||
23 | + return target.hp <= self.value * target.hpMax / 100 | ||
24 | + end | ||
25 | +end | ||
26 | +FilterFactory[Filter.HP_LOW] = function (_Filter) | ||
27 | + _Filter._execute = function (self, target) | ||
28 | + return target.hp < self.value * target.hpMax / 100 | ||
29 | + end | ||
30 | +end | ||
31 | +FilterFactory[Filter.BUFF_BY_TYPE] = function (_Filter) | ||
32 | + _Filter._execute = function (self, target) | ||
33 | + return target:hadBuff(self.value) | ||
34 | + end | ||
35 | +end | ||
36 | +FilterFactory[Filter.BUFF_BY_ID] = function (_Filter) | ||
37 | + _Filter._execute = function (self, target) | ||
38 | + return target:hadBuffById(self.value) | ||
39 | + end | ||
40 | +end | ||
11 | 41 | ||
12 | function Filter:ctor(params) | 42 | function Filter:ctor(params) |
13 | self.owner = params.owner | 43 | self.owner = params.owner |
src/adv/AdvPlayer.lua
@@ -105,6 +105,14 @@ function BaseObject:hadBuff(bType) | @@ -105,6 +105,14 @@ function BaseObject:hadBuff(bType) | ||
105 | end | 105 | end |
106 | end | 106 | end |
107 | 107 | ||
108 | +function BaseObject:hadBuffById(bId) | ||
109 | + for _, buff in ipairs(self.buffs) do | ||
110 | + if not buff.isDel and buff.id == bId then | ||
111 | + return true | ||
112 | + end | ||
113 | + end | ||
114 | +end | ||
115 | + | ||
108 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 | 116 | -- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类 |
109 | function BaseObject:getCommonBuffEffect(bType) | 117 | function BaseObject:getCommonBuffEffect(bType) |
110 | local effect, count = {[0] = 0, [1] = 0}, 0 | 118 | local effect, count = {[0] = 0, [1] = 0}, 0 |