46fac6f1
 
  zhouahaihai
 
酱料
 | 
1
2 
 | 
  -- 角色
  local Buff = require "adv.AdvBuff"
 
 | 
1b8336a6
 
  suhongyang
 
skill逻辑与player分开
 | 
3 
 | 
  local Skill = require "adv.AdvSkill"
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
4
5
6
7
8
9
10
11 
 | 
  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
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
12 
 | 
  	self.def = 0
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
13
14
15
16 
 | 
  	self.aType = 0 --攻击类型
  	self.lock = nil
  	self.passives = {} --固有技能
  	self.buffs = {} --buff
 
 | 
42f2d1d3
 
  suhongyang
 
战斗内技能序列逻辑
 | 
17 
 | 
  	self.skillOrder = {} --战斗内技能序列
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
18 
 | 
  	self.isDead = false
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
19
20
21
22
23 
 | 
  end
  --初始化角色
  function BaseObject:initData(data)
  	self.hpMax = data.hpMax or data.hp
  	self.hp = data.hp
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
24
25
26
27 
 | 
  	--可变化的值
  	self.atk = data.atk
  	self.miss = data.miss
  	self.hit = data.hit
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
28 
 | 
  	self.def = data.def
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
29
30
31
32 
 | 
  	--基础值记录
  	self._atk = data._atk or self.atk
  	self._miss = data._miss or self.miss
  	self._hit = data._hit or self.hit
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
33 
 | 
  	self._def = data._def or self.def
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
34
35
36
37 
 | 
  end
  -- 角色初始化完以后才是 技能和被动技能  方便初始化 buff 的 释放对象
  function BaseObject:initAfter(data)
  	for _, passive in ipairs(data.passives or {}) do
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
38 
 | 
  		table.insert(self.passives, Passive.new(self, passive))
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
39
40
41
42
43
44 
 | 
  	end
  	for _, buff in ipairs(data.buffs or {}) do
  		table.insert(self.buffs, Buff.load(self, buff))
  	end
  end
  
 
 | 
a734980c
 
  suhongyang
 
冒险战斗数据打完以前不存储
 | 
45
46
47
48
49
50
51 
 | 
  function BaseObject:reset(data)
  	self.passives = {}
  	self.buffs = {}
  	self:initData(data)
  	self:initAfter(data)
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
52
53
54
55
56 
 | 
  function BaseObject:afterRound()
  	for _, passive in ipairs(self.passives) do
  		passive:afterRound(self)
  	end
  	for _, buff in ipairs(self.buffs) do
 
 | 
0d405dc3
 
  suhongyang
 
Buff生命周期调整,被动加buf...
 | 
57 
 | 
  		buff:afterRound()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
58
59
60 
 | 
  	end
  end
  
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
61 
 | 
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
62
63
64
65
66
67
68
69
70 
 | 
  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
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
71 
 | 
  			self.battle.adv:backBuff(self.id, self.buffs[i].id, true)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
72
73
74
75
76
77
78
79
80
81 
 | 
  			self.buffs[i]:endBuff()
  			table.remove(self.buffs, i)
  		end
  	end
  end
  function BaseObject:clear()
  	self.buffs = {}
  	self.passives = {}
  end
  
 
 | 
821f2b60
 
  suhongyang
 
冒险战斗完善,增加battlebe...
 | 
82 
 | 
  function BaseObject:battleBegin()
 
 | 
65de8cf1
 
  suhongyang
 
被动逻辑进一步修缮
 | 
83 
 | 
  	for _, passive in ipairs(self.passives) do
 
 | 
821f2b60
 
  suhongyang
 
冒险战斗完善,增加battlebe...
 | 
84 
 | 
  		passive:battleBegin()
 
 | 
65de8cf1
 
  suhongyang
 
被动逻辑进一步修缮
 | 
85 
 | 
  	end
 
 | 
0d405dc3
 
  suhongyang
 
Buff生命周期调整,被动加buf...
 | 
86
87
88 
 | 
  end
  
  function BaseObject:battleEnd()
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
89 
 | 
  	for _, buff in ipairs(self.buffs) do
 
 | 
