46fac6f1
zhouahaihai
酱料
|
1
2
3
4
5
|
local Buff = class("Buff")
Buff.HP_CHANGE = 1 --生命变化(每回合生效)
Buff.HP_MAX_CHANGE = 2 --生命上限变化(状态)
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
6
|
Buff.ATTR_CHANGE = 3 --属性变化(状态)
|
46fac6f1
zhouahaihai
酱料
|
7
8
9
10
11
12
13
14
15
16
17
|
Buff.IMMNUE_ATK = 4 -- 免疫普通攻击
Buff.BACK_HURT = 5 -- 伤害反弹
Buff.HURT_CHANGE = 6 -- 伤害变化
Buff.INJURED_CHANGE = 7 -- 受伤变化
Buff.HURT_TRANSFER = 8 -- 侍宠(转移自己受到的伤害)
Buff.HURT_ABSORB = 9 -- 舍身(吸收他人受到的伤害)
Buff.CANT_BACK_ATK = 10 -- 无法反击
Buff.IMMNUE_BUFF = 11 -- 免疫buff
Buff.CLEAR_BUFF = 12 -- 清除buff
Buff.CANT_SKILL = 13 -- 禁止技能
Buff.OPEN_BLOCK = 14 -- 翻开格子(每回合)
|
040c6558
suhongyang
体力改为mp
|
18
|
Buff.POWER_CHANGE = 15 -- MP变化(每回合)
|
46fac6f1
zhouahaihai
酱料
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
--角色一些属性的变化
local function commonAttr(_Buff, attrName)
_Buff._init = function(self, data) --初始化变化值
self.owner:reSetAttr(attrName)
end
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
_Buff._endBuff = function(self, data)
self.owner:reSetAttr(attrName)
end
end
local BuffFactory = {
[Buff.HP_CHANGE] = function(_Buff)
_Buff._init = function(self, data) --初始化变化值
self._changeV = 0
if self.buffData.effectValue1 == 0 then --固定值
self._changeV = self.buffData.effectValue2
elseif self.buffData.effectValue1 == 1 then
local baseOwner = self.buffData.effectValue4 == 1 and self.owner or self.release
local attrs = {[0] = "hp", [1] = "hpMax", [2] = "atk"}
|
4ae223df
zhouahaihai
Buff bug
|
42
|
self._changeV = baseOwner[attrs[self.buffData.effectValue3]] * self.buffData.effectValue2 / 100
|
46fac6f1
zhouahaihai
酱料
|
43
44
45
46
47
48
49
50
|
end
if self._changeV < 0 then
self._changeV = -self.release:getHurtValue(-self._changeV)
end
end
_Buff._initDB = function(self, data)
self._changeV = data.cv
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
51
52
53
54
55
56
|
_Buff._afterRound = function(self)
local value = self:effect()
if value > 0 then
self.owner:recover(value, self.release)
elseif value < 0 then
self.owner:hurt(-value, self.release, {hurtType = 2})
|
46fac6f1
zhouahaihai
酱料
|
57
58
|
end
end
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
59
60
61
62
63
64
65
66
|
_Buff._afterTurn = function(self)
local value = self:effect()
if value > 0 then
self.owner:recover(value, self.release)
elseif value < 0 then
self.owner:hurt(-value, self.release, {hurtType = 2})
end
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
67
68
69
|
_Buff._effectValue = function(self)
return self._changeV
end
|
46fac6f1
zhouahaihai
酱料
|
70
71
72
73
74
75
76
77
78
79
80
81
82
|
_Buff._getDB = function(self)
return {cv = self._changeV}
end
end,
[Buff.HP_MAX_CHANGE] = function(_Buff)
_Buff._init = function(self, data) --初始化变化值
self._changeV = 0
if self.buffData.effectValue1 == 0 then --固定值
self._changeV = self.buffData.effectValue2
elseif self.buffData.effectValue1 == 1 then
local baseOwner = self.buffData.effectValue4 == 1 and self.owner or self.release
local attrs = {[0] = "hp", [1] = "hpMax", [2] = "atk"}
|
4ae223df
zhouahaihai
Buff bug
|
83
|
self._changeV = baseOwner[attrs[self.buffData.effectValue3]] * self.buffData.effectValue2 / 100
|
46fac6f1
zhouahaihai
酱料
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
end
local old = self.owner.hpMax
self.owner.hpMax = math.max(1, self.owner.hpMax + self._changeV)
self._changeV = self.owner.hpMax - old
if self._changeV > 0 then
self.owner:recover(self._changeV, self.release)
elseif self._changeV < 0 then
self.owner:hurt(self.release:getHurtValue(-self._changeV), self.release, {hurtType = 2})
self.owner.hp = math.min(self.owner.hpMax, self.owner.hp)
end
end
_Buff._initDB = function(self, data)
self._changeV = data.cv
end
_Buff._endBuff = function(self, data)
if self._changeV then
self.owner.hpMax = math.max(1, self.owner.hpMax - self._changeV)
self.owner.hp = math.min(self.owner.hpMax, self.owner.hp)
end
end
_Buff._getDB = function(self)
return {cv = self._changeV}
end
end,
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
108
|
[Buff.ATTR_CHANGE] = function(_Buff)
|
d78bc768
suhongyang
Fix bug
|
109
|
local attrName = AttsEnumEx[_Buff.buffData.effectValue3]
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
110
|
commonAttr(_Buff, attrName)
|
46fac6f1
zhouahaihai
酱料
|
111
|
end,
|
46fac6f1
zhouahaihai
酱料
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
[Buff.BACK_HURT] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2, self.buffData.effectValue3
end
end,
[Buff.HURT_CHANGE] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.INJURED_CHANGE] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.HURT_TRANSFER] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.HURT_ABSORB] = function(_Buff)
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
end
end,
[Buff.IMMNUE_BUFF] = function(_Buff)
_Buff._init = function(self, data)
self.count = self.buffData.effectValue3
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
146
147
148
149
150
|
_Buff._canEffect = function(self, buffId, buffGroup)
local cType, aim = self.buffData.effectValue1, self.buffData.effectValue2
if (cType == 0 and buffId == aim) or (cType == 1 and buffGroup == aim) then
return true
end
|
46fac6f1
zhouahaihai
酱料
|
151
152
153
154
155
156
|
end
end,
[Buff.CLEAR_BUFF] = function(_Buff)
_Buff._init = function(self, data)
self.count = self.buffData.effectValue3
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
157
|
for _, buff in ipairs(self.buffs) do -- 挂上就清除一下子
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
158
|
if not buff.isDel and self:canEffect(buff.id, buff:getGroup()) then
|
46fac6f1
zhouahaihai
酱料
|
159
|
buff.isDel = true
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
160
|
self:effect()
|
46fac6f1
zhouahaihai
酱料
|
161
|
end
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
162
|
end
|
46fac6f1
zhouahaihai
酱料
|
163
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
164
165
166
167
168
|
_Buff._canEffect = function(self, buffId, buffGroup)
local cType, aim = self.buffData.effectValue1, self.buffData.effectValue2
if (cType == 0 and buffId == aim) or (cType == 1 and buffGroup == aim) then
return true
end
|
46fac6f1
zhouahaihai
酱料
|
169
170
171
172
|
end
end,
[Buff.OPEN_BLOCK] = function(_Buff)
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
173
174
175
176
|
_Buff._afterRound = function(self)
local roomNum = self:effect()
self.owner.battle.adv:openBlockRand(roomNum)
end
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
177
178
179
180
|
_Buff._afterTurn = function(self)
local roomNum = self:effect()
self.owner.battle.adv:openBlockRand(roomNum)
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
181
182
|
_Buff._effectValue = function(self)
return self.buffData.effectValue1
|
46fac6f1
zhouahaihai
酱料
|
183
184
185
186
|
end
end,
[Buff.POWER_CHANGE] = function(_Buff)
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
187
188
189
|
--cType 0 or nil 值 1 百分比
_Buff._afterRound = function(self)
local value, cType = self:effect()
|
7e45c419
suhongyang
现有buff补全战斗内生效逻辑
|
190
191
192
193
|
self.owner.battle.adv:changePower(value, cType)
end
_Buff._afterTurn = function(self)
local value, cType = self:effect()
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
194
195
196
197
|
self.owner.battle.adv:changePower(value, cType)
end
_Buff._effectValue = function(self)
return self.buffData.effectValue1, self.buffData.effectValue2
|
46fac6f1
zhouahaihai
酱料
|
198
199
200
201
|
end
end
}
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
202
203
204
205
206
|
function Buff:ctor(owner, id)
self.owner = owner
self.id = id
self.buffData = csvdb["adv_buffCsv"][self.id]
self.isDel = false
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
207
208
209
210
211
212
213
214
215
216
|
self.roundSpace = 0 --生效间隔
self.turnSpace = 0 --生效间隔
self.round = 0 --剩余的回合
self.turn = 0 --剩余战斗内回合
self.count = -1 -- 可生效的次数 -1 无次数限制
if BuffFactory[self.buffData.type] then
BuffFactory[self.buffData.type](self)
end
end
|
46fac6f1
zhouahaihai
酱料
|
217
218
219
220
221
222
223
224
225
226
227
228
229
|
function Buff.create(owner, release, data)
local buff = Buff.new(owner, data.id)
buff:initNew(release, data)
return buff
end
function Buff.load(owner, data)
local buff = Buff.new(owner, data.id)
buff:initByDB(data)
return buff
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
230
231
232
233
234
235
236
237
238
|
function Buff:initNew(release, data)
self.release = release
self.round = self.buffData.round
self.turn = self.buffData.turn
if self.buffData.effectTime > 0 then
self.count = self.buffData.effectTime
end
if self._init then
self:_init(data)
|
46fac6f1
zhouahaihai
酱料
|
239
240
241
242
243
244
245
246
247
248
249
|
end
end
function Buff:initByDB(data)
if data.rele then
if data.rele == 0 then
self.release = self.owner.battle.player
else
self.release = self.owner.battle:getEnemyById(data.rele)
end
end
|
821f2b60
suhongyang
冒险战斗完善,增加battlebe...
|
250
|
self.round = data.round
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
251
|
self.roundSpace = data.roundSp -- 可以优化为0的时候不记录
|
46fac6f1
zhouahaihai
酱料
|
252
253
254
255
256
257
258
259
260
|
if data.count then
self.count = data.count
end
if self._initDB then
self:_initDB(data)
end
end
|
0d405dc3
suhongyang
Buff生命周期调整,被动加buf...
|
261
262
263
264
|
function Buff:battleEnd()
if self.buffData.turn ~= 0 then
self.isDel = true -- turn类型buff战斗结束后移除
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
265
266
267
|
end
function Buff:beforeTurn()
|
5b3f595a
suhongyang
区分round型和turn型buff
|
268
|
if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
269
270
271
272
273
274
275
276
277
|
if self.turnSpace > 0 then
return
end
if self._beforeTurn then
self:_beforeTurn()
end
end
function Buff:afterTurn()
|
5b3f595a
suhongyang
区分round型和turn型buff
|
278
|
if self.isDel or self.owner.isDead or self.buffData.turn == 0 then return end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
|
if self.turnSpace > 0 then
self.turnSpace = self.turnSpace - 1
self:decTurn()
return
end
if self._afterTurn then
self:_afterTurn()
end
if self.buffData.turnTime > 0 then
self.turnSpace = self.buffData.turnTime
end
self:decTurn()
end
function Buff:decTurn()
if self.buffData.turn == 0 then
return
end
self.turn = self.turn - 1
if self.turn <= 0 then
self.isDel = true
|
46fac6f1
zhouahaihai
酱料
|
300
301
302
303
|
end
end
function Buff:afterRound()
|
5b3f595a
suhongyang
区分round型和turn型buff
|
304
|
if self.isDel or self.owner.isDead or self.buffData.round == 0 then return end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
305
|
if self.roundSpace > 0 then
|
8d8bf91a
suhongyang
fix bug
|
306
|
self.roundSpace = self.roundSpace - 1
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
307
308
309
310
311
312
|
self:decRound()
return
end
if self._afterRound then
self:_afterRound()
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
313
|
if self.buffData.roundTime > 0 then
|
8d8bf91a
suhongyang
fix bug
|
314
|
self.roundSpace = self.buffData.roundTime
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
315
316
317
|
end
self:decRound()
end
|
46fac6f1
zhouahaihai
酱料
|
318
|
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
319
320
321
322
323
324
325
326
327
328
329
330
331
|
function Buff:decRound()
if self.buffData.round == 0 then
return
end
self.round = self.round - 1
if self.round <= 0 then
self.isDel = true
end
end
function Buff:canEffect(...)
if not self._canEffect then
return true
|
46fac6f1
zhouahaihai
酱料
|
332
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
333
|
return self:_canEffect(...)
|
46fac6f1
zhouahaihai
酱料
|
334
335
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
336
|
function Buff:effect()
|
46fac6f1
zhouahaihai
酱料
|
337
338
339
|
if self._effectValue then
return self:_effectValue()
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
340
|
self:decCount()
|
46fac6f1
zhouahaihai
酱料
|
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
end
--删除buff 时调用
function Buff:endBuff()
if self._endBuff then
self:_endBuff()
end
end
function Buff:getType()
return self.buffData.type
end
function Buff:decCount()
if self.count == -1 then return end
self.count = self.count - 1
if self.count <= 0 then
self.isDel = true
end
end
function Buff:getGroup()
return self.buffData.group
end
function Buff:getDB()
local db = {}
if self._getDB then
db = self:_getDB()
end
db.id = self.id
if self.release and not self.release.isDead then
db.rele = self.release.id or 0 --释放者的id (0 为玩家) (不存在 则释放者不存在或者已经死亡)
end
|
821f2b60
suhongyang
冒险战斗完善,增加battlebe...
|
374
375
|
if self.buffData.round ~= 0 then
db.round = self.round
|
46fac6f1
zhouahaihai
酱料
|
376
|
end
|
7c55db1f
suhongyang
Buff逻辑完善,buff生效次数...
|
377
|
db.roundSp = self.roundSpace
|
46fac6f1
zhouahaihai
酱料
|
378
379
380
381
382
383
384
|
if self.count ~= -1 then
db.count = self.count
end
return db
end
return Buff
|