AdvPlayer.lua
20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
-- 角色
local Buff = require "adv.AdvBuff"
local Skill = require "adv.AdvSkill"
local Passive = require "adv.AdvPassive"
local BaseObject = class("BaseObject")
function BaseObject:ctor(battle)
self.battle = battle
self.hpMax = 0
self.hp = 0
self.atk = 0
self.def = 0
self.aType = 0 --攻击类型
self.lock = nil
self.passives = {} --固有技能
self.buffs = {} --buff
self.skillOrder = {} --战斗内技能序列
self.isDead = false
end
--初始化角色
function BaseObject:initData(data)
self.hpMax = data.hpMax or data.hp
self.hp = data.hp
--可变化的值
self.atk = data.atk
self.miss = data.miss
self.hit = data.hit
self.def = data.def
--基础值记录
self._atk = data._atk or self.atk
self._miss = data._miss or self.miss
self._hit = data._hit or self.hit
self._def = data._def or self.def
self._hpMax = data._hpMax or self.hpMax
end
-- 角色初始化完以后才是 技能和被动技能 方便初始化 buff 的 释放对象
function BaseObject:initAfter(data)
for _, passive in ipairs(data.passives or {}) do
table.insert(self.passives, Passive.new(self, passive))
end
for _, buff in ipairs(data.buffs or {}) do
table.insert(self.buffs, Buff.load(self, buff))
end
end
function BaseObject:reset(data)
self.passives = {}
self.buffs = {}
self:initData(data)
self:initAfter(data)
end
function BaseObject:afterRound()
for _, passive in ipairs(self.passives) do
passive:afterRound(self)
end
for _, buff in ipairs(self.buffs) do
buff:afterRound()
end
end
function BaseObject:clearRound()
for i = #self.passives, 1, -1 do
if self.passives[i].isDel then
self.passives[i]:endPassive()
table.remove(self.passives, i)
end
end
for i = #self.buffs, 1, -1 do
if self.buffs[i].isDel then
local buff = self.buffs[i]
table.remove(self.buffs, i)
buff:endBuff()
if self.attrChangeCondBuffCheck then
self:attrChangeCondBuffCheck(2, buff.id)
end
end
end
end
function BaseObject:clear()
self.buffs = {}
self.passives = {}
end
function BaseObject:battleBegin()
for _, passive in ipairs(self.passives) do
passive:battleBegin()
end
end
function BaseObject:battleEnd()
for _, buff in ipairs(self.buffs) do
buff:battleEnd()
end
end
function BaseObject:addPassive(params)
local skillId = params.id
local skillData = csvdb["adv_map_passiveCsv"][skillId]
if not skillData then return end
local level = params.level or 1
if not skillData[level] then return end
table.insert(self.passives, Passive.new(self, { id = skillId, level = level }))
end
function BaseObject:getPassiveIdx(passive)
for idx, passive_ in ipairs(self.passives) do
if passive_ == passive then
return idx
end
end
end
function BaseObject:getDisablePassiveCount()
local count = 0
for _, buff in ipairs(self.buffs) do
if not buff.isDel and buff:getType() == Buff.DISABLE_BUFF then
count = count + buff:effect()
end
end
return count
end
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 buff:canEffect(buffId) then
buff:effect()
return
end
end
end
local oldBuff = self:getBuffById(buffId)
if oldBuff then
if not oldBuff:checkKeep() then return end
oldBuff:overlay(releaser, {}) -- 叠加
else
-- 不能保持的buff 也加不上去
if not Buff.checkKeep({
owner = self,
buffData = buffData,
releaseId = releaser and releaser.monsterId or nil
}) then return end
local buff = Buff.create(self, releaser, {id = buffId})
table.insert(self.buffs, buff)
buff:createAfter()
end
self:triggerPassive(Passive.GET_BUFF, {buffId = buffId})
return true
end
function BaseObject:getBuffById(bId)
for idx, buff in ipairs(self.buffs) do
if buff.id == bId then
return buff
end
end
end
function BaseObject:delBuffById(bId)
for idx, buff in ipairs(self.buffs) do
if buff.id == bId then
table.remove(self.buffs, idx)
buff:endBuff()
if self.attrChangeCondBuffCheck then
self:attrChangeCondBuffCheck(2, bId)
end
return buff
end
end
end
function BaseObject:delPassiveById(pId)
for idx, passive in ipairs(self.passives) do
if passive.id == pId then
table.remove(self.passives, idx)
return passive
end
end
end
function BaseObject:hadBuff(bType)
for _, buff in ipairs(self.buffs) do
if not buff.isDel and buff:getType() == bType then
return buff
end
end
end
function BaseObject:hadBuffById(bId)
for _, buff in ipairs(self.buffs) do
if not buff.isDel and buff.id == bId then
return buff
end
end
end
-- 通用的buff 效果汇总 -- 0 固定 1百分比 两种分类
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
local cType, value, cond = buff:effect()
if cType and (not otherCond or otherCond == cond) then
effect[cType] = effect[cType] + value
count = count + 1
end
end
end
effect[1] = effect[1] / 100
return effect, count --效果 和生效的buff 个数
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
local cType, value = buff:effect() -- aType 0 全部 1 普通攻击
if cType then
effect[cType] = effect[cType] + value
end
end
end
return effect
end
--释放者伤害变化
function BaseObject:getHurtChange()
local change = self:getCommonBuffEffect(Buff.HURT_CHANGE)
return change
end
--受伤者受伤变化
function BaseObject:getInjuredChange()
local change = self:getCommonBuffEffect(Buff.INJURED_CHANGE)
return change
end
-- 奖励道具变化
function BaseObject:getRewardChange(itemId)
local change = self:getCommonBuffEffect(Buff.ITEM_GET_UP, itemId)
return change
end
-- buff 增益 检疫
function BaseObject:getBuffEffectChange(classify)
local classifys = classify:toArray(true, " ")
local had = {}
for _, one in pairs(classifys) do
had[one] = 1
end
local effect = 0
for _, buff in ipairs(self.buffs) do
if not buff.isDel and buff:getType() == Buff_EFFECT_CHANGE then
local cType, value = buff:effect()
if cType and had[cType] then
effect = effect + value
end
end
end
effect = effect / 100
return effect
end
function BaseObject:getAttrBuffChange(attr)
local AttrBuff = {
[Buff.ATTR_CHANGE] = 1,
[Buff.ATTR_CHANGE_COND] = 1,
}
local effect, count = {[0] = 0, [1] = 0}, 0
for _, buff in ipairs(self.buffs) do
if not buff.isDel and AttrBuff[buff:getType()] then
local cType, value, attrName = buff:effect()
if cType and attr == attrName then
effect[cType] = effect[cType] + value
count = count + 1
end
end
end
effect[1] = effect[1] / 100
return effect, count
end
--重新计算属性
function BaseObject:reSetAttr(field)
local old = self[field]
self[field] = self["_" .. field] --重置一下
local effect = self:getAttrBuffChange(field)
self[field] = math.ceil((self[field] + effect[0]) * (1 + effect[1]))
local delta = self[field] - old
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
local cv = buff:effect()
if cv then
self.hpMax = self.hpMax + cv
end
end
end
local effect = self:getAttrBuffChange("hp")
self.hpMax = (self.hpMax + effect[0]) * (1 + effect[1])
self.hpMax = math.ceil(math.max(1, self.hpMax))
self.hp = math.min(self.hpMax, self.hp)
end
--计算打出伤害加成后的值
function BaseObject:getHurtValue(value)
value = value or self.atk
local hurtChange = self:getHurtChange()
return math.max(0, (value + hurtChange[0]) * (1 + hurtChange[1]))
end
--计算自己伤害减免后的值
function BaseObject:getInjuredValue(value)
local injuredChange = self:getInjuredChange()
return math.max(0, (value - self.def + injuredChange[0]) * (1 + injuredChange[1]))
end
--最终伤害 = [ (敌方攻击 - 己方防御) * (1+伤害增加百分比-伤害减少百分比)*(1+受伤增加百分比-受伤减少百分比)+(伤害增加固定值-伤害增加固定值+受伤增加固定值-受伤增加固定值)]*(1+侍宠百分比)-侍宠固定值
-- params -- hurtType 1 普攻伤害 2 buff伤害 3 反弹伤害 4 真实伤害 5 客户端发回来的伤害 --直接作用 6 buff伤害(真实)
--进入这个方法之前计算好释放者加成的伤害
function BaseObject:hurt(value, releaser, params)
params = params or {}
if params.hurtType and (params.hurtType == 2 or params.hurtType == 6) then
self:triggerPassive(Passive.SELF_HURT, {trigger = releaser, buffId = params.buffId})
for _, team in ipairs(self:getTeam(1, true)) do
team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser, buffId = params.buffId})
end
end
if params.hurtType ~= 5 and params.hurtType ~= 6 then
if not params.hurtType or params.hurtType ~= 4 then
value = self:getInjuredValue(value) --减伤计算
end
if value == 0 then return end
-- 舍身和恃宠
local team = self:getTeam(1)
local transfer = {}
local absorb = {}
for _, one in ipairs(team) do
local change1, count1 = one:getCommonBuffEffect(Buff.INJURED_CHANGE)
local change2, count2 = one:getCommonBuffEffect(Buff.HURT_ABSORB)
if count1 > 0 then
table.insert(transfer, {one, change1, count1})
end
if count2 > 0 then
table.insert(absorb, {one, change2, count2})
end
end
if #absorb == 1 then --舍身优先级高 --舍身生效
if absorb[1][1] ~= self then --舍身的人不是自己才有效
local absorbV = (value - absorb[1][2][0]) * absorb[1][2][1] + absorb[1][2][0] --固定值先生效
value = value - absorbV
absorb[1][1]:hurt(absorbV, releaser, params)
end
else
if #transfer == 1 and transfer[1][1] == self and #team > 1 then --侍宠 生效
local transferValue = (value - transfer[1][2][0])* transfer[1][2][1] + transfer[1][2][0] --固定值先生效
value = value - transferValue
local oneValue = transferValue / (#team - 1)
for _, one in ipairs(team) do
if one ~= self then
one:hurt(oneValue, releaser, params)
end
end
end
end
end
value = math.max(0, math.ceil(value))
if value == 0 then return end
-- 反弹伤害
if params.hurtType ~= 3 and params.hurtType ~= 5 and releaser and not releaser.isDead then
local backEffect = self:getBackHurtBuff()
local backValue = math.max(0, value * backEffect[1] + backEffect[0])
releaser:hurt(backValue, releaser, {hurtType = 3})
end
--受伤了~
if self:is("Player") and params.hurtType ~= 5 then
self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = -value})
end
if params.hurtType ~= 5 then -- 非客户端发回的伤害 返回更新地块
if self.roomId and self.blockId then
self.battle.adv:backBlockChange(self.roomId, self.blockId)
end
end
self.hp = math.max(0, self.hp - value)
if self.hp == 0 then
self:triggerPassive(Passive.SELF_DEAD)
for _, team in ipairs(self:getTeam(1, true)) do
team:triggerPassive(Passive.TEAM_DEAD)
end
if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then
self.battle.adv:checkAchievement(self.battle.adv.AchievType.KillByBuff, 1, params.buffId)
end
self.isDead = true
end
self:triggerPassive(Passive.HURT_PERCENT_SELF, {value = value / self.hpMax})
for _, team in ipairs(self:getTeam(1, true)) do
team:triggerPassive(Passive.HURT_PERCENT_TEAM, {value = value / self.hpMax})
end
end
--恢复
function BaseObject:recover(value, releaser, params)
params = params or {}
value = math.max(0, math.ceil(value))
self.hp = math.min(self.hpMax, self.hp + value)
self.battle.adv:pushBackEvent(AdvBackEventType.HpChange, {change = value})
end
function BaseObject:addSpecialSkill(skillId, skillLevel, target)
local skillData = {id = skillId, level = skillLevel, target = target}
table.insert(self.skillOrder, skillData)
end
function BaseObject:releaseSkill(skillId, target)
if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物
local skill = Skill.new(self, {id = skillId, target = target})
--返回客户端
for _, target in ipairs(skill:getTargets()) do
self.battle.adv:backSkill(self.monsterId, skillId, target.id)
end
skill:doEffect()
for _, team in ipairs(self:getTeam(2)) do
team:triggerPassive(Passive.TARGET_SKILL)
end
for _, team in ipairs(self:getTeam(1, true)) do
team:triggerPassive(Passive.TEAM_SKILL)
end
end
--0 全部 1 我方 2 敌方
function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock)
mapIdx = mapIdx or self.battle.adv:getCurMapIdx()
nType = nType or 0
local team = {}
local function addPlayer()
if not noSelf or self.battle.player ~= self then
if not self.battle.player.isDead then
table.insert(team, self.battle.player)
end
end
end
local function addEnemy()
for _, enemy in pairs(self.battle.enemys[mapIdx]) do
if not noSelf or enemy ~= self then
if not enemy.isDead and (includeLock or not enemy.lock) then -- 已经翻开的
table.insert(team, enemy)
end
end
end
end
if nType == 0 then
addPlayer()
addEnemy()
elseif nType == 1 then
if not self.monsterId then --玩家
addPlayer()
else
addEnemy()
end
elseif nType == 2 then
if not self.monsterId then --玩家
addEnemy()
else
addPlayer()
end
end
return team
end
function BaseObject:getDB()
local db = {}
db.hp = self.hp
local baseAttr = {"atk", "miss", "hit", "def", "hpMax"}
for _, field in pairs(baseAttr) do
db[field] = self[field]
db["_"..field] = self["_" .. field]
end
db.passives = {}
for _, passive in ipairs(self.passives) do
table.insert(db.passives, passive:getDB())
end
db.buffs = {}
for _, buff in ipairs(self.buffs) do
table.insert(db.buffs, buff:getDB())
end
return db
end
function BaseObject:triggerPassive(condType, params)
if self.isDead then return end
for _, passive in ipairs(self.passives) do
passive:trigger(condType, params) --检查触发
end
end
function BaseObject:changeSp()
end
function BaseObject:is(what)
return self["is" .. what] and self["is" .. what](self)
end
local Enemy = class("Enemy", BaseObject)
function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy, mapIdx)
Enemy.super.ctor(self, battle)
self.id = mId
self.monsterId = monsterId --数据id
self.roomId = roomId
self.blockId = blockId
self.lock = lock
self.mapIdx = mapIdx
self:initData(enemy)
end
function Enemy:unlock(id)
self.id = id
self.lock = nil
end
function Enemy:isEnemy()
return true
end
local Player = class("Player", BaseObject)
function Player:ctor(battle, data)
Player.super.ctor(self, battle)
self:initData(data)
end
function Player:initData(data)
Player.super.initData(self, data)
self.level = data.level or 1 --level 每增加1级 属性增长 growth * baseAttr
self.growth = data.growth
self.exp = data.exp or 0
self.sp = data.sp or 100
self.spMax = data.spMax or 100
self._spMax = data._spMax or 100
end
function Player:addExp(value)
-- buff 经验加成
local up = self:getCommonBuffEffect(Buff.EXP_UP)
value = math.ceil((value + up[0]) * (1 + up[1]))
if value <= 0 then return end
local newExp = self.exp + value
local level = self.level
if level >= #csvdb["adv_levelCsv"] then return end
while true do
local curData = csvdb["adv_levelCsv"][level]
if newExp < curData.exp then break end
level = level + 1
newExp = newExp - curData.exp
if level >= #csvdb["adv_levelCsv"] then break end
end
local delta = level - self.level
if delta > 0 then
for attr, _ in pairs(AdvAttsEnum) do
self:addBaseAttr(attr, self.growth[attr] * delta, 0, true)
end
self.battle.adv:pushBackEvent(AdvBackEventType.Level, {level = level, delta = delta})
end
self.level = level
self.exp = newExp
return value
end
--vtype 0/1 值/%
function Player:addBaseAttr(attr, value, vtype, ignoreBack)
local attrName = attr
if attr == "hp" then
attrName = "hpMax"
elseif attr == "sp" then
attrName = "spMax"
end
local baseName = "_" .. attrName
if not self[baseName] then return end
local oldV = self[baseName]
local change = value
if vtype == 1 then
change = oldV * value / 100
end
self[baseName] = self[baseName] + change
if attr == "hp" then
self.hp = self.hp + change
self:reSetHpMax()
elseif attr == "sp" then
self.sp = self.sp + change
self:reSetSpMax()
else
self:reSetAttr(attr)
end
if not ignoreBack then
self.battle.adv:pushBackEvent(AdvBackEventType.BaseAttrChange, {type = AdvAttsEnum[attr] or 0, change = change})
end
end
--cType 0 or nil 值 1 百分比
function Player:changeSp(value, cType)
local oldSp = self.sp
cType = cType or 0
if cType == 0 then
self.sp = self.sp + value
elseif cType == 1 then
self.sp = self.sp + self.sp * value / 100
end
self.sp = math.floor(math.min(self.spMax, math.max(0, self.sp)))
if self.sp - oldSp ~= 0 then
self.battle.adv:pushBackEvent(AdvBackEventType.SpChange, {change = self.sp - oldSp})
end
end
-- 重新计算 魔法上限
function Player:reSetSpMax()
self.spMax = self._spMax
local change = self:getCommonBuffEffect(Buff.SP_MAX_CHANGE)
self.spMax = math.ceil((self.spMax + change[0]) * (1 + change[1]))
self.spMax = math.max(1, self.spMax)
self.sp = math.min(self.spMax, self.sp)
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
buff:effect()
end
end
end
function Player:afterLayer()
for _, buff in ipairs(self.buffs) do
if not buff.isDel then
buff:afterLayer()
end
end
end
function Player:addBuff(buffId, releaser)
local status = Player.super.addBuff(self, buffId, releaser)
if status then
self.battle.player:attrChangeCondBuffCheck(2, buffId)
self.battle.adv:checkAchievement(self.battle.adv.AchievType.GetBuff, 1, buffId)
self.battle.adv:pushBackEvent(AdvBackEventType.Buff, {buffId = buffId})
end
return status
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
local _et, _attr, _co = buff:getEffectBy()
if etype == _et and (not _co or _co == cond) then
effect[_attr] = 1
end
end
end
for attrName, _ in pairs(effect) do
if attrName == "hp" then
self:reSetHpMax()
else
self:reSetAttr(attrName)
end
end
end
function Player:isPlayer()
return true
end
function Player:getDB()
local db = Player.super.getDB(self)
for _ , field in pairs({"level", "exp", "growth", "sp", "spMax"}) do
db[field] = self[field]
end
db["_spMax"] = self._spMax
return db
end
-- 建筑 拥有被动技
local Build = class("Build", BaseObject)
function Build:ctor(battle, id, roomId, blockId, lock, build, mapIdx)
Enemy.super.ctor(self, battle)
self.id = id
self.monsterId = monsterId --数据id
self.roomId = roomId
self.blockId = blockId
self.lock = lock
self.mapIdx = mapIdx
self:initData(build)
end
function Build:initData(data)
end
function Build:addBuff(buffId, releaser)
end
function Build:hurt()
end
function Build:isBuild()
return true
end
--0 全部 1 怪物 2 玩家
function Build:getTeam(nType, noSelf, mapIdx, includeLock)
noSelf = false -- 不管怎么都取不到自己
mapIdx = mapIdx or self.battle.adv:getCurMapIdx()
nType = nType or 0
local team = {}
local function addPlayer()
if not noSelf or self.battle.player ~= self then
if not self.battle.player.isDead then
table.insert(team, self.battle.player)
end
end
end
local function addEnemy()
for _, enemy in pairs(self.battle.enemys[mapIdx]) do
if not noSelf or enemy ~= self then
if not enemy.isDead and (includeLock or not enemy.lock) then -- 已经翻开的
table.insert(team, enemy)
end
end
end
end
if nType == 0 then
addPlayer()
addEnemy()
elseif nType == 1 then
addEnemy()
elseif nType == 2 then
addPlayer()
end
return team
end
function Build:unlock()
self.lock = nil
end
function Build:getDB()
local db = {}
db.passives = {}
for _, passive in ipairs(self.passives) do
table.insert(db.passives, passive:getDB())
end
return db
end
return table.pack(Player, Enemy, Build)