0d405dc3
 
  suhongyang
 
Buff生命周期调整,被动加buf...
 | 
90 
 | 
  		buff:battleEnd()
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
91 
 | 
  	end
 
 | 
65de8cf1
 
  suhongyang
 
被动逻辑进一步修缮
 | 
92
93 
 | 
  end
  
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
94
95 
 | 
  function BaseObject:addPassive(params)
  	local skillId = params.id
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
96 
 | 
  	local skillData = csvdb["adv_map_passiveCsv"][skillId]
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
97
98
99
100 
 | 
  	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 }))
 
 | 
4eadc2ab
 
  suhongyang
 
獲得被動暫時增加log,後面可以去掉
 | 
101
102 
 | 
  
  	self.battle.adv:backPassive(self.id, skillId)
 
 | 
23a38f47
 
  suhongyang
 
new passives  effect
 | 
103
104 
 | 
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
105 
 | 
  function BaseObject:addBuff(buffId, releaser)
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
106 
 | 
  	local buffData = csvdb["adv_map_buffCsv"][buffId]
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
107
108 
 | 
  	if not buffData then return end
  	for _, buff in ipairs(self.buffs) do
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
109
110
111 
 | 
  		if not buff.isDel and (buff:getType() == Buff.CLEAR_BUFF or buff:getType() == Buff.IMMNUE_BUFF) then
  			if buff:canEffect(buffId, buffData.group) then
  				buff:effect()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
112
113
114
115
116 
 | 
  				return
  			end
  		end
  	end
  	table.insert(self.buffs, Buff.create(self, releaser, {id = buffId}))
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
117
118 
 | 
  
  	self.battle.adv:backBuff(self.id, buffId)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
119
120 
 | 
  end
  
 
 | 
916096ed
 
  zhouhaihai
 
神器效果
 | 
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 
 | 
  function BaseObject:delBuffById(bId)
  	for _, buff in ipairs(self.buffs) do
  		if not buff.isDel and buff.id == bId then
  			buff.isDel = true
  			return buff
  		end
  	end
  end
  
  function BaseObject:delPassiveById(pId)
  	for _, passive in ipairs(self.passives) do
  		if not passive.isDel and passive.id == pId then
  			passive.isDel = true
  			return passive
  		end
  	end
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
139
140
141 
 | 
  function BaseObject:hadBuff(bType)
  	for _, buff in ipairs(self.buffs) do
  		if not buff.isDel and buff:getType() == bType then
 
 | 
7828ffd0
 
  zhouhaihai
 
冒险 连续选择点 和 地图因子
 | 
142 
 | 
  			return buff
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
143
144
145
146 
 | 
  		end
  	end
  end
  
 
 | 
1cb78a24
 
  suhongyang
 
passive的筛选
 | 
147
148
149 
 | 
  function BaseObject:hadBuffById(bId)
  	for _, buff in ipairs(self.buffs) do
  		if not buff.isDel and buff.id == bId then
 
 | 
7828ffd0
 
  zhouhaihai
 
冒险 连续选择点 和 地图因子
 | 
150 
 | 
  			return buff
 
 | 
1cb78a24
 
  suhongyang
 
passive的筛选
 | 
151
152
153
154 
 | 
  		end
  	end
  end
  
 
 | 
916096ed
 
  zhouhaihai
 
神器效果
 | 
155 
 | 
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
156
157
158
159
160 
 | 
  -- 通用的buff 效果汇总  -- 0 固定 1百分比  两种分类
  function BaseObject:getCommonBuffEffect(bType)
  	local effect, count = {[0] = 0, [1] = 0}, 0
  	for _, buff in ipairs(self.buffs) do
  		if not buff.isDel and buff:getType() == bType then
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
161 
 | 
  			local cType, value = buff:effect()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
162 
 | 
  			if cType then
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
163 
 | 
  				effect[cType] = effect[cType] + value
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
164
165
166
167 
 | 
  				count = count + 1
  			end
  		end
  	end
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
168 
 | 
  	effect[1] = effect[1] / 100
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
169
170
171
172
173
174
175 
 | 
  	return effect, count --效果 和生效的buff 个数
  end
  --伤害反弹
  function BaseObject:getBackHurtBuff(isAtk)
  	local effect = {[0] = 0, [1] = 0}
  	for _, buff in ipairs(self.buffs) do
  		if not buff.isDel and buff:getType() == Buff.BACK_HURT then
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
176 
 | 
  			local cType, value, aType = buff:effect()  --  aType 0 全部  1 普通攻击
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
177
178 
 | 
  			if cType then
  				if aType == 0 or isAtk then
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
179 
 | 
  					effect[cType] = effect[cType] + value
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198 
 | 
  				end
  			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:reSetAttr(field)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
199 
 | 
  	local old = self[field]
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
200 
 | 
  	self[field] = self["_" .. field] --重置一下
 
 | 
7c55db1f
 
  suhongyang
 
Buff逻辑完善,buff生效次数...
 | 
201 
 | 
  	local fieldToBuff = {atk = Buff.ATK_CHANGE, hit = Buff.HIT_CHANGE, miss = Buff.MISS_CHANGE, def = Buff.DEF_CHANGE}
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
202 
 | 
  	local effect = self:getCommonBuffEffect(fieldToBuff[field])
 
 | 
e10edb5f
 
  zhouahaihai
 
冒险事件新
 | 
203 
 | 
  	self[field] = math.ceil((self[field] + effect[0]) * (1 + effect[1]))
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
204
205
206
207 
 | 
  	local delta = self[field] - old
  	if delta ~= 0 then
  		if field == "atk" then
  			self.battle.adv:backAtkChange(self.id, delta)
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
208
209 
 | 
  		elseif field == "def" then
  			self.battle.adv:backDefChange(self.id, delta)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
210
211 
 | 
  		end 
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
212
213
214
215
216
217
218
219
220
221
222 
 | 
  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()
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
223 
 | 
  	return math.max(0, (value + injuredChange[0]) * (1 + injuredChange[1]) - self.def)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
224
225 
 | 
  end
  
 
 | 
ae9a74b5
 
  suhongyang
 
返回miss,快速战斗逻辑
 | 
226 
 | 
  --最终伤害 = [ (敌方攻击 - 己方防御) * (1+伤害增加百分比-伤害减少百分比)*(1+受伤增加百分比-受伤减少百分比)+(伤害增加固定值-伤害增加固定值+受伤增加固定值-受伤增加固定值)]*(1+侍宠百分比)-侍宠固定值
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
227 
 | 
  -- params   -- hurtType  1 普攻伤害  2 buff伤害  3 反弹伤害  4 真实伤害  5 客户端发回来的伤害  --直接作用 6 buff伤害(真实)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
228
229
230
231 
 | 
  --进入这个方法之前计算好释放者加成的伤害
  function BaseObject:hurt(value, releaser, params)
  	params = params or {}
  	if params.hurtType and params.hurtType == 1 then
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
232
233
234
235 
 | 
  		releaser:triggerPassive(Passive.SELF_ATK)
  		for _, team in ipairs(releaser:getTeam(1, true)) do
  			team:triggerPassive(Passive.TEAM_ATK)
  		end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
236
237
238
239 
 | 
  		if self:hadBuff(Buff.IMMNUE_ATK) then return end --无视普通攻击
  		
  		local hit = releaser.hit - self.miss  --命中率
  		if hit < math.randomInt(1, 100) then --miss
 
 | 
ae9a74b5
 
  suhongyang
 
返回miss,快速战斗逻辑
 | 
240 
 | 
  			self.battle.adv:backMiss(self.id)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
241
242 
 | 
  			return
  		end
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
243
244
245
246 
 | 
  		self:triggerPassive(Passive.SELF_HURT, {trigger = releaser})
  		for _, team in ipairs(self:getTeam(1, true)) do
  			team:triggerPassive(Passive.TEAM_HURT, {trigger = releaser})
  		end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
247 
 | 
  	end
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
248 
 | 
  	if params.hurtType ~= 5 and params.hurtType ~= 6 then
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
249
250 
 | 
  		if not params.hurtType or params.hurtType ~= 4 then
  			value = self:getInjuredValue(value) --减伤计算
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
251 
 | 
  		end
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266 
 | 
  		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
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
267 
 | 
  		end
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282 
 | 
  		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
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
283
284
285
286
287 
 | 
  				end
  			end
  		end
  	end
  
 
 | 
e10edb5f
 
  zhouahaihai
 
冒险事件新
 | 
288 
 | 
  	value = math.max(0, math.ceil(value))
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
289
290 
 | 
  	if value == 0 then return end
  	-- 反弹伤害
 
 | 
12f7b52c
 
  zhouhaihai
 
冒险战斗
 | 
291 
 | 
  	if params.hurtType ~= 3 and params.hurtType ~= 5 and releaser and not releaser.isDead then
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
292
293
294
295
296
297 
 | 
  		local backEffect = self:getBackHurtBuff(params.hurtType == 1)
  		local backValue = math.max(0, value * backEffect[1] + backEffect[0])
  		releaser:hurt(backValue, releaser, {hurtType = 3})
  	end
  
  	--受伤了~
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
298 
 | 
  	self.battle.adv:backHpChange(self.id, -value)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
299 
 | 
  	self.hp = math.max(0, self.hp - value)
 
 | 
b0fe1817
 
  zhouahaihai
 
冒险分数
 | 
300
301
302
303
304 
 | 
  
  	if self.cutHp then
  		self:cutHp(value)
  	end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
305 
 | 
  	if self.hp == 0 then
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
306
307
308
309
310 
 | 
  		self:triggerPassive(Passive.SELF_DEAD)
  		for _, team in ipairs(self:getTeam(1, true)) do
  			team:triggerPassive(Passive.TEAM_DEAD)
  		end
  
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
311 
 | 
  		if (params.hurtType == 6 or params.hurtType == 2) and self ~= self.battle.player then
 
 | 
b176d7d3
 
  zhouhaihai
 
冒险成就
 | 
312
313
314 
 | 
  			self.battle.adv:checkAchievement(self.battle.adv.AchievType.KillByBuff, 1, params.buffId)
  		end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
315 
 | 
  		self.isDead = true
 
 | 
bedca62d
 
  zhouahaihai
 
冒险
 | 
316 
 | 
  		self.battle.adv:backDead(self.id)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
317 
 | 
  	end
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
318
319
320
321 
 | 
  	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
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
322
323
324
325 
 | 
  end
  --恢复
  function BaseObject:recover(value, releaser, params)
  	params = params or {}
 
 | 
e10edb5f
 
  zhouahaihai
 
冒险事件新
 | 
326 
 | 
  	value = math.max(0, math.ceil(value))
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
327 
 | 
  	self.hp = math.min(self.hpMax, self.hp + value)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
328 
 | 
  	self.battle.adv:backHpChange(self.id, value)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
329
330 
 | 
  end
  
 
 | 
42f2d1d3
 
  suhongyang
 
战斗内技能序列逻辑
 | 
331
332
333
334
335 
 | 
  function BaseObject:addSpecialSkill(skillId, skillLevel, target)
  	local skillData = {id = skillId, level = skillLevel, target = target}
  	table.insert(self.skillOrder, skillData)
  end
  
 
 | 
d27ad5e0
 
  suhongyang
 
使用营养技
 | 
336 
 | 
  function BaseObject:releaseSkill(skillId, target)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
337 
 | 
  	if self:hadBuff(Buff.CANT_SKILL) then return end -- 针对 怪物
 
 | 
d27ad5e0
 
  suhongyang
 
使用营养技
 | 
338 
 | 
  	local skill = Skill.new(self, {id = skillId, target = target})
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
339 
 | 
  	--返回客户端
 
 | 
1b8336a6
 
  suhongyang
 
skill逻辑与player分开
 | 
340 
 | 
  	for _, target in ipairs(skill:getTargets()) do
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
341
342 
 | 
  		self.battle.adv:backSkill(self.id, skillId, target.id)
  	end
 
 | 
1b8336a6
 
  suhongyang
 
skill逻辑与player分开
 | 
343 
 | 
  	skill:doEffect()
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
344
345
346
347
348
349 
 | 
  	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
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
350
351
352 
 | 
  end
  
  --0 全部  1 我方  2 敌方
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
353 
 | 
  function BaseObject:getTeam(nType, noSelf, mapIdx, includeLock)
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
354 
 | 
  	mapIdx = mapIdx or self.battle.adv:getCurMapIdx()
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
355
356
357
358
359
360
361
362
363
364 
 | 
  	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()
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
365 
 | 
  		for _, enemy in pairs(self.battle.enemys[mapIdx]) do
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
366 
 | 
  			if not noSelf or enemy ~= self then 
 
 | 
53e8037e
 
  zhouhaihai
 
任务
 | 
367 
 | 
  				if not enemy.isDead and (includeLock or not enemy.lock) then -- 已经翻开的
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
368
369
370
371
372
373
374
375
376 
 | 
  					table.insert(team, enemy)
  				end
  			end
  		end
  	end
  	if nType == 0 then
  		addPlayer()
  		addEnemy()
  	elseif nType == 1 then
 
 | 
b594a026
 
  suhongyang
 
Fix bug
 | 
377 
 | 
  		if not self.monsterId then --玩家
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
378
379
380
381
382 
 | 
  			addPlayer()
  		else
  			addEnemy()
  		end
  	elseif nType == 2 then
 
 | 
b594a026
 
  suhongyang
 
Fix bug
 | 
383 
 | 
  		if not self.monsterId then --玩家
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
384
385
386
387
388
389
390
391
392
393
394
395 
 | 
  			addEnemy()
  		else
  			addPlayer()
  		end
  	end
  	return team
  end
  
  function BaseObject:getDB()
  	local db = {}
  	db.hpMax = self.hpMax
  	db.hp = self.hp
 
 | 
e996b82a
 
  zhouahaihai
 
冒险增加防御属性
 | 
396 
 | 
  	local baseAttr = {"atk", "miss", "hit", "def"}
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
397
398
399
400
401
402
403
404 
 | 
  	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
 
 | 
4ae223df
 
  zhouahaihai
 
Buff bug
 | 
405 
 | 
  	db.buffs = {}
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
406
407
408
409
410
411
412 
 | 
  	for _, buff in ipairs(self.buffs) do
  		table.insert(db.buffs, buff:getDB())
  	end
  	return db
  end
  
  function BaseObject:triggerPassive(condType, params)
 
 | 
02c4de8d
 
  zhouahaihai
 
增加 固有技
 | 
413
414
415
416 
 | 
  	if self.isDead then return end
  	for _, passive in ipairs(self.passives) do
  		passive:trigger(condType, params) --检查触发
  	end
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
417
418 
 | 
  end
  
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
419
420
421 
 | 
  function BaseObject:changeSp()
  end
  
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
422 
 | 
  local Enemy = class("Enemy", BaseObject)
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
423 
 | 
  function Enemy:ctor(battle, mId, monsterId, roomId, blockId, lock, enemy, mapIdx)
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
424 
 | 
  	Enemy.super.ctor(self, battle)
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
425
426 
 | 
  	self.id = mId
  	self.monsterId = monsterId  --数据id
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
427
428
429 
 | 
  	self.roomId = roomId
  	self.blockId = blockId
  	self.lock = lock
 
 | 
43babcff
 
  zhouhaihai
 
优化冒险结构  增加夹层功能
 | 
430 
 | 
  	self.mapIdx = mapIdx
 
 | 
46fac6f1
 
  zhouahaihai
 
酱料
 | 
431
432
433
434
435
436
437
438
439
440
441
442
443 
 | 
  	self:initData(enemy)
  end
  function Enemy:unlock(id)
  	self.id = id
  	self.lock = nil
  end
  
  local Player = class("Player", BaseObject)
  function Player:ctor(battle, data)
  	Player.super.ctor(self, battle)
  	self:initData(data)
  end
  
 
 | 
b0fe1817
 
  zhouahaihai
 
冒险分数
 | 
444
445
446
447 
 | 
  function Player:cutHp(value)
  	self.battle.adv:scoreChange(AdvScoreType.Hurt, value)
  end
  
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
448
449 
 | 
  function Player:initData(data)
  	Player.super.initData(self, data)
 
 | 
386ca58e
 
  zhouhaihai
 
优化log
 | 
450 
 | 
  	self.level = data.level or 1  --level 每增加1级  属性增长 growth * baseAttr
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
451
452 
 | 
  	self.growth = data.growth or 0
  	self.exp = data.exp or 0
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
453 
 | 
  	self.sp = data.sp or 100
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
454
455
456 
 | 
  end
  
  function Player:addExp(value)
 
 | 
51718558
 
  zhouhaihai
 
中继层初始经验
 | 
457 
 | 
  	if value <= 0 then return end
 
 | 
6732f756
 
  zhouhaihai
 
玩家升级
 | 
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472 
 | 
  	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
  		local baseAttr = csvdb["adv_unitCsv"][self.battle.adv.chapterId]
  		for _, attr in pairs(AttsEnumEx) do
  			if baseAttr[attr] then
 
 | 
8019d0bb
 
  zhouhaihai
 
冒险buff 调整
 | 
473 
 | 
  				self[attr] = self[attr] +  self.growth * delta
 
 | 
6732f756
 
  zhouhaihai
 
玩家升级
 | 
474 
 | 
  				if attr == "hp" then
 
 | 
8019d0bb
 
  zhouhaihai
 
冒险buff 调整
 | 
475 
 | 
  					self.hpMax = self.hpMax +  self.growth * delta
 
 | 
6732f756
 
  zhouhaihai
 
玩家升级
 | 
476 
 | 
  				else
 
 | 
8019d0bb
 
  zhouhaihai
 
冒险buff 调整
 | 
477 
 | 
  					self["_" .. attr] = self["_" .. attr] + self.growth * delta
 
 | 
6732f756
 
  zhouhaihai
 
玩家升级
 | 
478
479
480
481
482
483 
 | 
  				end
  			end
  		end
  	end
  	self.level = level
  	self.exp = newExp
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
484
485 
 | 
  end
  
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
486
487
488
489
490
491
492
493
494
495
496
497 
 | 
  --cType 0 or nil  值  1 百分比
  function Player:changeSp(value, cType)
  	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.max(0, self.sp))
  	self.battle.adv:pushBackEvent(AdvBackEventType.SpChange)
  end
  
 
 | 
e90b4d20
 
  zhouhaihai
 
战斗buff
 | 
498
499
500 
 | 
  --战斗结束了扣战斗buff次数
  function Player:effectBattleBuff()
  	for _, buff in ipairs(self.buffs) do
 
 | 
b176d7d3
 
  zhouhaihai
 
冒险成就
 | 
501 
 | 
  		if not buff.isDel and (buff:getType() == Buff.BATTLE_BUFF or buff:getType() == Buff.BATTLE_PASSIVE) then
 
 | 
e90b4d20
 
  zhouhaihai
 
战斗buff
 | 
502
503
504
505 
 | 
  			buff:effect()
  		end
  	end
  end
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
506 
 | 
  
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
507
508 
 | 
  function Player:getDB()
  	local db = Player.super.getDB(self)
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
509 
 | 
  	for _ , field in pairs({"level", "exp", "growth", "sp"}) do
 
 | 
b53593b5
 
  zhouhaihai
 
羁绊加成
 | 
510
511
512
513
514 
 | 
  		db[field] = self[field]
  	end
  	return db
  end
  
 
 | 
3b0526d2
 
  zhouhaihai
 
冒险demo
 | 
515
516 
 | 
  
  
 
 | 
36c30c5c
 
  zhouahaihai
 
冒险
 | 
517 
 | 
  return table.pack(Player, Enemy)
 
 |