Blame view

src/adv/Adv.lua 70.3 KB
46fac6f1   zhouahaihai   酱料
1
2
  local Passive = require "adv.AdvPassive"
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
3
4
  local AdvCommon = require "adv.AdvCommon"
  local AdvMap = require "adv.AdvMap"
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
5
  local Buff = require "adv.AdvBuff"
46fac6f1   zhouahaihai   酱料
6
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
7
  local Adv = class("Adv")
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
8
9
10
  local AdvTask = import(".AdvTask")  --任务相关数据搞出去
  AdvTask.bind(Adv)
  
9104a922   zhouhaihai   多重掉落
11
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
12
13
14
15
  function Adv:ctor(owner)
  	assert(owner, "Adv instance must have owner(role)")
  	self.owner = owner
  	self.maps = {}
f8408529   zhouhaihai   冒险商店
16
  	self.shopStatus = {}
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
17
18
  	self.battle = nil
  	self.backEvents = {} --发给客户端的事件组
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
19
20
21
22
  
  	self.advTask = self.owner:getProperty("advTask")
  	self.advMTask = self.owner:getProperty("advMTask")
  	self.advTaskChange = false -- 任务改变才更新
46fac6f1   zhouahaihai   酱料
23
24
  end
  
f22a33af   zhouhaihai   自己的日志
25
26
27
28
29
30
31
32
33
34
35
  function Adv:mylog(contents)
  	contents = contents or {}
  	if contents["cint1"] or contents["cint2"] or contents["cint3"] then
  		print("advLog error log have cint1 or cint2 or cint3 ", debug.traceback())
  	end
  	contents["cint1"] = self.chapterId
  	contents["cint2"] = self.level
  
  	self.owner:mylog("adv_action", contents)
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
36
  --初始化adv 信息
70cc72d7   zhouhaihai   拾荒bug
37
38
  function Adv:initByInfo()
  	local advInfo = self.owner:getProperty("advInfo")
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
39
40
41
42
  	if not next(advInfo) then return end --还没有 开始新地图
  
  	self.chapterId = advInfo.chapterId
  	self.level = advInfo.level or 1
98be031a   liuzujun   新年活动
43
  	self.actid = advInfo.actid
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
44
  	self.round = advInfo.round or 0
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
45
  	self.score = advInfo.score or {}
0e3ab88d   zhouhaihai   中继层
46
  	self.isRelay = advInfo.isRelay
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
47
48
  	self.lastEnemyId = advInfo.lastEId or 1
  	self.mapStack = advInfo.mstack or {}
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
49
  	self.lchoose = advInfo.lch or {}
ccbafe67   zhouhaihai   冒险神器和buff
50
  	self.waitArtifact = advInfo.waitAF
f45d3a7b   zhouhaihai   adv_unlock
51
  	self.cacheUnlock = advInfo.cacheUnlock or {}
f8408529   zhouhaihai   冒险商店
52
  	self.shopStatus = advInfo.shopStatus or {}
9ced5432   zhouhaihai   冒险支援效果 保底事件
53
  	self.support = advInfo.support or {}
97807511   zhouhaihai   增加日志
54
  	self.logid = advInfo.logid or "auto"
f8408529   zhouhaihai   冒险商店
55
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
56
57
58
  	self.maps = {}
  	for id, map in ipairs(advInfo.maps or {}) do
  		self.maps[id] = AdvMap.new(self, id, map)
46fac6f1   zhouahaihai   酱料
59
  	end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
60
  
400f1f91   zhouhaihai   auras
61
  	self:initBattle(advInfo)
46fac6f1   zhouahaihai   酱料
62
  end
0e3ab88d   zhouhaihai   中继层
63
  -- 找出level 是否存在中继层
1ef9a7e3   zhouhaihai   错误的
64
  function Adv:isHaveRelay(level, chapterId, force)
b5185d3b   zhouhaihai   bug
65
  	level = level or self.level
0e3ab88d   zhouhaihai   中继层
66
  	chapterId = chapterId or self.chapterId
1ef9a7e3   zhouhaihai   错误的
67
  	if level == 1 and not force then return end
0e3ab88d   zhouhaihai   中继层
68
69
70
71
72
73
74
75
76
  	
  	local campsiteCsv = csvdb["adv_chapter_campsiteCsv"][chapterId]
  	for _, campsite in ipairs(campsiteCsv) do
  		if campsite.floor == level then
  			return campsite
  		end
  	end
  	return nil
  end
46fac6f1   zhouahaihai   酱料
77
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
78
  -- 随机新的地图
35e2e3c4   zhouhaihai   优化 gm advt 增加感知b...
79
80
81
82
83
84
85
86
87
  function Adv:initByChapter(params)
  	local chapterId = params.chapterId
  	local level = params.level 
  	local isToNext = params.isToNext 
  	local notNotify = params.notNotify 
  	local isRelay = params.isRelay 
  	local isEnter = params.isEnter 
  	local support = params.support
  	local debugMapId = params.debugMapId
98be031a   liuzujun   新年活动
88
  	local actid = params.actid
35e2e3c4   zhouhaihai   优化 gm advt 增加感知b...
89
  
b176d7d3   zhouhaihai   冒险成就
90
91
92
93
94
95
96
  	if not self.chapterId then -- 开始新的章节
  		self.chapterId = chapterId
  		self:checkAchievement(Adv.AchievType.StartBattle, 1)
  	elseif chapterId ~= self.chapterId then  -- 正常不会出现
  		return 
  	end
  	
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
97
  	self.level = level or 1
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
98
  	self.round = 0
98be031a   liuzujun   新年活动
99
  	self.actid = self.actid or actid
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
100
101
102
  	self.score = self.score or {}
  	self.lastEnemyId = 1
  	self.mapStack = {1} -- 最后一个为当前的地图
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
103
  	self.lchoose = self.lchoose or {}
f45d3a7b   zhouhaihai   adv_unlock
104
  	self.cacheUnlock = self.cacheUnlock or {}
f8408529   zhouhaihai   冒险商店
105
  	self.shopStatus = self.shopStatus or {}
9ced5432   zhouhaihai   冒险支援效果 保底事件
106
  	self.support = self.support or {}
a80fee7c   zhouhaihai   光环
107
108
109
  	if self.battle then
  		self.battle:overBattle()
  	end
cd498e53   zhouhaihai   被动技生效bug
110
  	self.battle = nil  -- 清掉 老的 battle
97807511   zhouhaihai   增加日志
111
  	self.logid = self.owner:getActionUcode()
9ced5432   zhouhaihai   冒险支援效果 保底事件
112
113
114
  
  	if isEnter then -- 把 支援效果初始化为易用用的形式
  		self:initSupport(support or {})
17d8d855   zhouhaihai   冒险 时间 limit 改为全局
115
  		self.owner:setProperty("advLimit", {}) -- 清掉 Limit
9ced5432   zhouhaihai   冒险支援效果 保底事件
116
  	end
f4c65591   zhouhaihai   抽奖
117
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
118
  	-- 随机出地图
e51ff6d2   zhouhaihai   冒险~
119
  	local mapId, relayData
35e2e3c4   zhouhaihai   优化 gm advt 增加感知b...
120
121
122
123
124
125
126
127
128
129
130
131
132
  
  	if debugMapId and csvdb["mapCsv"][debugMapId] then
  		mapId = debugMapId
  	end
  	if not mapId then
  		if isRelay then
  			relayData = self:isHaveRelay(level, chapterId)
  			if relayData then 
  				mapId = relayData.map
  			else
  				isRelay = false
  				mapId = self:randomMapId(chapterId, level)
  			end
0e3ab88d   zhouhaihai   中继层
133
  		else
0e3ab88d   zhouhaihai   中继层
134
135
  			mapId = self:randomMapId(chapterId, level)
  		end
0e3ab88d   zhouhaihai   中继层
136
  	end
1d4eec98   zhouhaihai   冒险引导 锁定地图101
137
  
0e3ab88d   zhouhaihai   中继层
138
139
140
141
142
143
144
  	self.isRelay = isRelay
  	local isNewRelay = false
  	if self.isRelay then -- 中继层
  		local advRelay = self.owner:getProperty("advRelay")
  		local chapter = self:isEndless() and -1 or self.chapterId
  		if not (advRelay[chapter] or {})[self.level] then
  			isNewRelay = true
0e3ab88d   zhouhaihai   中继层
145
146
147
  		end
  	end
  
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
148
149
150
151
  	if self.level == 1 or self.isRelay then
  		self:supplyPotion()
  	end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
152
  	self.maps = {}
0e3ab88d   zhouhaihai   中继层
153
  	self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay)
46fac6f1   zhouahaihai   酱料
154
  
a5660239   zhouhaihai   冒险bug
155
  	self:initBattle(nil, isToNext)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
156
  
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
157
158
  	self:initLayerTask()
  
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
159
  	self:checkTask(Adv.TaskType.Arrive)
f45d3a7b   zhouhaihai   adv_unlock
160
  	self:checkAdvUnlock(1, self.level)
e51ff6d2   zhouhaihai   冒险~
161
  
e51ff6d2   zhouhaihai   冒险~
162
  	-- 中继进入奖励
9ee46da4   zhouhaihai   第一层也发奖
163
  	if isEnter then
40c88e08   zhouhaihai   拾荒bug
164
  		relayData = relayData or self:isHaveRelay(level, chapterId, true)
9ee46da4   zhouhaihai   第一层也发奖
165
166
167
  		if relayData then
  			self:awardRelay(relayData, notNotify)
  		end
e51ff6d2   zhouhaihai   冒险~
168
169
  	end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
170
171
  	if not notNotify then
  		self:saveDB(notNotify)
1607a7f0   zhouahaihai   冒险事件 new
172
  	end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
173
  end
b0fe1817   zhouahaihai   冒险分数
174
  
f2648427   zhouhaihai   修改中继营地解锁条件
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  function Adv:passAdvRelay()
  	local advRelay = self.owner:getProperty("advRelay")
  	local chapter = self:isEndless() and -1 or self.chapterId
  	if not (advRelay[chapter] or {})[self.level] then
  		advRelay[chapter] = advRelay[chapter] or {}
  		advRelay[chapter][self.level] = 1
  		self.owner:updateProperty({field = "advRelay", value = advRelay})
  		local relayData = self:isHaveRelay()
  		if relayData and relayData.award ~= "" then
  			self:pushBackEvent(AdvBackEventType.RelayReward, {items = self:award(relayData.award:toNumMap(), {log = {desc = "relayReward"}})})
  		end
  	end
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
189
190
191
  function Adv:clear()
  	self.chapterId = nil
  	self.level = nil
43a6d57e   liuzujun   拾荒活动
192
  	self.actid = nil
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
193
  	self.score = {}
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
194
  	self.round = 0
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
195
196
  	self.lastEnemyId = 1
  	self.mapStack = {}
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
197
  	self.lchoose = {}
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
198
199
  	self.maps = {}
  	self.battle = nil
ccbafe67   zhouhaihai   冒险神器和buff
200
  	self.waitArtifact = nil
0e3ab88d   zhouhaihai   中继层
201
  	self.isRelay = nil
f45d3a7b   zhouhaihai   adv_unlock
202
  	self.cacheUnlock = {}
f8408529   zhouhaihai   冒险商店
203
  	self.shopStatus = {}
9ced5432   zhouhaihai   冒险支援效果 保底事件
204
  	self.support = {}
1b20cfdb   zhouhaihai   赛季更新完善 无尽冒险排行榜
205
206
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
207
208
  function Adv:saveDB(notNotify)
  	local advInfo,  advTeam = {}, self.owner:getProperty("advTeam")
1b20cfdb   zhouhaihai   赛季更新完善 无尽冒险排行榜
209
  	if self:isRunning() then
46fac6f1   zhouahaihai   酱料
210
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
211
212
  		advInfo.chapterId = self.chapterId
  		advInfo.level = self.level
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
213
  		advInfo.round = self.round
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
214
  		advInfo.score = self.score
98be031a   liuzujun   新年活动
215
  		advInfo.actid = self.actid
0e3ab88d   zhouhaihai   中继层
216
  		advInfo.isRelay = self.isRelay
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
217
218
  		advInfo.lastEId = self.lastEnemyId
  		advInfo.mstack = self.mapStack
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
219
  		advInfo.lch = self.lchoose
ccbafe67   zhouhaihai   冒险神器和buff
220
  		advInfo.waitAF = self.waitArtifact
f45d3a7b   zhouhaihai   adv_unlock
221
  		advInfo.cacheUnlock = self.cacheUnlock
f8408529   zhouhaihai   冒险商店
222
  		advInfo.shopStatus = self.shopStatus
9ced5432   zhouhaihai   冒险支援效果 保底事件
223
  		advInfo.support = self.support
97807511   zhouhaihai   增加日志
224
  		advInfo.logid = self.logid
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
225
  		advInfo.maps = {}
1607a7f0   zhouahaihai   冒险事件 new
226
  
a80fee7c   zhouhaihai   光环
227
  		self.battle:saveDB(advInfo)
1607a7f0   zhouahaihai   冒险事件 new
228
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
229
230
  		for id , map in ipairs(self.maps) do
  			advInfo.maps[id] = map:getDB()
46fac6f1   zhouahaihai   酱料
231
  		end
46fac6f1   zhouahaihai   酱料
232
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
233
  		advTeam.player = self.battle.player:getDB()
46fac6f1   zhouahaihai   酱料
234
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
235
236
  	else
  		advTeam.player = nil
46fac6f1   zhouahaihai   酱料
237
  	end
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
238
239
  
  	self:updateTask(notNotify)
b176d7d3   zhouhaihai   冒险成就
240
  	self:updateAchievement(notNotify)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
241
  	self.owner:updateProperties({advInfo = advInfo, advTeam = advTeam}, notNotify)
46fac6f1   zhouahaihai   酱料
242
243
  end
  
e51ff6d2   zhouhaihai   冒险~
244
245
  function Adv:awardRelay(relayData, notNotify)
  	local gift = {}
e51ff6d2   zhouhaihai   冒险~
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
  	if relayData.artifact > 0 then
  		local pool = {}
  		for id, temp in pairs(csvdb["adv_artifactCsv"]) do
  			if not self:isHaveArtifact(id) and self.owner:isArtifactOpen(id, self:isEndless()) then
  				table.insert(pool, id)
  			end
  		end
  		for i = 1, math.min(relayData.artifact, #pool) do
  			local idx = math.randomInt(1, #pool)
  			gift[pool[idx]] = 1
  			table.remove(pool, idx)
  		end
  	end
  
  	if relayData.point > 0 then
  		gift[ItemId.AdvPoint] = relayData.point
  	end
  
  	if relayData.otherAward ~= "" then
  		for dropId, count in pairs(relayData.otherAward:toNumMap()) do
  			for i = 1, count do
  				local dropData = csvdb["event_dropCsv"][dropId]
  				if dropData then
  					local item = dropData["range"]:randWeight(true)
4b34fee8   zhouhaihai   增加~= 0 判定
270
271
272
  					if item[1] ~= 0 then
  						gift[item[1]] = (gift[item[1]] or 0) + item[2]
  					end
e51ff6d2   zhouhaihai   冒险~
273
274
275
276
277
278
279
280
281
282
  				else
  					skynet.error(string.format("[ERROR]: event_dropCsv no id %s,  adv_chapter_campsite",  dropId))
  				end
  			end
  		end
  	end
  
  	self:award(gift, {notNotify = notNotify,  log = {desc = "relayEnter", int1 = self.chapterId, int2 = self.level}})
  end
  
9ced5432   zhouhaihai   冒险支援效果 保底事件
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
  function Adv:initSupport(supports)
  	self.support = {}
  
  	local supportEffect = {}
  	-- 获得道具 1=道具id=道具数量
  	supportEffect[1] = function(_, itemId, num)
  		self.support[1] = self.support[1] or {}
  		self.support[1][itemId] = (self.support[1][itemId] or 0) + num
  	end
  
  	-- 获得mapbuff  2=mapbuffid
  	supportEffect[2] = function(_, buffId)
  		self.support[2] = self.support[2] or {}
  		table.insert(self.support[2], buffId)
  	end
  
  	-- 获得mappassive 3=mappassive
  	supportEffect[3] = function(_, passiveId)
  		self.support[3] = self.support[3] or {}
  		table.insert(self.support[3], passiveId)
  	end
  
  	-- 首层额外刷新 4=类型=id=数量(类型1=choose/2=building/3=click/4=drop/5=shop)
  	supportEffect[4] = function(_, etype, id, num)
  		self.support[4] = self.support[4] or {}
  		self.support[4][etype] = self.support[4][etype] or {}
  		self.support[4][etype][id] = (self.support[4][etype][id] or 0) + num
  	end
  
  	-- 每层额外刷新 5=类型=id=数量(类型1=choose/2=building/3=click/4=drop/5=shop)
  	supportEffect[5] = function(_, etype, id, num)
  		self.support[5] = self.support[5] or {}
  		self.support[5][etype] = self.support[5][etype] or {}
  		self.support[5][etype][id] = (self.support[5][etype][id] or 0) + num
  	end
  
  	-- 获得随机神器 6=数量
9250904b   zhouhaihai   参数错误
320
  	supportEffect[6] = function(_, num)
9ced5432   zhouhaihai   冒险支援效果 保底事件
321
322
323
324
  		self.support[6] = (self.support[6] or 0) + num
  	end
  
  	-- 获得3选1神器 7=选择次数(连续选择,每次选择重新随机)
9250904b   zhouhaihai   参数错误
325
  	supportEffect[7] = function(_, num)
9ced5432   zhouhaihai   冒险支援效果 保底事件
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
  		self.support[7] = (self.support[7] or 0) + num
  	end
  
  	for _, supportId in ipairs(supports) do
  		local supportData = csvdb["adv_supportCsv"][supportId]
  		for _, effect in ipairs(supportData.effect:toArray()) do
  			local cur = effect:toArray(true, "=")
  			if supportEffect[cur[1]] then
  				supportEffect[cur[1]](table.unpack(cur))
  			end 
  		end
  	end
  end
  
  function Adv:activeSomeSupport()
  	-- 奖励物品
  	if self.support[1] then
3133cb76   zhouhaihai   日志
343
  		self:award(self.support[1], {log = {desc = "support"}})
9ced5432   zhouhaihai   冒险支援效果 保底事件
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
  		self.support[1] = nil
  	end
  
  	-- 加buff
  	if self.support[2] then
  		for _, buffId in ipairs(self.support[2]) do
  			self.battle.player:addBuff(buffId)
  		end
  		self.support[2] = nil
  	end
  
  	--加被动技
  	if self.support[3] then
  		for _, passiveId in ipairs(self.support[3]) do
  			self.battle.player:addPassive({id = passiveId})
  		end
  		self.support[3] = nil
  	end
  
  	-- 加随机神器
  	if self.support[6] then
  		local pool = {}
  		for id, temp in pairs(csvdb["adv_artifactCsv"]) do
  			if not self:isHaveArtifact(id) and self.owner:isArtifactOpen(id, self:isEndless()) then
  				table.insert(pool, id)
  			end
  		end
  		for i = 1, math.min(self.support[6], #pool) do
  			local idx = math.randomInt(1, #pool)
3133cb76   zhouhaihai   日志
373
  			self:award({[pool[idx]] = 1}, {log = {desc = "support"}})
9ced5432   zhouhaihai   冒险支援效果 保底事件
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
  			table.remove(pool, idx)
  		end
  		self.support[6] = nil
  	end
  
  	self:supportChooseArtifact()
  end
  
  function Adv:supportChooseArtifact()
  	-- 加 三选一 神器
  	if self.support[7] then
  		if self.support[7] > 0 then
  			self:waitChooseArtifact()
  		end
  		self.support[7] = self.support[7] - 1
  		if self.support[7] <= 0 then
  			self.support[7] = nil
  		end
  	end
  end
  
  function Adv:supportFirstLayerAddEvent()
  	if self.support[4] then
  		local temp = self.support[4]
  		self.support[4] = nil
  		return temp
  	end
  end
  
  function Adv:supportEveryLayerAddEvent()
  	return self.support[5]
  end
  
  
  function Adv:isRunning()
  	if self.chapterId then return true end
  	return false
  end
  
70cc72d7   zhouhaihai   拾荒bug
413
414
415
  -- 强制结束  逻辑和adv内部无关
  function Adv:forceOver(notNotify, force)
  	if self:isRunning() or force then
9ced5432   zhouhaihai   冒险支援效果 保底事件
416
417
418
  		local advTeam = self.owner:getProperty("advTeam")
  		advTeam.player = nil
  
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
419
420
421
  		local advPotionCsv = csvdb["adv_potionCsv"]
  		local potionBag = self.owner:getProperty("potionBag")
  
9ced5432   zhouhaihai   冒险支援效果 保底事件
422
423
  		local reward = self.owner:getProperty("advItems"):toNumMap()
  		for itemId, count in pairs(reward) do
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
424
425
426
427
428
  			if advPotionCsv[itemId] then
  				potionBag[itemId] = (potionBag[itemId] or 0) + count
  			else
  				reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败
  			end
9ced5432   zhouhaihai   冒险支援效果 保底事件
429
  		end
67b46a6b   zhouhaihai   修复存在的冒险进不去的玩家
430
  		self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}, notNotify = notNotify})
9ced5432   zhouhaihai   冒险支援效果 保底事件
431
  
3133cb76   zhouhaihai   日志
432
  		self:clear()
9ced5432   zhouhaihai   冒险支援效果 保底事件
433
434
435
436
437
438
  		self.owner:updateProperties({
  			advInfo = {}, 
  			advTeam = advTeam,
  			advItems = "",
  			advAFGet = {},
  			advAFWear = {},
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
439
  			potionBag = potionBag,
9ced5432   zhouhaihai   冒险支援效果 保底事件
440
441
442
443
444
445
  		}, notNotify)
  	end
  end
  
  
  
f45d3a7b   zhouhaihai   adv_unlock
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
  -- 1=抵达x层;2=通关x层;3=完成指定事件;4=完成指定连锁事件
  function Adv:checkAdvUnlock(utype, value)
  	if not self.chapterId then return end
  	local chapter = self.chapterId % 100
  	local reward = {}
  	for id, data in pairs(csvdb["adv_unlockCsv"]) do
  		if data.chapterid == chapter and data.type == utype and value == data.value then
  			--0=立即获得;1=结算时获得
  			if data.time == 0 then
  				reward[data.itemid] = 1
  			elseif data.time == 1 then
  				table.insert(self.cacheUnlock, data.itemid)
  			end
  		end
  	end
  	if next(reward) then
3133cb76   zhouhaihai   日志
462
  		self.owner:award(reward, {log = {desc = "advUnlock", int1 = self.chapterId}})
f45d3a7b   zhouhaihai   adv_unlock
463
464
465
466
467
468
469
470
471
  	end
  end
  
  function Adv:clearAdvUnlockCache()
  	local reward = {}
  	for _, itemId in ipairs(self.cacheUnlock) do
  		reward[itemId] = 1
  	end
  	if next(reward) then
3133cb76   zhouhaihai   日志
472
  		self.owner:award(reward, {log = {desc = "advUnlock", int1 = self.chapterId}})
f45d3a7b   zhouhaihai   adv_unlock
473
474
475
476
  	end
  	self.cacheUnlock = {}
  end
  
a5660239   zhouhaihai   冒险bug
477
  function Adv:initBattle(info, isToNext)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
478
  	self.battle = require("adv.AdvBattle").new(self)
a5660239   zhouhaihai   冒险bug
479
480
481
482
483
484
485
486
487
488
489
490
  	-- 支援效果生效一些
  	self:activeSomeSupport()
  	
  	-- 不是中继层  加上 层 和 地图的buff和被动
  	if not self.isRelay then
  		self.battle:initMapEffect()
  	end
  
  	if isToNext then
  		self.battle.player:afterLayer() -- 玩家的buff 清理一下
  	end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
491
492
  	for _, passiveC in ipairs(self.cachePassiveEvent or {}) do
  		self.battle:triggerPassive(passiveC[1], passiveC[2])
46fac6f1   zhouahaihai   酱料
493
  	end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
494
  	self.cachePassiveEvent = {}
1313eac0   zhouhaihai   冒险的一些bug
495
496
497
498
499
  
  	-- after init battle
  	for idx, map in pairs(self.maps) do
  		map:initBattleAfter()
  	end
b71a8190   zhouhaihai   动态改变 一些buff
500
  	--下层
a5660239   zhouhaihai   冒险bug
501
  	if not info and isToNext then
b71a8190   zhouhaihai   动态改变 一些buff
502
503
  		self.battle.player:attrChangeCondBuffCheck(1)
  	end
a80fee7c   zhouhaihai   光环
504
505
  
  	-- 初始化
400f1f91   zhouhaihai   auras
506
  	if not info then
a80fee7c   zhouhaihai   光环
507
  		self.battle:newBattle()
400f1f91   zhouhaihai   auras
508
509
  	else
  		self.battle:loadBattle(info)
a80fee7c   zhouhaihai   光环
510
  	end
46fac6f1   zhouahaihai   酱料
511
512
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
513
514
515
516
517
518
519
  function Adv:triggerPassive(condType, params)
  	self.cachePassiveEvent = self.cachePassiveEvent or {}
  	if not self.battle then
  		table.insert(self.cachePassiveEvent, {condType, params})
  	else
  		self.battle:triggerPassive(condType, params)
  	end
46fac6f1   zhouahaihai   酱料
520
521
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
522
523
  function Adv:getCurMap()
  	return self.maps[self.mapStack[#self.mapStack]]
46fac6f1   zhouahaihai   酱料
524
525
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
526
527
  function Adv:getCurMapIdx()
  	return self.mapStack[#self.mapStack]
46fac6f1   zhouahaihai   酱料
528
529
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
530
531
532
533
534
  function Adv:getRoom(roomId, mapIdx)
  	mapIdx = mapIdx or self:getCurMapIdx()
  	local map = self.maps[mapIdx]
  	if map then
  		return map.rooms[roomId]
36c30c5c   zhouahaihai   冒险
535
  	end
46fac6f1   zhouahaihai   酱料
536
537
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
538
539
540
541
  function Adv:getBlock(roomId, blockId, mapIdx)
  	local room = self:getRoom(roomId, mapIdx)
  	if room then
  		return room.blocks[blockId]
c0b7797f   zhouhaihai   陷阱、点击生效点
542
  	end
46fac6f1   zhouahaihai   酱料
543
544
  end
  
ccbafe67   zhouhaihai   冒险神器和buff
545
546
547
548
549
550
551
  function Adv:isHaveArtifact(id)
  	return self.owner:getProperty("advAFGet")[id]
  end
  
  function Adv:awardArtifact(id, params)
  	if self:isHaveArtifact(id) then return end
  	self.owner:changeUpdates({{type = "advAFGet", field = id, value = 1}}, params.notNotify)
e852b350   zhouhaihai   冒险成就类型增加
552
  	self:checkAchievement(Adv.AchievType.GetMWeapon, 1, id)
3133cb76   zhouhaihai   日志
553
554
  
  
f22a33af   zhouhaihai   自己的日志
555
556
557
558
559
560
561
562
563
564
565
566
  	if params.log then
  		local log = clone(params.log)
  		if log["cint1"] or log["cint2"] or log["cint3"] then
  			print("awardArtifact error log have cint1 or cint2 or cint3 ", debug.traceback())
  		end
  		log["cint1"] = self.chapterId
  		log["cint2"] = self.level
  		log["cint3"] = id
  		self.owner:mylog("in_artifact", log)
  	else
  		print("awardArtifact no log ", debug.traceback())
  	end
bbb5f29a   zhouhaihai   冒险奖励神器
567
568
569
  	if not params.isChoose then
  		self:pushBackEvent(AdvBackEventType.Artifact, {id = id})
  	end
ccbafe67   zhouhaihai   冒险神器和buff
570
571
572
  end
  
  
56e2b75f   zhouhaihai   方法名错误
573
  function Adv:addArtifactEffect(effect)
ccbafe67   zhouhaihai   冒险神器和buff
574
575
576
577
578
579
580
581
582
583
  	for _, eff in ipairs(effect:toArray()) do
  		local etype, id = table.unpack(eff:toArray(true, "="))
  		if etype == 1 then
  			self.battle.player:addPassive({id = id})
  		elseif etype == 2 then
  			self.battle.player:addBuff(id)
  		end
  	end
  end
  
56e2b75f   zhouhaihai   方法名错误
584
  function Adv:delArtifactEffect(effect)
ccbafe67   zhouhaihai   冒险神器和buff
585
586
587
588
589
590
591
592
593
594
595
596
597
598
  	for _, eff in ipairs(effect:toArray()) do
  		local etype, id = table.unpack(eff:toArray(true, "="))
  		if etype == 1 then
  			self.battle.player:delPassiveById(id)
  		elseif etype == 2 then
  			self.battle.player:delBuffById(id)
  		end
  	end
  end
  
  function Adv:wearArtifact(slot, id)
  	local advAFGet = self.owner:getProperty("advAFGet")
  	local advAFWear = self.owner:getProperty("advAFWear")
  
c992c911   zhouhaihai   中继
599
600
601
602
603
604
  	if id == -1 then
  		if not advAFWear[slot] then return end
  	else
  		if not advAFGet[id] then return end
  	end
  
ccbafe67   zhouhaihai   冒险神器和buff
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
  	local curWear = {}
  	for _, _id in pairs(advAFWear) do
  		curWear[_id] = 1
  	end
  	if curWear[id] then return end
  
  	if advAFWear[slot] then
  		local oldData = csvdb["adv_artifactCsv"][advAFWear[slot]][advAFGet[advAFWear[slot]]]
  		self:delArtifactEffect(oldData.effect)
  		if oldData.comboId ~= 0 then
  			local comboData = csvdb["adv_artifact_comboCsv"][oldData.comboId]
  			if comboData then
  				local isHaveCombo = true
  				for _, _id in ipairs(comboData.artifactid:toArray(true)) do
  					if not curWear[_id] then
  						isHaveCombo = false
  						break
  					end
  				end
  				if isHaveCombo then
  					self:delArtifactEffect(comboData.effect)
  				end
  			end
  		end
  		curWear[advAFWear[slot]] = nil
  	end
  	
c992c911   zhouhaihai   中继
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
  	if id ~= -1 then
  		curWear[id] = 1
  		local newData = csvdb["adv_artifactCsv"][id][advAFGet[id]]
  		self:addArtifactEffect(newData.effect)
  
  		if newData.comboId ~= 0 then
  			local comboData = csvdb["adv_artifact_comboCsv"][newData.comboId]
  			if comboData then
  				local isHaveCombo = true
  				for _, _id in ipairs(comboData.artifactid:toArray(true)) do
  					if not curWear[_id] then
  						isHaveCombo = false
  						break
  					end
  				end
  				if isHaveCombo then
  					self:addArtifactEffect(comboData.effect)
ccbafe67   zhouhaihai   冒险神器和buff
649
  				end
ccbafe67   zhouhaihai   冒险神器和buff
650
651
  			end
  		end
c992c911   zhouhaihai   中继
652
653
  	else
  		id = nil
ccbafe67   zhouhaihai   冒险神器和buff
654
  	end
f22a33af   zhouhaihai   自己的日志
655
  	self:mylog({desc = "wearArtifact", int1 = id})
97807511   zhouhaihai   增加日志
656
657
658
659
660
661
662
663
664
  	self.owner:log("mission_pick_equip", {
  		mission_threadid = self.chapterId, -- 大地图ID
  		mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称
  		mission_id = self.level, -- 关卡ID
  		mission_pick_equip_type = 1, --神器操作类型:1:装备,2:卸下
  		mission_pick_equip_id = id, --神器ID
  		mission_pick_equip_lv = advAFGet[id], --神器等级
  		mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
  	})
46fac6f1   zhouahaihai   酱料
665
  
ccbafe67   zhouhaihai   冒险神器和buff
666
667
668
669
  	self.owner:changeUpdates({{type = "advAFWear", field = slot, value = id}})
  	return true
  end
  
e852b350   zhouhaihai   冒险成就类型增加
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
  -- 是否穿着指定神器
  function Adv:isWearAF(id)
  	local advAFWear = self.owner:getProperty("advAFWear")
  	for _, _id in pairs(advAFWear) do
  		if _id == id then
  			return true
  		end
  	end
  	return false
  end
  --是否激活指定神器套装
  function Adv:haveComboAF(id)
  	local advAFGet = self.owner:getProperty("advAFGet")
  	local advAFWear = self.owner:getProperty("advAFWear")
  	local curWear = {}
  	for _, _id in pairs(advAFWear) do
  		curWear[_id] = 1
  	end
  	for _, _id in pairs(advAFWear) do
  		local afData = csvdb["adv_artifactCsv"][_id][advAFGet[_id]]
  		if afData.comboId == id then
  			local comboData = csvdb["adv_artifact_comboCsv"][afData.comboId]
  			if comboData then
  				for _, _id2 in ipairs(comboData.artifactid:toArray(true)) do
  					if not curWear[_id2] then
  						return false
  					end
  				end
  				return true
  			end
  			return false
  		end
  	end
  	return false
  end
  
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
706
707
  function Adv:artifactLevelUp(id, level)
  	level = level or 1
ccbafe67   zhouhaihai   冒险神器和buff
708
  	local advAFGet = self.owner:getProperty("advAFGet")
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
709
  	if not advAFGet[id] then return end
ccbafe67   zhouhaihai   冒险神器和buff
710
  	local advAFWear = self.owner:getProperty("advAFWear")
e1355da3   zhouhaihai   神器 被动
711
712
713
714
  	local curWear = {}
  	for _, _id in pairs(advAFWear) do
  		curWear[_id] = 1
  	end
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
715
716
717
718
719
720
721
722
  	
  	local newLv = advAFGet[id]
  	for i = 1, level do
  		if not self.owner:isArtifactOpen(id, self:isEndless(), newLv + 1) then break end
  		newLv = newLv + 1
  	end
  	if newLv == advAFGet[id] then return end
  
f22a33af   zhouhaihai   自己的日志
723
724
  	self:mylog({desc = "artifactLevelUp", int1 = id, int2 = level})
  
ccbafe67   zhouhaihai   冒险神器和buff
725
  	local status = 0
e1355da3   zhouhaihai   神器 被动
726
  	if curWear[id] then -- 穿着呢
ccbafe67   zhouhaihai   冒险神器和buff
727
  		local oldData = csvdb["adv_artifactCsv"][id][advAFGet[id]]
e852b350   zhouhaihai   冒险成就类型增加
728
  		local newData = csvdb["adv_artifactCsv"][id][newLv]
ccbafe67   zhouhaihai   冒险神器和buff
729
730
731
732
  		self:delArtifactEffect(oldData.effect)
  		self:addArtifactEffect(newData.effect)
  		status = 1
  	end
e852b350   zhouhaihai   冒险成就类型增加
733
734
  	self.owner:changeUpdates({{type = "advAFGet", field = id, value = newLv}})
  	self:checkAchievement(Adv.AchievType.MWeaponLv, 1, id, newLv)
ccbafe67   zhouhaihai   冒险神器和buff
735
736
737
738
739
740
741
742
743
744
745
746
747
  	return status
  end
  
  function Adv:waitChooseArtifact()
  	local chooses = {}
  	local pool = {}
  	local count = 3  --需要多少个
  
  	for id, temp in pairs(csvdb["adv_artifactCsv"]) do
  		if not self:isHaveArtifact(id) and self.owner:isArtifactOpen(id, self:isEndless()) then
  			table.insert(pool, id)
  		end
  	end
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
748
  	if #pool == 0 then
3133cb76   zhouhaihai   日志
749
  		self:award({[ItemId.AdvPoint] = 48}, {log = {desc = "chooseArtifact"}})
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
750
751
  	else
  		for i = 1, math.min(count, #pool) do
ccbafe67   zhouhaihai   冒险神器和buff
752
753
754
755
  			local idx = math.randomInt(1, #pool)
  			table.insert(chooses, pool[idx])
  			table.remove(pool, idx)
  		end
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
756
757
  		self.waitArtifact = chooses
  		self:backChooseArtifact()
ccbafe67   zhouhaihai   冒险神器和buff
758
  	end
ccbafe67   zhouhaihai   冒险神器和buff
759
760
761
762
763
764
765
766
  end
  
  function Adv:isWaitChooseArtifact()
  	return self.waitArtifact
  end
  
  function Adv:chooseArtifact(index)
  	if not self.waitArtifact or not self.waitArtifact[index] then return end
bbb5f29a   zhouhaihai   冒险奖励神器
767
  	self:award({[self.waitArtifact[index]] = 1}, {log = {desc = "chooseArtifact"}, isChoose = true})
3133cb76   zhouhaihai   日志
768
  
f22a33af   zhouhaihai   自己的日志
769
770
  	self:mylog({desc = "chooseArtifact", int1 = self.waitArtifact[index]})
  
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
771
  	self.waitArtifact = nil
9ced5432   zhouhaihai   冒险支援效果 保底事件
772
773
774
775
  
  	-- 支援效果继续选择
  	self:supportChooseArtifact()
  
ccbafe67   zhouhaihai   冒险神器和buff
776
777
778
779
780
781
  	return true
  end
  
  function Adv:isEndless()
  	return AdvCommon.isEndless(self.chapterId)
  end
46fac6f1   zhouahaihai   酱料
782
  
43a6d57e   liuzujun   拾荒活动
783
784
785
786
  function Adv:isActivity()
  	return self.actid ~= nil
  end
  
eee37c88   zhouhaihai   楼层数据
787
  function Adv:getCurFloorData()
eee37c88   zhouhaihai   楼层数据
788
  	local chapter = self.chapterId % 100
bbf64622   zhouhaihai   冒险
789
  	return (csvdb["adv_chapter_floorCsv"][self.chapterId] or {})[self.level]
eee37c88   zhouhaihai   楼层数据
790
791
  end
  
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
792
  --关卡结束
bbf64622   zhouhaihai   冒险
793
  function Adv:over(success, rewardRatio, overType)
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
794
795
  	if success then 
  		rewardRatio = rewardRatio or 100
bbf64622   zhouhaihai   冒险
796
  		overType = overType or 0
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
797
798
  	else
  		rewardRatio = rewardRatio or globalCsv.adv_fail_reward_ratio
bbf64622   zhouhaihai   冒险
799
  		overType = overType or -1
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
800
  	end
bbf64622   zhouhaihai   冒险
801
802
  	local chapterData = csvdb["adv_chapterCsv"][self.chapterId]
  	-- 扣除的东西给积分
bbf64622   zhouhaihai   冒险
803
  	local addScore = 0
e22ded1b   zhouhaihai   被动技奖励
804
  	for itemId, count in pairs(self.owner:getProperty("advItems"):toNumMap()) do
bbf64622   zhouhaihai   冒险
805
  		local itemCsv = csvdb["itemCsv"][itemId]
3df73a9e   zhouhaihai   复兴奖励
806
807
808
  		if not itemCsv then
  			print("ERROR: no itemId in ItemCsv : ", itemId)
  		elseif itemCsv.type == ItemType.AdvItem then
bbf64622   zhouhaihai   冒险
809
  			addScore = addScore + count * itemCsv.advScore
bbf64622   zhouhaihai   冒险
810
  		end
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
811
  	end
bbf64622   zhouhaihai   冒险
812
813
814
815
  	self:scoreChange(AdvScoreType.ItemBack, addScore)
  
  	local score = self.owner:fixAdvScoreChange(self:getScore())
  	local scoreInfo = self.score
98be031a   liuzujun   新年活动
816
817
818
819
820
821
822
823
824
825
826
827
828
  
  	local scoreCoef = chapterData.scoreAward
  	local itemId = ItemId.OldCoin
  	-- 拾荒活动关卡相关处理
  	if self.actid then
  		while true do
  			if not self.owner.activity:isOpenById(self.actid, "AdvLevel") then 
  				break
  			end
  			local actCfg = csvdb["activity_adv_chapterCsv"][self.actid]
  			if not actCfg then break end
  			actCfg = actCfg[self.chapterId]
  			if not actCfg then break end
7cbf1146   liuzujun   去除advmap monster类型
829
830
  			local arr = actCfg["transform"]:toArray(true, "=")
  			itemId, scoreCoef = arr[1], arr[2]
98be031a   liuzujun   新年活动
831
832
833
  			local actData = self.owner.activity:getActData("AdvLevel")
  
  			-- 计算活动积分up
7f75dbc4   liuzujun   拾荒活动积分up
834
  			local upMap = actCfg["upCharacter"]:toNumMap()
98be031a   liuzujun   新年活动
835
836
837
838
839
840
841
842
843
844
  			local team = self.owner:getProperty("advTeam")
  			local format = self.owner:getTeamHerosInfo(team).heros
  			local upVal = 0
  			for _, hero in pairs(format) do
  				local heroId = hero["type"]
  				upVal = upVal + (upMap[heroId] or 0)
  			end
  			score = math.floor(score * (1 + upVal / 100))
  
  			local advInfo = actData[self.chapterId] or {}
7cbf1146   liuzujun   去除advmap monster类型
845
  			--print("upVal", upVal, score, advInfo["max"], itemId, scoreCoef)
98be031a   liuzujun   新年活动
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
  			local maxScore = advInfo["max"] or 0
  			local flag = false
  			if success then
  					advInfo["pass"] = 1
  					flag = true
  			end
  			-- 更新活动最大积分
  			if score > maxScore then
  				advInfo["max"] = score
  				actData[self.chapterId] = advInfo
  				flag = true
  			end
  			if flag then
  				self.owner.activity:updateActData("AdvLevel", actData)
  			end
  			break
  		end
  	end
bbf64622   zhouhaihai   冒险
864
  	
98be031a   liuzujun   新年活动
865
866
  	local scoreReward = math.floor(score / scoreCoef)
  	self.owner:award({[itemId] = scoreReward}, {log = {desc = "advOver", int1 = self.chapterId}})
bbf64622   zhouhaihai   冒险
867
  
e22ded1b   zhouhaihai   被动技奖励
868
  	-- 被动技会影响奖励
bbf64622   zhouhaihai   冒险
869
870
  	self.battle.player:triggerPassive(Passive.ADV_OVER, {score = score, level = self.level})
  
e22ded1b   zhouhaihai   被动技奖励
871
  	local reward = {}
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
872
873
  	local advPotionCsv = csvdb["adv_potionCsv"]
  	local potionBag = self.owner:getProperty("potionBag")
e22ded1b   zhouhaihai   被动技奖励
874
875
  	for itemId, count in pairs(self.owner:getProperty("advItems"):toNumMap()) do
  		local itemCsv = csvdb["itemCsv"][itemId]
1b08afa7   chenyueqi   修复拾荒结算时,返还药剂错误导致药...
876
877
878
  		if advPotionCsv[itemId] then
  			potionBag[itemId] = (potionBag[itemId] or 0) + count
  		elseif not itemCsv then
e22ded1b   zhouhaihai   被动技奖励
879
880
  			print("ERROR: no itemId in ItemCsv : ", itemId)
  		elseif itemCsv.type ~= ItemType.AdvItem then
1b08afa7   chenyueqi   修复拾荒结算时,返还药剂错误导致药...
881
  			reward[itemId] = math.ceil(count * rewardRatio / 100)
e22ded1b   zhouhaihai   被动技奖励
882
883
  		end
  	end
3133cb76   zhouhaihai   日志
884
  	reward = self.owner:award(reward, {log = {desc = "advOver", int1 = self.chapterId}})
e22ded1b   zhouhaihai   被动技奖励
885
  
ea40710f   zhouhaihai   活动
886
  	local backAdvCount
60fff866   zhouhaihai   微调 结算返还
887
  	if not self:isEndless() then
1fd96b9f   zhouhaihai   冒险次数返还
888
  		backAdvCount = math.floor((chapterData.limitlevel - self.level) / globalCsv.adv_daily_count_back_radio) *  globalCsv.adv_daily_count_back_radio
ea40710f   zhouhaihai   活动
889
  		self.owner:changeAdvCount(-backAdvCount)
60fff866   zhouhaihai   微调 结算返还
890
891
  	end
  
46fac6f1   zhouahaihai   酱料
892
  	if success then
53e8037e   zhouhaihai   任务
893
  		self.owner:checkTaskEnter("AdvPass", {id = self.chapterId, level = self.level, score = score})
bbf64622   zhouhaihai   冒险
894
895
  		
  		if not self:isEndless() and self.level >= chapterData.limitlevel then
53e8037e   zhouhaihai   任务
896
897
  			self.owner:checkTaskEnter("AdvAllPass", {id = self.chapterId})
  		end
9f135969   zhouhaihai   拾荒 失败也记录积分
898
  	end
b176d7d3   zhouhaihai   冒险成就
899
  
279a5773   zhouhaihai   Merge branch 'tr/...
900
  
9f135969   zhouhaihai   拾荒 失败也记录积分
901
902
  	local roleId = self.owner:getProperty("id")
  	local oldMaxScore = tonum(redisproxy:zscore(self.owner:getAdvRankKey(), roleId))
279a5773   zhouhaihai   Merge branch 'tr/...
903
  	if score > oldMaxScore and not self.actid then
9f135969   zhouhaihai   拾荒 失败也记录积分
904
905
906
907
908
909
910
911
912
913
914
915
916
  		local team = self.owner:getProperty("advTeam")
  		local curInfo = {
  			name = self.owner:getProperty("name"),
  			headId = self.owner:getProperty("headId"),
  			lv = self.owner:getProperty("level"),
  			batteV = self.owner:getTeamBattleValue(team.heros),
  			chapter = self.chapterId,
  			format = self.owner:getTeamHerosInfo(team).heros,
  		}
  		redisproxy:pipelining(function (red)
  			red:zadd(self.owner:getAdvRankKey(), score, roleId)	--更新分数
  			red:hset(RANK_ADV_INFO, roleId,  MsgPack.pack(curInfo))
  		end)
4bd10b43   chenyueqi   拾荒失败也要触发成就引导
917
  	end
9f135969   zhouhaihai   拾荒 失败也记录积分
918
  	
4bd10b43   chenyueqi   拾荒失败也要触发成就引导
919
920
921
  	-- 通关的时候要把引导步骤设定到成就引导
  	if not self.owner:checkOverGuide(57) then
  		self.owner:saveGuide(57,1,true)
46fac6f1   zhouahaihai   酱料
922
  	end
f45d3a7b   zhouhaihai   adv_unlock
923
  	self:clearAdvUnlockCache()
3133cb76   zhouhaihai   日志
924
  
f22a33af   zhouhaihai   自己的日志
925
926
  	self:mylog({desc = "over", short1 = success and 1 or 0, int1 = overType})
  
97807511   zhouhaihai   增加日志
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
  
  	local team = self.owner:getProperty("advTeam")
  	local player = {}
  	local attrs = self.owner:getTeamBattleInfo(team).heros
  	for attrName, _ in pairs(AdvAttsEnum) do
  		for _, hero in pairs(attrs) do
  			player[attrName] = (player[attrName] or 0) + hero[attrName]
  		end
  		player[attrName] = player[attrName] * (globalCsv.adv_battle_attr_ratio[attrName] or 1)
  	end
  
  	local battleV = 1 * player["hp"]
  		+ 2 * player["atk"]
  		+ 1.25 * player["def"]
  		+ 0.226 * player["hit"]
  		+ 0.26 * player["miss"]
  
  	local heroList = {team.leader, team.leader2}
  	for _, hid in pairs(team.heros) do
  		if hid ~= team.leader and hid ~= team.leader2 then
  			heroList[#heroList + 1] = hid
  		end
  	end
  
  	self.owner:log("mission_pick", {
  		mission_threadid = self.chapterId, -- 大地图ID
  		mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称
  		mission_id = self.level, -- 关卡ID
  		mission_herolist = heroList, -- 英雄ID列表,[111, 222, 333, 444, 555] 前两个为队长、副队长
  		mission_heroscore = battleV, -- 编队总评分
  		mission_teamlv = 0, -- 编队等级
  		mission_recscore = csvdb["adv_chapter_campsiteCsv"][self.chapterId][1].recommendValue, -- 关卡推荐评分
  		mission_floor_bef = 0, -- 进入前关卡层数
  		mission_floor_aft = self.level, -- 结束时关卡层数
  		mission_team_status = {HP = team.player.hp, SP = team.player.sp}, -- 队伍状态,{"HP":100, "SP":100, "curse":7}
  		mission_result = success and 1 or (team.player.hp > 0 and 3 or 2), -- 战斗结果(0-无效,1-胜利,2-血量耗尽退出,3,主动退出)
  		mission_reward = reward, -- 获得奖励,[{"id":101,"num":10},{"id":102,"num":20},{"id":103,"num":30}]
  		mission_integral_bef = 0, -- 进入前积分
  		mission_integral_aft = score, -- 完成后积分
  		mission_cleartype = 1, -- 1正常通关;2代理拾荒
  		mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
  	})
  
33be3111   zhouhaihai   修改hangPass 结构
970
  	local chapterId = self.chapterId
7cbf1146   liuzujun   去除advmap monster类型
971
  	local actid = self.actid
46fac6f1   zhouahaihai   酱料
972
  	self:clear()
89338c47   zhouhaihai   技能目标
973
  	self.owner:checkTaskEnter("AdvScore", {score = score})
00115a7a   zhouahaihai   奖励发放
974
  
1b20cfdb   zhouhaihai   赛季更新完善 无尽冒险排行榜
975
976
977
978
  	self.owner:updateProperties({
  		advItems = "",
  		advAFGet = {},
  		advAFWear = {},
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
979
  		potionBag = potionBag,
1b20cfdb   zhouhaihai   赛季更新完善 无尽冒险排行榜
980
  	})
ea40710f   zhouhaihai   活动
981
982
983
984
985
986
  	self:pushBackEvent(AdvBackEventType.End, {
  		success = success,
  		score = score,
  		scoreInfo = scoreInfo,
  		reward = reward,
  		type = overType,
be4e8031   zhouhaihai   活动 拾荒
987
  		scoreAward = scoreReward,
ea40710f   zhouhaihai   活动
988
989
  		chapterId = chapterId,
  		backAdvCount = backAdvCount,
7cbf1146   liuzujun   去除advmap monster类型
990
  		actid = actid
ea40710f   zhouhaihai   活动
991
  	})
46fac6f1   zhouahaihai   酱料
992
993
  end
  
ec87b4a5   zhouahaihai   冒险 完善
994
  function Adv:exit()
4b7c7c96   zhouahaihai   增加 清空 挂机 冒险gm 角色经验
995
  	self:over(false)
ec87b4a5   zhouahaihai   冒险 完善
996
997
998
  	self:saveDB()
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
999
1000
1001
1002
1003
  function Adv:randomMapId(chapterId, level)
  	local chapterData = csvdb["adv_chapterCsv"][chapterId]
  	if not chapterData then 
  		error("chapterId " .. chapterId .. " dont exist!")
  		return 
46fac6f1   zhouahaihai   酱料
1004
  	end
8da953a7   zhouhaihai   无尽模式
1005
  	if AdvCommon.isEndless(chapterId) then
916096ed   zhouhaihai   神器效果
1006
  		level = AdvCommon.getEndlessDataLv(chapterId, level)
8da953a7   zhouhaihai   无尽模式
1007
1008
1009
1010
1011
  	else
  		if level > chapterData.limitlevel then 
  			error("level overflow!")
  			return 
  		end
46fac6f1   zhouahaihai   酱料
1012
  	end
8da953a7   zhouhaihai   无尽模式
1013
  	
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1014
1015
  	--随出地图Id
  	local raw_pool = chapterData.mapid:toArray(true, "=")
46fac6f1   zhouahaihai   酱料
1016
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1017
1018
1019
  	local lastMapIds = {}
  	for id, map in ipairs(self.maps or {}) do
  		lastMapIds[map.mapId] = 1
46fac6f1   zhouahaihai   酱料
1020
  	end
02c4de8d   zhouahaihai   增加 固有技
1021
  	
46fac6f1   zhouahaihai   酱料
1022
  	local pool = {}
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1023
1024
1025
1026
  	for _, mapId in ipairs(raw_pool) do
  		local temp = csvdb["mapCsv"][mapId]
  		if temp and not lastMapIds[mapId] then
  			if AdvCommon.checkIsIn(level, temp.leveltype, temp.levellimit) then
cfc7a04a   zhouhaihai   map id 提供随机概率调整
1027
  				pool[mapId] = {showup = temp.showup}
46fac6f1   zhouahaihai   酱料
1028
1029
1030
  			end
  		end
  	end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1031
1032
1033
  	if not next(pool) then 
  		error("mapIds is empty!")
  		return 
46fac6f1   zhouahaihai   酱料
1034
  	end
cfc7a04a   zhouhaihai   map id 提供随机概率调整
1035
  	return math.randWeight(pool, "showup")
46fac6f1   zhouahaihai   酱料
1036
1037
  end
  
3f00afcf   zhouhaihai   增加日志
1038
  -- log long1 字段被征用!!!
46fac6f1   zhouahaihai   酱料
1039
  -- 在冒险中获得的物品都发放在冒险背包内
8955225b   zhouhaihai   快速拾取。快速使用
1040
  function Adv:award(gift, params, backRewardParams)
8c199cec   zhengshouren   简化物品奖励接口,设置默认参数
1041
  	params = params or {}
46fac6f1   zhouahaihai   酱料
1042
1043
1044
1045
1046
1047
1048
1049
1050
  	local tgift = {}
  	if type(gift) == "string" then
  		for _, one in pairs(gift:toTableArray(true)) do
  			tgift[one[1]] = (tgift[one[1]] or 0) + one[2]
  		end
  	else
  		tgift = gift
  	end
  	local items = self.owner:getProperty("advItems")
ccbafe67   zhouhaihai   冒险神器和buff
1051
  	local oldItems = items
8955225b   zhouhaihai   快速拾取。快速使用
1052
1053
  
  	local autoUse = {}
46fac6f1   zhouahaihai   酱料
1054
  	for itemId, count in pairs(tgift) do
47c6253a   zhouhaihai   bugfix
1055
  		if count > 0 and self.battle.player then
ccbafe67   zhouhaihai   冒险神器和buff
1056
  			local buffAdd = self.battle.player:getRewardChange(itemId)
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
1057
  			count = math.floor(math.max(0, (count + buffAdd[0]) * (1 + buffAdd[1]))) --附加 buff 的影响
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
1058
  			self:checkTask(Adv.TaskType.Item, count, itemId)
b176d7d3   zhouhaihai   冒险成就
1059
  			self:checkAchievement(Adv.AchievType.GetItem, count, itemId)
b0fe1817   zhouahaihai   冒险分数
1060
  		end
ccbafe67   zhouhaihai   冒险神器和buff
1061
  		tgift[itemId] = count
8955225b   zhouhaihai   快速拾取。快速使用
1062
1063
  		if globalCsv.adv_auto_useItem[itemId] and count > 0 then
  			autoUse[itemId] = count
ccbafe67   zhouhaihai   冒险神器和buff
1064
  		else
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1065
1066
  			local transId = globalCsv.adv_item_potion[itemId] or itemId
  			local origin = items:getv(transId, 0)
8955225b   zhouhaihai   快速拾取。快速使用
1067
1068
1069
1070
1071
1072
1073
  			local nums = origin + count
  
  			if csvdb["adv_artifactCsv"][itemId] then -- 获得神器
  				self:awardArtifact(itemId, params)
  				if not self.owner:checkOverGuide(55) then
  					self.owner:saveGuide(55,1,true)
  				end
ccbafe67   zhouhaihai   冒险神器和buff
1074
  			else
8955225b   zhouhaihai   快速拾取。快速使用
1075
  				if nums <= 0 then
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1076
  					items = items:delk(transId)
8955225b   zhouhaihai   快速拾取。快速使用
1077
1078
  					nums = 0
  				else
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1079
  					items = items:setv(transId, nums)
8955225b   zhouhaihai   快速拾取。快速使用
1080
  				end
3133cb76   zhouhaihai   日志
1081
  
8955225b   zhouhaihai   快速拾取。快速使用
1082
1083
  				if itemId == 16 and not self.owner:checkOverGuide(51,4) then
  					self.owner:saveGuide(51,4)
f22a33af   zhouhaihai   自己的日志
1084
  				end
8955225b   zhouhaihai   快速拾取。快速使用
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
  				if params.log then
  					local log = clone(params.log)
  					if log["cint1"] or log["cint2"] or log["cint3"] or log["long1"] then
  						print("addAdvItem error log have cint1 or cint2 or cint3 ", debug.traceback())
  					end
  					log["cint1"] = itemId
  					log["cint2"] = math.abs(count)
  					log["cint3"] = self.chapterId
  					log["long1"] = self.level
  					if count >= 0 then
  						self.owner:mylog("in_adv", log)
  					else
  						self.owner:mylog("out_adv", log)
  					end
f22a33af   zhouhaihai   自己的日志
1099
  				else
8955225b   zhouhaihai   快速拾取。快速使用
1100
  					print("addAdvItem no log ", debug.traceback())
f22a33af   zhouhaihai   自己的日志
1101
  				end
f22a33af   zhouhaihai   自己的日志
1102
  			end
916096ed   zhouhaihai   神器效果
1103
1104
  		end
  	end
ccbafe67   zhouhaihai   冒险神器和buff
1105
1106
1107
  	if items ~= oldItems then
  		self.owner:updateProperty({field = "advItems", value = items, notNotify = params.notNotify})
  	end
b71a8190   zhouhaihai   动态改变 一些buff
1108
1109
1110
1111
  
  	if tgift[ItemId.OldCoin] then
  		self.battle.player:attrChangeCondBuffCheck(0)
  	end
8955225b   zhouhaihai   快速拾取。快速使用
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
  
  	if backRewardParams then
  		self:backReward(tgift, backRewardParams)
  	end
  
  	if next(autoUse) then
  		for itemId, count in pairs(autoUse) do
  			self:useItem(itemId, count)
  		end
  		self:backUse(autoUse, 1)
  	end
ccbafe67   zhouhaihai   冒险神器和buff
1123
  	return tgift
916096ed   zhouhaihai   神器效果
1124
1125
1126
  end
  
  
8955225b   zhouhaihai   快速拾取。快速使用
1127
1128
1129
1130
1131
1132
1133
  function Adv:useItem(itemId, count, target)
  	local itemData = csvdb["adv_itemCsv"][itemId] 
  	if not itemData then return end
  
  	if itemData["function"] == 0 or itemData["function"] == 2 then count = 1 end
  
  	if itemId == 5020 then
505479c7   zhouhaihai   bug
1134
  		self.owner:finishGuide(53)
8955225b   zhouhaihai   快速拾取。快速使用
1135
1136
1137
  	end
  
  	self:checkAchievement(self.AchievType.UseItem, count, itemId)
7b570ef2   liuzujun   新春活动任务
1138
  	self.owner:checkTaskEnter("AdvUseItem", {itemId = itemId, count = count})
8955225b   zhouhaihai   快速拾取。快速使用
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
  	self:mylog({desc = "useItem", int1 = itemId, int2 = count})
  
  	self.owner:log("mission_pick_use", {
  		mission_threadid = self.chapterId, -- 大地图ID
  		mission_threadname = (csvdb["adv_chapterCsv"][self.chapterId] or {})["chapter"] or "auto", -- 大地图名称
  		mission_id = self.level, -- 关卡ID
  		item_id = itemId, -- 道具ID
  		mission_pick_use_num = count, -- 道具使用量
  		mission_sequenceid = self.logid, -- 本次拾荒ID,用于关联一次拾荒产生多条不同类型的日志
  	})
  
  	for i = 1, count do
  		self:doActive(itemData.effect, target) -- target
  	end
  end
  
46fac6f1   zhouahaihai   酱料
1155
1156
1157
  -- 消耗物品 优先冒险背包  --check 只是检查够不够
  function Adv:cost(item, params, check)
  	local items = self.owner:getProperty("advItems")
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1158
  	local potionCsv = csvdb["adv_potionCsv"]
46fac6f1   zhouahaihai   酱料
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
  	local less = {}
  	local advCost = {}
  	for itemId, count in pairs(item) do
  		advCost[itemId] = - math.min(items:getv(itemId, 0), count)
  		if advCost[itemId] == 0 then
  			advCost[itemId] = nil
  		end
  
  		local last = items:getv(itemId, 0) - count
  		if last < 0 then
  			less[itemId] = -last
  		end
  
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1172
1173
1174
  		if potionCsv[itemId] and last < 0 then -- 只能使用冒险背包里的药水
  			return
  		end
46fac6f1   zhouahaihai   酱料
1175
1176
1177
  	end
  	if next(less) and not self.owner:checkItemEnough(less) then return end --不够
  	if check then return true end
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1178
  
46fac6f1   zhouahaihai   酱料
1179
  	self:award(advCost, params)
ccbafe67   zhouhaihai   冒险神器和buff
1180
1181
1182
  	if next(less) then
  		self.owner:costItems(less, params)
  	end
46fac6f1   zhouahaihai   酱料
1183
1184
1185
  	return true
  end
  
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1186
1187
1188
1189
1190
  -- 补满冒险背包药剂,从药剂背包扣除药水放到冒险背包
  function Adv:supplyPotion()
  	local potionCsv = csvdb["adv_potionCsv"]
  	local potionBag = self.owner:getProperty("potionBag")
  	local advItems = self.owner:getProperty("advItems")
c32be356   chenyueqi   进入拾荒自动补给药水,按当前等级下...
1191
  	local dishTree = self.owner.dinerData:getProperty("dishTree")
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1192
1193
1194
  	for potionId, set in pairs(potionCsv) do
  		local count = potionBag[potionId] or 0
  		if count > 0 then
4122c3bd   chenyueqi   进入中继层补给药剂,补足到上限,扣除错误
1195
1196
1197
1198
  			local max = set[dishTree:getv(potionId,1)].limit
  			local old = advItems:getv(potionId,0)
  			local need = max - old
  
5470c530   chenyueqi   先判断药水补给的数量是否大于0
1199
1200
  			if need < 0 then
  			elseif need < count then
4122c3bd   chenyueqi   进入中继层补给药剂,补足到上限,扣除错误
1201
1202
  				advItems = advItems:setv(potionId,max)
  				potionBag[potionId] = count - need
4122c3bd   chenyueqi   进入中继层补给药剂,补足到上限,扣除错误
1203
1204
1205
1206
  			else
  				advItems = advItems:setv(potionId,old + count)
  				potionBag[potionId] = nil
  			end
0027e33b   chenyueqi   调理剂生产和使用逻辑优化
1207
1208
1209
1210
1211
1212
1213
1214
  		end
  	end
  	self.owner:updateProperties({
  		advItems = advItems,
  		potionBag = potionBag,
  	})
  end
  
46fac6f1   zhouahaihai   酱料
1215
  --事件点击处理
74a8fdc9   zhouhaihai   奖励副本 胜利扣除次数
1216
  local function clickOut(self, room, block, params, isExit)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1217
  	if self:getCurMap():checkOver() then --检查是否可以出去了
74a8fdc9   zhouhaihai   奖励副本 胜利扣除次数
1218
1219
1220
1221
1222
  		if isExit then
  			self:over(true)
  			return true
  		end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1223
  		if #self.mapStack > 1 then -- 处于夹层中
96018793   zhouhaihai   layer change
1224
  			self:backLayer(-1)
a80fee7c   zhouhaihai   光环
1225
  			local oldMapIdx = self:getCurMapIdx()
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1226
  			table.remove(self.mapStack) --退出夹层
a80fee7c   zhouhaihai   光环
1227
  			self.battle:iLayerChange(oldMapIdx)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1228
  		else --处于底层
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
1229
1230
  
  			local advPass = self.owner:getProperty("advPass")
4d943586   zhouhaihai   直通 advt gm
1231
  
ccbafe67   zhouhaihai   冒险神器和buff
1232
  			if self:isEndless() then
8da953a7   zhouhaihai   无尽模式
1233
1234
1235
1236
1237
1238
1239
  				-- 刷新最高层
  				if self.owner:getProperty("advElM") < self.level then
  					self.owner:updateProperty({field = "advElM", value = self.level})
  				end
  			else
  				if self.level > (advPass[self.chapterId] or 0) then
  					self.owner:changeUpdates({{type = "advPass", field = self.chapterId, value = self.level}})
0c54995a   liuzujun   第一次通关拾荒章节推送限时礼包,活...
1240
1241
1242
1243
1244
  
  				if (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel) then --关卡结束
  					self.owner:checkTaskEnter("AdvPassFirst", {id = self.chapterId})
  				end
  
8da953a7   zhouhaihai   无尽模式
1245
  				end
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
1246
  			end
0e3ab88d   zhouhaihai   中继层
1247
  
b176d7d3   zhouhaihai   冒险成就
1248
  			self:checkAchievement(Adv.AchievType.OverWin, 1, self.level)
f45d3a7b   zhouhaihai   adv_unlock
1249
  			self:checkAdvUnlock(2, self.level)
0e3ab88d   zhouhaihai   中继层
1250
  
bbf64622   zhouhaihai   冒险
1251
1252
1253
1254
1255
  			local curFloorData = self:getCurFloorData()
  			if not self.isRelay then
  				self:scoreChange(AdvScoreType.Level, curFloorData.advScore) --增加层级加分
  			end
  
e51ff6d2   zhouhaihai   冒险~
1256
  			if not self:isEndless() and (self.level >= csvdb["adv_chapterCsv"][self.chapterId].limitlevel) then --关卡结束
f2648427   zhouhaihai   修改中继营地解锁条件
1257
  				self:passAdvRelay()
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
1258
  				self:over(true)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1259
  			else
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
1260
  				self.battle.player:triggerPassive(Passive.DOWN_LAYER)
bbf64622   zhouhaihai   冒险
1261
  				
eee37c88   zhouhaihai   楼层数据
1262
  				if curFloorData then
8955225b   zhouhaihai   快速拾取。快速使用
1263
  					self:award({[ItemId.AdvPoint] = curFloorData.exp}, {log = {desc = "passReward", int1 = self.chapterId, int2 = self.level}}, {})
eee37c88   zhouhaihai   楼层数据
1264
  				end
76c48085   zhouhaihai   下一关提前
1265
  				self:backNext() --下一关
0e3ab88d   zhouhaihai   中继层
1266
  				local isHaveRelay = self:isHaveRelay(self.level)
0e3ab88d   zhouhaihai   中继层
1267
  				if isHaveRelay and not self.isRelay then 
35e2e3c4   zhouhaihai   优化 gm advt 增加感知b...
1268
1269
1270
1271
1272
1273
1274
  					self:initByChapter({
  						chapterId = self.chapterId, 
  						level = self.level, 
  						isToNext = true, 
  						notNotify = true, 
  						isRelay = true,
  					})
0e3ab88d   zhouhaihai   中继层
1275
  				else
f22a33af   zhouhaihai   自己的日志
1276
  					self:mylog({desc = "pass"})
35e2e3c4   zhouhaihai   优化 gm advt 增加感知b...
1277
1278
1279
1280
1281
1282
  					self:initByChapter({
  						chapterId = self.chapterId, 
  						level = self.level + 1, 
  						isToNext = true, 
  						notNotify = true,
  					})
0e3ab88d   zhouhaihai   中继层
1283
  				end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1284
  			end
b176d7d3   zhouhaihai   冒险成就
1285
  
46fac6f1   zhouahaihai   酱料
1286
  		end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1287
  		
46fac6f1   zhouahaihai   酱料
1288
1289
1290
1291
  		return true
  	end
  end
  
0e3ab88d   zhouhaihai   中继层
1292
  local function clickExit(self, room, block, params)
74a8fdc9   zhouhaihai   奖励副本 胜利扣除次数
1293
  	return clickOut(self, room, block, params, true)
0e3ab88d   zhouhaihai   中继层
1294
1295
  end
  
46fac6f1   zhouahaihai   酱料
1296
1297
  --战斗 普通攻击
  local function clickMonster(self, room, block, params)
12f7b52c   zhouhaihai   冒险战斗
1298
  	self.battle:battleBegin(room.roomId, block.blockId, params)
46fac6f1   zhouahaihai   酱料
1299
1300
1301
  	return true
  end
  
46fac6f1   zhouahaihai   酱料
1302
  
219e9654   zhouhaihai   拾荒增加选择类型
1303
1304
  local function checkChooseCondFunc(self, condStr, room, block, tag, chooseData)
  	chooseData = chooseData or {}
46fac6f1   zhouahaihai   酱料
1305
  	local checkCond = {
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1306
1307
1308
1309
  		-- 没有条件
  		[0] = function()
  			return true
  		end,
46fac6f1   zhouahaihai   酱料
1310
  		-- 拥有道具
219e9654   zhouhaihai   拾荒增加选择类型
1311
  		[1] = function(itemId, count)
498f0eb2   zhouhaihai   冒险 action
1312
  			if self:cost({[itemId] = count}, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, true) then
46fac6f1   zhouahaihai   酱料
1313
1314
1315
1316
  				return true
  			end
  		end,
  		-- xx角色(todo 队长)
219e9654   zhouhaihai   拾荒增加选择类型
1317
  		[2] = function(heroType)
9d66362c   zhouhaihai   修改冒险选择条件
1318
1319
1320
1321
1322
  			for slot, heroId in pairs(self.owner:getProperty("advTeam").heros) do
  				local hero = self.owner.heros[heroId]
  				if hero and hero:getProperty("type") == heroType then
  					return true
  				end 
46fac6f1   zhouahaihai   酱料
1323
1324
1325
1326
  			end
  		end,
  		--消灭所有怪
  		[3] = function()
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1327
  			for _, room in pairs(self:getCurMap().rooms) do
4ae223df   zhouahaihai   Buff bug
1328
  				for _, block in pairs(room.blocks) do
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1329
  					if block:isMonster() then
46fac6f1   zhouahaihai   酱料
1330
1331
1332
1333
1334
1335
  						return
  					end
  				end
  			end
  			return true
  		end,
53e8037e   zhouhaihai   任务
1336
  		--制定属性 
219e9654   zhouhaihai   拾荒增加选择类型
1337
  		[4] = function(attrType, value)
1229c24d   zhouhaihai   新加选择条件
1338
  			if (self.battle.player[AttsEnumEx[attrType]] or 0) >= value then
46fac6f1   zhouahaihai   酱料
1339
1340
1341
  				return true
  			end
  		end,
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1342
  		-- 提交一个物品
219e9654   zhouhaihai   拾荒增加选择类型
1343
  		[5] = function (itemId, count)
498f0eb2   zhouhaihai   冒险 action
1344
  			if self:cost({[itemId] = count}, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}) then
1229c24d   zhouhaihai   新加选择条件
1345
  				self:backCost({[itemId] = count})
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1346
1347
1348
  				return true
  			end
  		end,
53e8037e   zhouhaihai   任务
1349
  		-- sp 到达指定值
219e9654   zhouhaihai   拾荒增加选择类型
1350
  		[6] = function(value)
1229c24d   zhouhaihai   新加选择条件
1351
  			if self.battle.player.sp >= value then
b8eb016b   zhouhaihai   冒险条件扣血扣蓝直接作用
1352
  				self.battle.player:changeSp(-value)
53e8037e   zhouhaihai   任务
1353
1354
1355
  				return true
  			end
  		end,
1229c24d   zhouhaihai   新加选择条件
1356
  		--7=拥有指定buff指定层数
219e9654   zhouhaihai   拾荒增加选择类型
1357
  		[7] = function(buffId, layer)
1229c24d   zhouhaihai   新加选择条件
1358
1359
  			local buff = self.battle.player:getBuffById(buffId)
  			if buff and buff:getLayer() >= layer then
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1360
1361
1362
  				return true
  			end
  		end,
1229c24d   zhouhaihai   新加选择条件
1363
  		--8=拥有x神器
219e9654   zhouhaihai   拾荒增加选择类型
1364
  		[8] = function(artifactId)
1229c24d   zhouhaihai   新加选择条件
1365
1366
1367
  			return self:isHaveArtifact(artifactId)
  		end,
  		-- 9 = 生命值大于x%
219e9654   zhouhaihai   拾荒增加选择类型
1368
  		[9] = function (value)
b8eb016b   zhouhaihai   冒险条件扣血扣蓝直接作用
1369
1370
1371
1372
1373
  			local cost = value / 100 * self.battle.player.hpMax
  			if self.battle.player.hp > cost then
  				self.battle.player:hurt(cost, nil, {hurtType = 6, buffId = -1})
  				return true
  			end
1229c24d   zhouhaihai   新加选择条件
1374
  		end,
f02ffa27   zhouhaihai   未获得神器
1375
  		-- 10 = 未获得x神器
219e9654   zhouhaihai   拾荒增加选择类型
1376
  		[10] = function(artifactId)
f02ffa27   zhouhaihai   未获得神器
1377
1378
  			return not self:isHaveArtifact(artifactId)
  		end,
cb071e8d   zhouhaihai   多条件选项
1379
  		-- 11 = 地图上没有指定id 的怪
219e9654   zhouhaihai   拾荒增加选择类型
1380
  		[11] = function(monsterId, size)
b23cd820   zhouhaihai   查询角色
1381
1382
1383
1384
  			if not size or size == 0 then
  				for _, room in pairs(self:getCurMap().rooms) do
  					for _, block in pairs(room.blocks) do
  						if block:isMonster() then
667bd98b   zhouhaihai   增加 0 的判断
1385
  							if not monsterId or monsterId == 0 then return false end
b23cd820   zhouhaihai   查询角色
1386
1387
1388
1389
1390
1391
1392
1393
1394
  							if block.event.id == monsterId then
  								return false
  							end
  						end
  					end
  				end
  			else
  				for _, cblock in ipairs(self:getCurMap():getBlocksBySize(room.roomId, block.blockId, size)) do
  					if cblock:isMonster() then
667bd98b   zhouhaihai   增加 0 的判断
1395
  						if not monsterId or monsterId == 0 then return false end
b23cd820   zhouhaihai   查询角色
1396
  						if cblock.event.id == monsterId then
cb071e8d   zhouhaihai   多条件选项
1397
1398
1399
1400
1401
1402
1403
1404
  							return false
  						end
  					end
  				end
  			end
  			return true
  		end,
  		-- 12 = 地图上没有指定id 的建筑
219e9654   zhouhaihai   拾荒增加选择类型
1405
  		[12] = function(buildId, size)
b23cd820   zhouhaihai   查询角色
1406
1407
1408
1409
  			if not size or size == 0 then
  				for _, room in pairs(self:getCurMap().rooms) do
  					for _, block in pairs(room.blocks) do
  						if block:isBuild() then
667bd98b   zhouhaihai   增加 0 的判断
1410
  							if not buildId or buildId == 0 then return false end
b23cd820   zhouhaihai   查询角色
1411
1412
1413
1414
1415
1416
1417
1418
1419
  							if block.event.id == buildId then
  								return false
  							end
  						end
  					end
  				end
  			else
  				for _, cblock in ipairs(self:getCurMap():getBlocksBySize(room.roomId, block.blockId, size)) do
  					if cblock:isBuild() then
667bd98b   zhouhaihai   增加 0 的判断
1420
  						if not buildId or buildId == 0 then return false end
b23cd820   zhouhaihai   查询角色
1421
  						if cblock.event.id == buildId then
cb071e8d   zhouhaihai   多条件选项
1422
1423
1424
1425
1426
1427
1428
1429
  							return false
  						end
  					end
  				end
  			end
  			return true
  		end,
  		-- 13 = 地图上没有指定的 选择点
219e9654   zhouhaihai   拾荒增加选择类型
1430
  		[13] = function(chooseId, size)
b23cd820   zhouhaihai   查询角色
1431
1432
1433
1434
  			if not size or size == 0 then
  				for _, room in pairs(self:getCurMap().rooms) do
  					for _, block in pairs(room.blocks) do
  						if block:isChoose() then
667bd98b   zhouhaihai   增加 0 的判断
1435
  						if not chooseId or chooseId == 0 then return false end
b23cd820   zhouhaihai   查询角色
1436
1437
1438
1439
1440
1441
1442
1443
1444
  							if block.event.id == chooseId then
  								return false
  							end
  						end
  					end
  				end
  			else
  				for _, cblock in ipairs(self:getCurMap():getBlocksBySize(room.roomId, block.blockId, size)) do
  					if cblock:isChoose() then
667bd98b   zhouhaihai   增加 0 的判断
1445
  						if not chooseId or chooseId == 0 then return false end
b23cd820   zhouhaihai   查询角色
1446
  						if cblock.event.id == chooseId then
cb071e8d   zhouhaihai   多条件选项
1447
1448
1449
1450
1451
1452
1453
  							return false
  						end
  					end
  				end
  			end
  			return true
  		end,
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1454
   	}
219e9654   zhouhaihai   拾荒增加选择类型
1455
1456
1457
  
   	local status, count = true, 0
   	for _, cond in ipairs(condStr:toTableArray(true)) do
cb071e8d   zhouhaihai   多条件选项
1458
   		assert(not cond[1] or checkCond[cond[1]], "error cond, event_" .. (tag or "choose") .. "Csv id :" .. block.event.id)
219e9654   zhouhaihai   拾荒增加选择类型
1459
1460
1461
1462
1463
  		if not checkCond[cond[1]](select(2, table.unpack(cond))) then 
  			status =  false
  		else
  			count = count + 1
  		end
cb071e8d   zhouhaihai   多条件选项
1464
   	end
219e9654   zhouhaihai   拾荒增加选择类型
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
   	return status, count
  end
  
  local function doChooseEffect(self, effectStr, room, block, tag, chooseData)
  	chooseData = chooseData or {}
  	local clearBlock = true
  	local doEffect = {
  		[1] = function(dropId, count) -- 获得某道具N个
  			count = count or 1
  			local reward = {}
  			for i = 1, count do
  				local dropData = csvdb["event_dropCsv"][dropId]
  				if dropData then
  					local item = dropData["range"]:randWeight(true)
4b34fee8   zhouhaihai   增加~= 0 判定
1479
1480
1481
  					if item[1] ~= 0 then
  						reward[item[1]] = (reward[item[1]] or 0) + item[2]
  					end
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1482
  				else
219e9654   zhouhaihai   拾荒增加选择类型
1483
  					skynet.error(string.format("[ERROR]: event_dropCsv no id %s in %s id: %s",  dropId, tag, chooseData.id))
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1484
  				end
219e9654   zhouhaihai   拾荒增加选择类型
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
  			end
  			self:award(reward, {log = {desc = "chooseEvent", key1 = tag, int1 = chooseData.id}}, {roomId = room.roomId, blockId = block.blockId})
  		end,
  		[2] = function(buffId, layer) --获得冒险buff
  			self.battle.player:addBuff(buffId, nil, layer or 1)
  		end,
  		[3] = function(id) --发现怪物
  			self:getCurMap():addNewMonsterRand(id, {room, block})
  			self:pushBackEvent(AdvBackEventType.Monster, {id = id})
  			clearBlock = false
  		end,
  		[4] = function() --无事发生
  		end,
  		[5] = function(addType, attrType, value) --5=属性枚举=数值;直接增加玩家属性
  			local attr
  			if attrType == 0 then
  				attr = "sp"
  			else
  				attr = AttsEnumEx[attrType]
  				if not AdvAttsEnum[attr] then return end
  			end
  			self.battle.player:addBaseAttr(attr, value, addType)
  		end,
  		[6] = function(id) -- 商店
  			block:updateEvent({
  				etype = AdvEventType.Trader,
  				id = id
  			})
  			self:pushBackEvent(AdvBackEventType.Trader, {id = id})
  			clearBlock = false
  		end,
  		[7] = function(id) -- 建筑
  			block:updateEvent({
  				etype = AdvEventType.Build,
  				id = id
  			})
  			clearBlock = false
  		end,
  		[8] = function(id) -- 选择
  			block:updateEvent({
  				etype = AdvEventType.Choose,
  				id = id
  			})
  			clearBlock = false
  		end,
  		[9] = function(id) -- click
  			block:updateEvent({
  				etype = AdvEventType.Click,
  				id = id
  			})
  			clearBlock = false
  		end,
  		[10] = function(id) -- 陷阱
  			block:updateEvent({
  				etype = AdvEventType.Trap,
  				id = id
  			})
  			clearBlock = false
  		end,
  		[11] = function()  -- 获得神器
  			self:waitChooseArtifact() --等待获取神器
  		end,
  		[12] = function(id)
  			-- buffId
  			local targers = self.battle.player:getTeam(2, nil, nil, true)
  			for _, target in pairs(targers) do
  				target:addBuff(id)
  			end
  		end,
  		[13] = function() -- 显示地图
  			self:getCurMap():showMap()
  			self:backMapShow()
  		end,
  		[14] = function(eventType, eventId, count, stage) -- 指定地块召唤 指定类型的id
  			local change = self:getCurMap():layEventToStage(eventType, eventId, count, stage)
  			for _, one in ipairs(change) do
  				if one[1].roomId == room.roomId and  one[2].blockId == block.blockId then
  					clearBlock = false
  				else
  					self:backBlockChange(one[1].roomId, one[2].blockId)
031dcf99   zhouhaihai   修改战斗属性计算 冒险增加效果类型
1565
  				end
219e9654   zhouhaihai   拾荒增加选择类型
1566
1567
1568
1569
1570
1571
1572
1573
1574
  			end
  		end,
  		[15] = function(eventType, eventId, count) -- 移除指定事件
  			local change = self:getCurMap():clearEventById(eventType, eventId, count)
  			for _, one in ipairs(change) do
  				if one[1].roomId == room.roomId and  one[2].blockId == block.blockId then
  					clearBlock = false
  				else
  					self:backBlockChange(one[1].roomId, one[2].blockId)
2d87caee   zhouhaihai   地块替换优化 新的效果类型
1575
  				end
219e9654   zhouhaihai   拾荒增加选择类型
1576
1577
1578
1579
1580
1581
1582
1583
1584
  			end
  		end,
  		[16] = function(eventTypeF, eventIdF, eventTypeT, eventIdT, count) -- 指定事件转移
  			local change = self:getCurMap():eventChangeToOther(eventTypeF, eventIdF, eventTypeT, eventIdT, count)
  			for _, one in ipairs(change) do
  				if one[1].roomId == room.roomId and  one[2].blockId == block.blockId then
  					clearBlock = false
  				else
  					self:backBlockChange(one[1].roomId, one[2].blockId)
2d87caee   zhouhaihai   地块替换优化 新的效果类型
1585
  				end
219e9654   zhouhaihai   拾荒增加选择类型
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
  			end
  		end,
  		[17] = function(eventId)
  			local diceCsv = csvdb["event_choose_diceCsv"][eventId]
  			if not diceCsv then return end
  			local weight = math.randomInt(1, 12)
  			local sum = 0
  			local needEffect = nil
  			local pool = {}
  			for _, v in ipairs(diceCsv) do
  				local status, okCount = checkChooseCondFunc(self, v.cond, room, block, tag .. " dice", chooseData)
  				pool[#pool + 1] = v.weight + okCount * v.weightUp
ebc40c72   zhouhaihai   随机事件bug
1598
  				sum = sum + pool[#pool]
219e9654   zhouhaihai   拾荒增加选择类型
1599
1600
1601
  				if sum >= weight and not needEffect then
  					-- 达成效果
  					needEffect = v.effect
e085da41   zhouhaihai   指定事件转移
1602
  				end
219e9654   zhouhaihai   拾荒增加选择类型
1603
1604
1605
1606
1607
1608
1609
1610
1611
  			end
  			if needEffect then
  				self:pushBackEvent(AdvBackEventType.ChooseDice, {id = eventId, pool = pool, result = weight})
  				clearBlock = doChooseEffect(self, needEffect, room, block, tag .. " dice", chooseData)
  			end
  		end,
  	}
  
  	for _, effect in ipairs(effectStr:toTableArray(true)) do
4163e40a   zhouhaihai   找错误
1612
  		assert(doEffect[effect[1]], "error effect, event_" .. (tag or "choose") .. "Csv id :" .. (block.event and block.event.id or 0) .. "effect  " .. effect[1])
219e9654   zhouhaihai   拾荒增加选择类型
1613
  		doEffect[effect[1]](select(2, table.unpack(effect)))
e10edb5f   zhouahaihai   冒险事件新
1614
  	end
219e9654   zhouhaihai   拾荒增加选择类型
1615
1616
1617
  	return clearBlock
  end
  
bbf64622   zhouhaihai   冒险
1618
  
219e9654   zhouhaihai   拾荒增加选择类型
1619
1620
1621
1622
1623
  local function chooseCommon(self, room, block, chooseData, choose, tag)
  	if not choose then return end
  	if not chooseData or not chooseData["button".. choose .."cond"] then return end
   	if not checkChooseCondFunc(self, chooseData["button".. choose .."cond"], room, block, tag, chooseData) then return end
  	local clearBlock = chooseData.keep ~= 1
2205321c   zhouhaihai   拾荒 选择bug
1624
1625
  	local clearBlock_ = doChooseEffect(self, chooseData["button".. choose .."effect"], room, block, tag, chooseData)
  	clearBlock = clearBlock and clearBlock_
219e9654   zhouhaihai   拾荒增加选择类型
1626
  	self:scoreChange(AdvScoreType.Event, chooseData.advScore) --增加加分
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1627
1628
1629
1630
1631
1632
  	return true, clearBlock
  end
  
  local function clickChoose(self, room, block, params)
  	local choose = params.choose
  	local chooseData = csvdb["event_chooseCsv"][block.event.id]
6ce6fac7   zhouhaihai   冒险任务bug
1633
  	local oldId = block.event.id
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1634
  	local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "choose")
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1635
  	if not status then return end
6ce6fac7   zhouhaihai   冒险任务bug
1636
1637
1638
1639
  	self:checkAdvUnlock(3, oldId)
  	self:checkTask(Adv.TaskType.Choose, 1, oldId)
  	self:checkAchievement(Adv.AchievType.Choose, 1, oldId)
  	self:checkAchievement(Adv.AchievType.ChooseBySelect, 1, oldId, choose)
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1640
1641
1642
1643
1644
1645
1646
1647
1648
  	if clearBlock then
  		block:clear()
  	end
  	return true
  end
  
  local function clickLinkChoose(self, room, block, params)
  	local choose = params.choose
  	local chooseData = csvdb["event_linkchooseCsv"][block.event.id]
abe0d7e9   zhouhaihai   连续选择点bug
1649
  	local lcId = block.event.id
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1650
  	local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "link")
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1651
1652
1653
  	if not status then return end
  
  	-- 完成统计次数
abe0d7e9   zhouhaihai   连续选择点bug
1654
1655
1656
  	local idx = lcId % 10
  	if idx == 9 or not csvdb["event_linkchooseCsv"][lcId + 1] then --全部完成
  		local startId = math.floor(lcId / 10) * 10 + 1
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1657
  		self.lchoose[startId] = (self.lchoose[startId] or 0) + 1
b176d7d3   zhouhaihai   冒险成就
1658
  		self:checkAchievement(Adv.AchievType.LinkChoose, 1, startId)
e852b350   zhouhaihai   冒险成就类型增加
1659
  		self:checkAchievement(Adv.AchievType.FinishStoryId, 1, chooseData.storyid)
6133e29f   zhouhaihai   新加任务
1660
  		self:checkTask(Adv.TaskType.FinishStoryId, 1, chooseData.storyid)
e852b350   zhouhaihai   冒险成就类型增加
1661
1662
1663
1664
1665
  		local advStoryB = self.owner:getProperty("advStoryB")
  		advStoryB[chooseData.storyid] = (advStoryB[chooseData.storyid] or 0) + 1
  		self.owner:setProperty("advStoryB", advStoryB)
  		local storyData = csvdb["event_linkchoose_storyCsv"][chooseData.storyid]
  		self:checkAchievement(Adv.AchievType.StorryDone, 1, storyData[1].chapter)  -- 检查故事对应章节
68964730   zhouhaihai   增加积分 bug
1666
  		self:scoreChange(AdvScoreType.Story, storyData[1].advScore) --增加加分
e852b350   zhouhaihai   冒险成就类型增加
1667
  
f45d3a7b   zhouhaihai   adv_unlock
1668
  		self:checkAdvUnlock(4, startId)
e6439157   zhouhaihai   故事事件
1669
  		self.lchoose.cur = self.lchoose.cur or {}
abe0d7e9   zhouhaihai   连续选择点bug
1670
  		table.insert(self.lchoose.cur, {lcId, choose})
e6439157   zhouhaihai   故事事件
1671
1672
  		self:pushBackEvent(AdvBackEventType.LinkChooseOver, self.lchoose.cur)
  		self.lchoose.cur = nil
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1673
  	else
abe0d7e9   zhouhaihai   连续选择点bug
1674
  		self.lchoose.ing = lcId + 1  --后面会出现后继事件
e6439157   zhouhaihai   故事事件
1675
  		self.lchoose.cur = self.lchoose.cur or {}
abe0d7e9   zhouhaihai   连续选择点bug
1676
  		table.insert(self.lchoose.cur, {lcId, choose})
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1677
  	end
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
1678
  
02c4de8d   zhouahaihai   增加 固有技
1679
  	if clearBlock then
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1680
  		block:clear()
02c4de8d   zhouahaihai   增加 固有技
1681
  	end
b176d7d3   zhouhaihai   冒险成就
1682
  
46fac6f1   zhouahaihai   酱料
1683
1684
1685
1686
1687
1688
  	return true
  end
  
  local function clickDrop(self, room, block, params)
  	local reward = {}
  	if not block.event.item then return end
f0b81492   zhouhaihai   营地进入 bug
1689
  	if not self.battle or not self.battle.player then return end
d3da3368   zhouhaihai   冒险地图被动技, buff 神器
1690
  	self.battle.player:triggerPassive(Passive.CLICK_DROP)
f0b81492   zhouhaihai   营地进入 bug
1691
  
8955225b   zhouhaihai   快速拾取。快速使用
1692
1693
  	local reward = self:award({[block.event.item[1]] = block.event.item[2]}, {log = {desc = "clickDrop"}}, {roomId = room.roomId, blockId = block.blockId})
  
1e9cb217   chenyueqi   服务器记录控制引导过程
1694
1695
1696
  	if block.event.item[1] == 5020 and not self.owner:checkOverGuide(53,2) then
  		self.owner:saveGuide(53,2)
  	end
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1697
  	block:clear()
46fac6f1   zhouahaihai   酱料
1698
1699
1700
1701
1702
1703
  	return true
  end
  
  local function clickTrader(self, room, block, params)
  	local buyId = params.id
  	local traderData = csvdb["event_traderCsv"][block.event.id]
8c4a6f4c   zhouhaihai   冒险增加错误返回
1704
  	if not traderData then return false, 1 end -- 偷偷改表了
46fac6f1   zhouahaihai   酱料
1705
  
8c4a6f4c   zhouhaihai   冒险增加错误返回
1706
1707
  	if not block.event.shop or not block.event.shop[buyId] then return false, 2 end
  	if (block.event.status or ""):getv(buyId, 0) == 1 then return false, 3 end -- 买过了
46fac6f1   zhouahaihai   酱料
1708
  
127a5787   zhouhaihai   商人卖完走人
1709
  	local buyCount = #((block.event.status or ""):toArray())
27cc6f23   zhouhaihai   商店bug
1710
  	if traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount then return false, 4 end
f8408529   zhouhaihai   冒险商店
1711
1712
  
  	local goodsData = csvdb["event_trader_goodsCsv"][block.event.shop[buyId][1]]
8c4a6f4c   zhouhaihai   冒险增加错误返回
1713
  	if not goodsData then return false, 5 end
f8408529   zhouhaihai   冒险商店
1714
1715
  
  	local costCount = math.ceil(goodsData.price * (block.event.shop[buyId][2] or 100) / 100)
498f0eb2   zhouhaihai   冒险 action
1716
  	if not self:cost({[goodsData.currency] = costCount}, {log = {desc = "clickTrader", int1 = block.event.id}}) then return false, 6 end --不够
f8408529   zhouhaihai   冒险商店
1717
  	self:backCost({[goodsData.currency] = costCount})
8955225b   zhouhaihai   快速拾取。快速使用
1718
  	self:award({[goodsData.item] = goodsData.num}, {log = {desc = "clickTrader", int1 = block.event.id}}, {})
f8408529   zhouhaihai   冒险商店
1719
1720
1721
1722
1723
1724
1725
  	if goodsData.restrict == 1 then
  		self.shopStatus[goodsData.goods] = (self.shopStatus[goodsData.goods] or 0) + 1
  	elseif goodsData.restrict == 2 then
  		local advShop = self.owner:getProperty("advShop")
  		advShop[goodsData.goods] = (advShop[goodsData.goods] or 0) + 1
  		self.owner:updateProperty({field = "advShop", value = advShop})
  	end
46fac6f1   zhouahaihai   酱料
1726
  	block.event.status = block.event.status:setv(buyId, 1)
127a5787   zhouhaihai   商人卖完走人
1727
  	buyCount = buyCount + 1
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
1728
  	self:checkTask(Adv.TaskType.Shop, 1, block.event.id)
b176d7d3   zhouhaihai   冒险成就
1729
  	self:checkAchievement(Adv.AchievType.Shop, 1, block.event.id)
127a5787   zhouhaihai   商人卖完走人
1730
  
27cc6f23   zhouhaihai   商店bug
1731
  	if (traderData.purchasetime ~= 0 and traderData.purchasetime <= buyCount) or #block.event.shop <= buyCount then
127a5787   zhouhaihai   商人卖完走人
1732
1733
  		block:clear()
  	end
46fac6f1   zhouahaihai   酱料
1734
1735
1736
1737
  	return true
  end
  
  local function clickBuild(self, room, block, params)
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1738
1739
  	local choose = params.choose
  	local chooseData = csvdb["event_buildingCsv"][block.event.id]
6ce6fac7   zhouhaihai   冒险任务bug
1740
  	local oldId = block.event.id
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1741
1742
  	local status, clearBlock = chooseCommon(self, room, block, chooseData, choose, "build")
  	if not status then return end
85ded242   zhouhaihai   丰富返回事件
1743
  
e59430d5   zhouhaihai   宝藏怪刷新,计数
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
  	local isMine = false -- 是不是宝藏怪
  	for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do 
  		if mid == oldId then
  			isMine = true
  			break
  		end
  	end
  	if isMine then
  		local advMine = self.owner:getProperty("advMine")
  		advMine[2] = advMine[2] or {}
  		local mineCo2 = advMine[2].co or {}
  		if chooseData.limit ~= 0 then
  			mineCo2[oldId] = (mineCo2[oldId] or 0) + 1
  		end
  		advMine[2].co = mineCo2
  		self.owner:setProperty("advMine", advMine)
a5660239   zhouhaihai   冒险bug
1760
  		self.owner:checkTaskEnter("AdvMineLayer")
e59430d5   zhouhaihai   宝藏怪刷新,计数
1761
1762
  	end
  
6ce6fac7   zhouhaihai   冒险任务bug
1763
1764
1765
  	self:checkTask(Adv.TaskType.Build, 1, oldId)
  	self:checkAchievement(Adv.AchievType.Build, 1, oldId)
  	self:checkAchievement(Adv.AchievType.BuildBySelect, 1, oldId, choose)
7b570ef2   liuzujun   新春活动任务
1766
  	self.owner:checkTaskEnter("AdvBuild", {buildId = oldId})
1ffc16b9   zhouhaihai   冒险 选择点和 建筑
1767
  
02c4de8d   zhouahaihai   增加 固有技
1768
  	if clearBlock then
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1769
  		block:clear()
02c4de8d   zhouahaihai   增加 固有技
1770
  	end
46fac6f1   zhouahaihai   酱料
1771
1772
1773
  	return true
  end
  
c0b7797f   zhouhaihai   陷阱、点击生效点
1774
1775
  local function clickClick(self, room, block, params)
  	local clickData = csvdb["event_clickCsv"][block.event.id]
6133e29f   zhouhaihai   新加任务
1776
  	local oldId = block.event.id
c0b7797f   zhouhaihai   陷阱、点击生效点
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
  	if not clickData then return end
  	local clearBlock = true
  	local doEffect = {
  		[1] = function() -- 技能
  			for _, skillId in ipairs(clickData.effect:toArray(true, "=")) do
  				self.battle.player:releaseSkill(skillId)
  			end
  		end,
  		[2] = function() -- dropId
  			local reward = {}
  			for _, dropId in ipairs(clickData.effect:toArray(true, "=")) do
  				local item = csvdb["event_dropCsv"][dropId]["range"]:randWeight(true)
4b34fee8   zhouhaihai   增加~= 0 判定
1789
1790
1791
  				if item[1] ~= 0 then
  					reward[item[1]] = (reward[item[1]] or 0) + item[2]
  				end
c0b7797f   zhouhaihai   陷阱、点击生效点
1792
  			end
8955225b   zhouhaihai   快速拾取。快速使用
1793
  			self:award(reward, {log = {desc = "clickClick", int1 = block.event.id}}, {roomId = room.roomId, blockId = block.blockId})
3df1e9ea   zhouhaihai   掉落增加 地块信息,。click ...
1794
1795
1796
1797
1798
  		end,
  		[3] = function()
  			for _, buffId in ipairs(clickData.effect:toArray(true, "=")) do
  				self.battle.player:addBuff(buffId)
  			end
c0b7797f   zhouhaihai   陷阱、点击生效点
1799
1800
  		end,
  	}
6133e29f   zhouhaihai   新加任务
1801
  
a1e9e891   zhouhaihai   点击事件未生效
1802
1803
  	assert(doEffect[clickData.type], "error effect, event_clickCsv id :" .. block.event.id)
  	doEffect[clickData.type]()
6133e29f   zhouhaihai   新加任务
1804
1805
  	self:checkTask(Adv.TaskType.Click, 1, oldId)
  
c0b7797f   zhouhaihai   陷阱、点击生效点
1806
  	if clearBlock then
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1807
  		block:clear()
c0b7797f   zhouhaihai   陷阱、点击生效点
1808
  	end
f20cc9ca   zhouhaihai   点击点返回清空信息
1809
  	return true
c0b7797f   zhouhaihai   陷阱、点击生效点
1810
1811
  end
  
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1812
  local function clickLayer(self, room, block, params)
a80fee7c   zhouhaihai   光环
1813
  	local oldMapIdx = self:getCurMapIdx()
96018793   zhouhaihai   layer change
1814
  	self:backLayer(1)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
  	if block.event.mapIdx then
  		table.insert(self.mapStack, block.event.mapIdx) --进入夹层
  	else
  		--生成夹层
  		local mapId = csvdb["event_layerCsv"][block.event.id].effect
  		local mapIdx = #self.maps + 1
  		block.event.mapIdx = mapIdx
  		table.insert(self.mapStack, mapIdx)
  
  		self.maps[mapIdx] = AdvMap.new(self, mapIdx, mapId)
78dcacb6   zhouhaihai   夹层 后处理 没做
1825
  		self.battle:initMapEnemys(mapIdx, true)
7b2dc17c   zhouhaihai   地图 层 buff passive
1826
  		self.battle:initMapEffect(true)
1313eac0   zhouhaihai   冒险的一些bug
1827
  		self.maps[mapIdx]:initBattleAfter()
b176d7d3   zhouhaihai   冒险成就
1828
  		self:checkAchievement(Adv.AchievType.EnterILayer, 1, mapId)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1829
  	end
a80fee7c   zhouhaihai   光环
1830
  	self.battle:iLayerChange(oldMapIdx)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1831
1832
1833
  	return true
  end
  
46fac6f1   zhouahaihai   酱料
1834
1835
  local eventCallFunc = {
  	[AdvEventType.Out] = clickOut,
0e3ab88d   zhouhaihai   中继层
1836
1837
  	[AdvEventType.InOut] = clickOut,
  	[AdvEventType.Exit] = clickExit,
46fac6f1   zhouahaihai   酱料
1838
1839
1840
  	[AdvEventType.BOSS] = clickMonster,
  	[AdvEventType.Monster] = clickMonster,
  	[AdvEventType.Choose] = clickChoose,
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
1841
  	[AdvEventType.LinkChoose] = clickLinkChoose,
46fac6f1   zhouahaihai   酱料
1842
1843
1844
  	[AdvEventType.Drop] = clickDrop,
  	[AdvEventType.Trader] = clickTrader,
  	[AdvEventType.Build] = clickBuild,
c0b7797f   zhouhaihai   陷阱、点击生效点
1845
  	[AdvEventType.Click] = clickClick,
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1846
  	[AdvEventType.Layer] = clickLayer,
46fac6f1   zhouahaihai   酱料
1847
1848
1849
1850
1851
  }
  
  --点击处理 roomId, blockId 
  --params 某些事件需要的客户端传递的参数
  function Adv:clickBlock(roomId, blockId, params)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1852
1853
1854
  	local map = self:getCurMap()
  	local room = self:getRoom(roomId)
  	local block = self:getBlock(roomId, blockId)
46fac6f1   zhouahaihai   酱料
1855
1856
  	if not block then return end
  
8c4a6f4c   zhouhaihai   冒险增加错误返回
1857
  	local status, errorCode = false, nil
36c30c5c   zhouahaihai   冒险
1858
  	local clickEvent = false
48962a74   zhouhaihai   路障系统提交
1859
1860
  
  	local function checkAroundBlocks(ignoreGuard)
36c30c5c   zhouahaihai   冒险
1861
  		local canOpen = false  --如果未开放是否可以开放
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1862
  		for _, one in ipairs(map:getAroundBlocks(room, block)) do
36c30c5c   zhouahaihai   冒险
1863
  			local _room, _block = one[1], one[2]
48962a74   zhouhaihai   路障系统提交
1864
1865
1866
  			if not ignoreGuard and _block:isGuard() then 
  				if _block:isMonster() then
  					local enemy = self.battle:getEnemy(_room.roomId, _block.blockId)
a0834e49   zhouhaihai   增加潜行 功能
1867
  					if not enemy:hadBuff(Buff.DONT_DEFEND) and not self.battle.player:hadBuff(Buff.SNEAK) then
48962a74   zhouhaihai   路障系统提交
1868
1869
1870
1871
  						return false
  					end
  				else
  					return false
4f0a5fae   zhouhaihai   营养剂
1872
  				end
48962a74   zhouhaihai   路障系统提交
1873
1874
  			elseif _block:isWalk() then
  				canOpen = true
36c30c5c   zhouahaihai   冒险
1875
1876
  			end
  		end
48962a74   zhouhaihai   路障系统提交
1877
1878
1879
1880
  		return canOpen
  	end
  
  	if not block.isOpen then
7b64b6cd   zhouhaihai   中继层优化
1881
  		if self.isRelay or checkAroundBlocks() then --开放
8781e103   zhouhaihai   冒险 bug
1882
  			self:getCurMap():openBlock(roomId, blockId, true, true)
46fac6f1   zhouahaihai   酱料
1883
1884
1885
  			status = true
  		end
  	else
36c30c5c   zhouahaihai   冒险
1886
  		clickEvent = true
46fac6f1   zhouahaihai   酱料
1887
1888
1889
1890
  		--点了空地
  		if not block.event then
  			return 
  		end
48962a74   zhouhaihai   路障系统提交
1891
  
be2bc68b   zhouhaihai   看守周围的格子
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
  		if not block:isMonster() then
  			for _, one in ipairs(map:getAroundBlocksPlus(room, block)) do
  				local _room, _block = one[1], one[2]
  				if _block:isMonster() then
  					local enemy = self.battle:getEnemy(_room.roomId, _block.blockId)
  					if enemy:hadBuff(Buff.OBSTACLE_PLUS) then
  						return
  					end
  				end
  			end
  		end
  
48962a74   zhouhaihai   路障系统提交
1904
1905
1906
  		if block:isHinder() then
  			if not checkAroundBlocks(true) then return end
  		end
46fac6f1   zhouahaihai   酱料
1907
  		--可点击的事件
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
1908
  		if not room.isBossRoom or block:isBoss() then
46fac6f1   zhouahaihai   酱料
1909
  			if eventCallFunc[block.event.etype] then
8c4a6f4c   zhouhaihai   冒险增加错误返回
1910
  				status, errorCode = eventCallFunc[block:getEventType()](self, room, block, params)
46fac6f1   zhouahaihai   酱料
1911
1912
1913
  			end
  		end
  	end
39a6e08b   suhongyang   冒险战斗内逻辑调整
1914
  	local needChange = true
ae20365b   suhongyang   Revert "修改冒险战斗逻辑"
1915
  	if clickEvent and block.event then
8b25d183   zhouhaihai   切换层不更新回合
1916
1917
1918
1919
  		if block:getEventType() == AdvEventType.Out 
  			or block:getEventType() == AdvEventType.InOut 
  			or block:getEventType() == AdvEventType.Layer 
  			or block:getEventType() == AdvEventType.Exit then
ae20365b   suhongyang   Revert "修改冒险战斗逻辑"
1920
1921
  			needChange = false
  		end
39a6e08b   suhongyang   冒险战斗内逻辑调整
1922
1923
  	end
  	if status and needChange then  --出去了就不计算回合了
46fac6f1   zhouahaihai   酱料
1924
1925
1926
  		self:backBlockChange(roomId, blockId)
  		self:afterRound()
  	end
36c30c5c   zhouahaihai   冒险
1927
  	self:saveDB()
8c4a6f4c   zhouhaihai   冒险增加错误返回
1928
  	return status, errorCode
46fac6f1   zhouahaihai   酱料
1929
1930
  end
  
46fac6f1   zhouahaihai   酱料
1931
  
4f0a5fae   zhouhaihai   营养剂
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
  function Adv:doActive(activeId, target)
  	local activeData = csvdb["adv_activeCsv"][activeId]
  	if not activeData then return end
  
  	local targers = {}
  
  	-- 筛选对象
  	if activeData.usetype == 1 then -- 自己
  	elseif activeData.usetype == 2 then -- 敌人
  		if not target or not target.roomId or not target.blockId then return end
  		local block = self:getBlock(target.roomId, target.blockId)
  		if block:isBoss() then return end
  		local enemy = self.battle:getEnemy(target.roomId, target.blockId)
  		if not enemy then return end
  		local blocks = self:getCurMap():getBlocksBySize(target.roomId, target.blockId, activeData.scope)
  		for _, block in pairs(blocks) do
  			if block:isMonster() and not block:isBoss() then
  				local e = self.battle:getEnemy(block.room.roomId, block.blockId)
  				if e then
  					table.insert(targers, e)
  				end
  			end
  		end
  	elseif activeData.usetype == 3 then -- 地板
  		if not target or not target.roomId or not target.blockId then return end
  		local block = self:getBlock(target.roomId, target.blockId)
  		if block:isBoss() then return end
  		local blocks = self:getCurMap():getBlocksBySize(target.roomId, target.blockId, activeData.scope)
  		for _, block in pairs(blocks) do
  			if not block:isBoss() then
  				table.insert(targers, block)
  			end
  		end
318c573a   zhouhaihai   冒险bug
1965
  	elseif activeData.usetype == 4 then -- 没有目标 全体成员
4f0a5fae   zhouhaihai   营养剂
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
  	elseif activeData.usetype == 5 then -- 空地板
  		if not target or not target.roomId or not target.blockId then return end
  		local block = self:getBlock(target.roomId, target.blockId)
  		if not block.isOpen or block:getEventType() then return end
  		local blocks = self:getCurMap():getBlocksBySize(target.roomId, target.blockId, activeData.scope)
  		for _, block in pairs(blocks) do
  			if not block:isBoss() then
  				table.insert(targers, block)
  			end
  		end
  	end
  
  	local doActiveEffect = {}
  
  	-- 1=map_buff_id:为范围内所有目标附加mapbuff
  	doActiveEffect[1] = function(_,  buffId)
318c573a   zhouhaihai   冒险bug
1982
1983
1984
1985
1986
1987
1988
1989
  		if not next(targers) then
  			if activeData.usetype == 1 then
  				table.insert(targers, self.battle.player)
  			elseif activeData.usetype == 4 then
  				targers = self.battle.player:getTeam(2)
  			else
  				return
  			end
4f0a5fae   zhouhaihai   营养剂
1990
1991
1992
  		end
  
  		for _, target in ipairs(targers) do
318c573a   zhouhaihai   冒险bug
1993
1994
1995
1996
1997
1998
  			if target.class.__cname == "AdvBlock" then
  				target = self.battle:getEnemy(target.room.roomId, target.blockId)
  			end
  			if target then
  				target:addBuff(buffId, self.battle.player)
  			end
4f0a5fae   zhouhaihai   营养剂
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
  		end
  
  		return true
  	end
  	-- 2=trader_id:召唤商人	
  	doActiveEffect[2] = function(_,  traderId)
  		for _, target in ipairs(targers) do
  			if target.isOpen and not target:getEventType() then
  				target:updateEvent({
  					etype = AdvEventType.Trader,
  					id = traderId,
  				})
4f0a5fae   zhouhaihai   营养剂
2011
  				self:backBlockChange(target.room.roomId, target.blockId)
d232676a   zhouhaihai   功能解锁 冒险返回
2012
  				self:pushBackEvent(AdvBackEventType.Trader, {id = traderId})
4f0a5fae   zhouhaihai   营养剂
2013
2014
2015
2016
2017
2018
2019
2020
2021
  			end
  		end
  		return true
  	end
  
  	-- 3=monster_id:替换怪物,仅使用方式为2时生效
  	doActiveEffect[3] = function(_, monsterId)
  		for _,  target in ipairs(targers) do
  			if not target.lock and not target.isDead then
318c573a   zhouhaihai   冒险bug
2022
  				self:getCurMap():addNewMonsterRand(monsterId, {self:getRoom(target.roomId), self:getBlock(target.roomId, target.blockId)})
4f0a5fae   zhouhaihai   营养剂
2023
  				self:backBlockChange(target.roomId, target.blockId)
d232676a   zhouhaihai   功能解锁 冒险返回
2024
  				self:pushBackEvent(AdvBackEventType.Monster, {id = monsterId})
4f0a5fae   zhouhaihai   营养剂
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
  			end
  		end
  		return true
  	end
  	-- 4:显示本层
  	doActiveEffect[4] = function(_)
  		self:getCurMap():showMap()
  		self:backMapShow()
  		return true
  	end
  	-- 5:放逐目标
  	doActiveEffect[5] = function(_)
  		for _,  target in ipairs(targers) do
f773a677   zhouhaihai   假的boss 没有效果
2038
  			local had = false
4f0a5fae   zhouhaihai   营养剂
2039
  			if not target.lock and not target.isDead then
f773a677   zhouhaihai   假的boss 没有效果
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
  				if target:getMonsterCsv().type == 5 then
  					-- 假boss 不能用
  					had = true
  				else
  					target:kill()
  					self:backBlockChange(target.roomId, target.blockId)
  				end
  			end
  			if had then
  				self:pushBackEvent(AdvBackEventType.NoEffect)
4f0a5fae   zhouhaihai   营养剂
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
  			end
  		end
  		return true
  	end
  	-- 6=陷阱id:移除陷阱,不填写id则移除所有陷阱
  	doActiveEffect[6] = function(_, trapId)
  		if not next(targers) and activeData.usetype == 4 then
  			-- 全屏
  			for _, room in pairs(self:getCurMap().rooms) do
  				for _, block in pairs(room.blocks) do
  					if block:getEventType() ==  AdvEventType.Trap then
  						block:updateEvent(nil)
  						self:backBlockChange(block.room.roomId, block.blockId)
  					end
  				end
  			end
  		else
  			for _ , target in ipairs(targers) do
  				if target:getEventType() ==  AdvEventType.Trap then
  					target:updateEvent(nil)
  					self:backBlockChange(target.room.roomId, target.blockId)
  				end
  			end
  		end
  		return true
  	end
  	
  	-- 7=道具燃烧效果
40c88e08   zhouhaihai   拾荒bug
2078
2079
  	doActiveEffect[7] = function(_, ctype)
  		self:blockDropChange(ctype, targers)
4f0a5fae   zhouhaihai   营养剂
2080
2081
2082
2083
2084
2085
  		return true
  	end
  
  	-- 8:翻开范围内的方格
  	doActiveEffect[8] = function(_)
  		for _ , target in ipairs(targers) do
c8210d56   zhouhaihai   boss 房有入口
2086
  			self:getCurMap():openBlock(target.room.roomId, target.blockId, true)
4f0a5fae   zhouhaihai   营养剂
2087
2088
2089
2090
  		end
  		return true
  	end
  
db3c56ad   zhouhaihai   冒险相关
2091
2092
2093
2094
2095
2096
  	-- 9: 给玩家增加buff
  	doActiveEffect[9] = function(_, buffId)
  		self.battle.player:addBuff(buffId, self.battle.player)
  		return true
  	end
  
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
2097
2098
  	--10: 立刻结算 按比例返还
  	doActiveEffect[10] = function(_, rewardRatio)
bbf64622   zhouhaihai   冒险
2099
  		self:over(true, rewardRatio, 1)
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
2100
2101
  		return true
  	end
1bb3abca   zhouhaihai   冒险 退出 bug
2102
  
6dc482bb   zhouhaihai   中继层完成, 新增两个冒险物品使用效果
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
  	--11: 随机提升一个未满级神器等级,配置提升等级
  	doActiveEffect[11] = function(_, level)
  		local advAFGet = self.owner:getProperty("advAFGet")
  		local pool = {}
  		for id_, lv in pairs(advAFGet) do
  			if self.owner:isArtifactOpen(id_, self:isEndless(), lv + 1) then  
  				table.insert(pool, id_)
  			end
  		end
  		if #pool > 0 then
  			local idx = math.randomInt(1, #pool)
  			self:artifactLevelUp(pool[idx], level)
  		end
  		return true
  	end
1bb3abca   zhouhaihai   冒险 退出 bug
2118
  
d232676a   zhouhaihai   功能解锁 冒险返回
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
  	doActiveEffect[12] = function(_, vtype, attrType, value)
  		local attr
  		if attrType == 0 then
  			attr = "sp"
  		else
  			attr = AttsEnumEx[attrType]
  			if not AdvAttsEnum[attr] then return end
  		end
  		self.battle.player:addBaseAttr(attr, value, vtype)
  		return true
  	end
  
4f0a5fae   zhouhaihai   营养剂
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
  	for _, effect in ipairs(activeData.effect:toArray()) do
  		local cur = effect:toArray(true, "=")
  		if doActiveEffect[cur[1]] then
  			if not doActiveEffect[cur[1]](table.unpack(cur)) then
  				return
  			end
  		end
  	end
  
  	return true
  end
  
46fac6f1   zhouahaihai   酱料
2143
  
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
2144
2145
  -- 地图上物品变化
  function Adv:mapItemChange(ctype)
6826fdf6   zhouhaihai   被动触发
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
  	local blocks = {}
  	for roomId, room in pairs(self:getCurMap().rooms) do
  		for blockId, block in pairs(room.blocks) do
  			table.insert(blocks, block)
  		end
  	end
  	self:blockDropChange(ctype, blocks)
  end
  
  function Adv:blockDropChange(ctype, blocks)
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
2156
2157
  	local clist = csvdb["transform_itemCsv"][ctype]
  	if clist then
6826fdf6   zhouhaihai   被动触发
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
  		for _, block in ipairs(blocks) do
  			if block:getEventType() == AdvEventType.Drop and block.event.item then
  				local id = block.event.item[1]
  				local count = block.event.item[2]
  				local changeTo = nil
  				if clist[id] then
  					changeTo = {clist[id].toId, math.ceil(count * clist[id].num)}
  				elseif clist[-1] then
  					changeTo = {clist[-1].toId, math.ceil(count * clist[-1].num)}
  				end
  				if changeTo and changeTo[1] ~= 0 and changeTo[2] ~= 0 then
  					block.event.item = changeTo
  					self:backBlockChange(block.room.roomId, block.blockId, ctype)
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
2171
2172
2173
2174
2175
2176
  				end
  			end
  		end
  	end
  end
  
46fac6f1   zhouahaihai   酱料
2177
  --敌人死亡
7828ffd0   zhouhaihai   冒险 连续选择点 和 地图因子
2178
2179
  function Adv:enemyDead(enemy, escape)
  	local roomId, blockId = enemy.roomId, enemy.blockId
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
2180
2181
2182
2183
  	local map = self:getCurMap()
  	local room = self:getRoom(roomId)
  	local block = self:getBlock(roomId, blockId)
  	if not block then return end
46fac6f1   zhouahaihai   酱料
2184
  	--死了以后掉东西
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
2185
2186
  	if block:isMonster() then --处理死亡
  		if block:isBoss() then
36c30c5c   zhouahaihai   冒险
2187
2188
  			room.isBossRoom = false
  		end
02c4de8d   zhouahaihai   增加 固有技
2189
  		if escape then
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
2190
  			block:clear()
02c4de8d   zhouahaihai   增加 固有技
2191
  		else
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
2192
2193
  			local enemyId = block.event.id
  			local monsterData = csvdb["event_monsterCsv"][enemyId]
bbf64622   zhouhaihai   冒险
2194
2195
2196
2197
2198
  			if block:isBoss() then 
  				self:scoreChange(AdvScoreType.KillBoss, monsterData.advScore)
  			else
  				self:scoreChange(AdvScoreType.Kill, monsterData.advScore)
  			end
a95b35ce   zhouhaihai   删除等级
2199
2200
2201
  			-- local changeV = self.battle.player:addExp(monsterData.exp)
  			-- self:backDead(enemyId, changeV)
  			self:backDead(enemyId)
9104a922   zhouhaihai   多重掉落
2202
  
36875ec5   zhouhaihai   宝藏怪
2203
2204
2205
2206
2207
2208
  			local isMine = false -- 是不是宝藏怪
  			for _, mid in ipairs(globalCsv.adv_egg_treasureMonster_id) do 
  				if mid == enemyId then
  					isMine = true
  					break
  				end
9104a922   zhouhaihai   多重掉落
2209
  			end
e59430d5   zhouhaihai   宝藏怪刷新,计数
2210
  
36875ec5   zhouhaihai   宝藏怪
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
  			if isMine then
  				local advMine = self.owner:getProperty("advMine")
  				advMine[1] = advMine[1] or {}
  				advMine[2] = advMine[2] or {}
  				local mineCo = advMine[1].co or {}
  				local mineCo2 = advMine[2].co or {}
  				local mineCh = advMine[2].ch or globalCsv.adv_egg_treasureLayer_showup
  				if monsterData.limit ~= 0 then
  					mineCo[enemyId] = (mineCo[enemyId] or 0) + 1
  				end
9104a922   zhouhaihai   多重掉落
2221
  
36875ec5   zhouhaihai   宝藏怪
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
  				local had = false
  				if math.randomInt(1, 100) <= mineCh then -- 刷出来了
  					local mpool = {}
  					for _, mid in ipairs(globalCsv.adv_egg_treasureLayer_id) do
  						local layer = csvdb["event_buildingCsv"][mid]
  						if (not mineCo2[mid] or layer.limit == 0 or mineCo2[mid] < layer.limit) and layer.showup > 0 then
  							mpool[mid] = {layer.showup}
  						end
  					end
  					if next(mpool) then
  						local cId = math.randWeight(mpool, 1)
  						block:updateEvent({
  							etype = AdvEventType.Build,
  							id = cId
  						})
36875ec5   zhouhaihai   宝藏怪
2237
2238
2239
2240
  						had = true
  					end
  				end
  				if had then
36875ec5   zhouhaihai   宝藏怪
2241
  					mineCh = nil
fea3baab   zhouhaihai   宝藏怪bug
2242
2243
2244
  				else
  					block:clear()
  					mineCh = math.min(mineCh + globalCsv.adv_egg_treasureLayer_showup_add, 100)
36875ec5   zhouhaihai   宝藏怪
2245
  				end
9104a922   zhouhaihai   多重掉落
2246
  
36875ec5   zhouhaihai   宝藏怪
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
  				local drops = {}
  				for _, dropId in ipairs(monsterData.dropid:toArray(true, "=")) do
  					local dropData = csvdb["event_dropCsv"][dropId]
  					if dropData then
  						local cur = dropData["range"]:randWeight(true)
  						if cur and cur[1] ~= 0 then
  							drops[#drops + 1] = cur
  						end
  					end
  				end
  				local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
  				for _i, cblock in ipairs(blocks) do
  					cblock:updateEvent({
  						etype = AdvEventType.Drop,
  						item = drops[_i]
  					})
  					if cblock ~= block then
  						self:backBlockChange(cblock.room.roomId, cblock.blockId)
  					end
  				end
  				advMine[1].co = mineCo
  				advMine[2].co = mineCo2
  				advMine[2].ch = mineCh
  				self.owner:setProperty("advMine", advMine)
a5660239   zhouhaihai   冒险bug
2271
  				self.owner:checkTaskEnter("AdvMineKill")
36875ec5   zhouhaihai   宝藏怪
2272
2273
2274
2275
2276
  			else
  				local toClick = enemy:hadBuff(Buff.CHANGE_DROP_TO_CLICK)
  				if toClick then
  					toClick = toClick:effect()
  				end
9104a922   zhouhaihai   多重掉落
2277
  
36875ec5   zhouhaihai   宝藏怪
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
  				local changItem = enemy:hadBuff(Buff.CHANGE_DROP)
  				if changItem then
  					changItem = table.pack(changItem:effect())
  				end
  
  				local addMult = 0
  				local dropBuff = enemy:hadBuff(Buff.DROP_BUFF_BY_ENEMY)  -- 根据敌人数量变化个数
  				if dropBuff then
  					local team = enemy:getTeam(1, true)
  					addMult = addMult + 0.2 * #team
  				end
  
  				local dropIds = monsterData.dropid:toArray(true, "=")
  				local drops = {}
  				local cCcount = 0 -- 需要改变为click 的个数
  				for _, dropId in ipairs(dropIds) do
  					local dropData = csvdb["event_dropCsv"][dropId]
  					if dropData then
  						local cur = dropData["range"]:randWeight(true)
  						if cur and cur[1] ~= 0 then
  							if toClick then
  								cCcount = cCcount + 1
  							else
  								local item = changItem and changItem or cur
  								item[2] = math.floor(item[2] * (1 + addMult))
  								drops[#drops + 1] = item
  							end
e7b51763   zhouhaihai   无掉落怪
2305
  						end
db3c56ad   zhouhaihai   冒险相关
2306
  					end
db3c56ad   zhouhaihai   冒险相关
2307
  				end
36875ec5   zhouhaihai   宝藏怪
2308
  				-- 这些奖励可能会有被动加成
40c88e08   zhouhaihai   拾荒bug
2309
  				self.battle.player:triggerPassive(Passive.BATTLE_WIN, {drops = drops, trigger = enemy})
9104a922   zhouhaihai   多重掉落
2310
  
36875ec5   zhouhaihai   宝藏怪
2311
2312
2313
2314
  				-- 自身带的掉落是不会被改变的 也不会被加成
  				if block.event.item and block.event.item[1] ~= 0 then
  					table.insert(drops,  1, block.event.item)
  				end
9104a922   zhouhaihai   多重掉落
2315
  
36875ec5   zhouhaihai   宝藏怪
2316
2317
  				-- 清空当前的格子
  				block:clear()
9104a922   zhouhaihai   多重掉落
2318
  
36875ec5   zhouhaihai   宝藏怪
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
  				-- 掉落走一波
  				local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, #drops)
  				for _i, cblock in ipairs(blocks) do
  					cblock:updateEvent({
  						etype = AdvEventType.Drop,
  						item = drops[_i]
  					})
  					if cblock ~= block then
  						self:backBlockChange(cblock.room.roomId, cblock.blockId)
  					end
9104a922   zhouhaihai   多重掉落
2329
  				end
9104a922   zhouhaihai   多重掉落
2330
  
36875ec5   zhouhaihai   宝藏怪
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
  				-- 转换的click走一波
  				local blocks = self:getCurMap():getEmptyBlocks(roomId, blockId, cCcount)
  				for _i, cblock in ipairs(blocks) do
  					cblock:updateEvent({
  						etype = AdvEventType.Click,
  						id = clickId
  					})
  					if cblock ~= block then
  						self:backBlockChange(cblock.room.roomId, cblock.blockId)
  					end
db3c56ad   zhouhaihai   冒险相关
2341
  				end
4b7c7c96   zhouahaihai   增加 清空 挂机 冒险gm 角色经验
2342
  			end
9104a922   zhouhaihai   多重掉落
2343
  
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
2344
2345
  			self:checkTask(Adv.TaskType.Kill, 1, enemyId)
  			self:checkTask(Adv.TaskType.KillAll)
b176d7d3   zhouhaihai   冒险成就
2346
  			self:checkAchievement(Adv.AchievType.Kill, 1, enemyId)
e852b350   zhouhaihai   冒险成就类型增加
2347
2348
  			self:checkAchievement(Adv.AchievType.KillHadBuff, 1, enemy)
  
308a335c   zhouhaihai   错误单词
2349
  			self.owner:checkTaskEnter("AdvKill", {chapterId = self.chapterId})
7b570ef2   liuzujun   新春活动任务
2350
  
71a18948   zhouhaihai   成就未生效
2351
2352
  			self:checkAchievement(Adv.AchievType.KillWithBuff, 1)
  			self:checkAchievement(Adv.AchievType.KillNoBuff, 1)
e852b350   zhouhaihai   冒险成就类型增加
2353
2354
2355
2356
  			self:checkAchievement(Adv.AchievType.KillWithMWeapon, 1)
  			self:checkAchievement(Adv.AchievType.KillWithAMWeapon, 1)
  
  			if monsterData.type == 2 then
6133e29f   zhouhaihai   新加任务
2357
  				self:checkTask(Adv.TaskType.KillBoss, 1, enemyId)
71a18948   zhouhaihai   成就未生效
2358
2359
2360
  				self:checkAchievement(Adv.AchievType.KillBoss, 1, enemyId)
  				self:checkAchievement(Adv.AchievType.KillBossWithBuff, 1)
  				self:checkAchievement(Adv.AchievType.KillBossNoBuff, 1)
e852b350   zhouhaihai   冒险成就类型增加
2361
2362
  				self:checkAchievement(Adv.AchievType.KillBossWithMWeapon, 1)
  				self:checkAchievement(Adv.AchievType.KillBossWithAMWeapon, 1)
f76d63e1   liuzujun   联动任务活动
2363
  				self.owner:checkTaskEnter("AdvKillBoss")
6133e29f   zhouhaihai   新加任务
2364
2365
  			elseif monsterData.type == 3 then
  				self:checkTask(Adv.TaskType.KillElite, 1, enemyId)
e852b350   zhouhaihai   冒险成就类型增加
2366
  			end
46fac6f1   zhouahaihai   酱料
2367
  		end
46fac6f1   zhouahaihai   酱料
2368
2369
2370
2371
  	end
  	self:backBlockChange(roomId, blockId)
  end
  
46fac6f1   zhouahaihai   酱料
2372
2373
2374
2375
  
  function Adv:pushBackEvent(btype, params)
  	table.insert(self.backEvents, {btype = btype, params = params})
  end
8955225b   zhouhaihai   快速拾取。快速使用
2376
2377
2378
2379
  --[=[
  tag
  1 自动拾取
  --]=] 
3df1e9ea   zhouhaihai   掉落增加 地块信息,。click ...
2380
2381
  function Adv:backReward(items, params)
  	params = params or {}
8955225b   zhouhaihai   快速拾取。快速使用
2382
  	self:pushBackEvent(AdvBackEventType.Reward, {items = items, roomId = params.roomId, blockId = params.blockId, tag = params.tag})
46fac6f1   zhouahaihai   酱料
2383
  end
e996b82a   zhouahaihai   冒险增加防御属性
2384
2385
  
  -- if is player enemyId is nil 
46fac6f1   zhouahaihai   酱料
2386
  function Adv:backSkill(enemyId, skillId, receiver)
36c30c5c   zhouahaihai   冒险
2387
  	self:pushBackEvent(AdvBackEventType.Skill, {enemyId = enemyId, skillId = skillId, receiver = receiver})
46fac6f1   zhouahaihai   酱料
2388
2389
  end
  
46fac6f1   zhouahaihai   酱料
2390
2391
2392
2393
  function Adv:backNext()
  	self:pushBackEvent(AdvBackEventType.Next, {})
  end
  
46fac6f1   zhouahaihai   酱料
2394
  
b2e41074   zhouhaihai   冒险 排行榜拆分
2395
2396
  function Adv:backBlockChange(roomId, blockId, itemChangeType)
  	self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId, itemChangeType = itemChangeType})
46fac6f1   zhouahaihai   酱料
2397
2398
  end
  
a95b35ce   zhouhaihai   删除等级
2399
2400
  function Adv:backDead(enemyId)
  	self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
bedca62d   zhouahaihai   冒险
2401
2402
  end
  
386ca58e   zhouhaihai   优化log
2403
2404
2405
  function Adv:backTrap()
  	self:pushBackEvent(AdvBackEventType.Trap, {})
  end
ec87b4a5   zhouahaihai   冒险 完善
2406
  
85ded242   zhouhaihai   丰富返回事件
2407
2408
  function Adv:backLayer(status)
  	self:pushBackEvent(AdvBackEventType.Layer, {status = status})
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
2409
2410
  end
  
4f0a5fae   zhouhaihai   营养剂
2411
2412
2413
2414
  function Adv:backMapShow()
  	self:pushBackEvent(AdvBackEventType.MapShow, {})
  end
  
ccbafe67   zhouhaihai   冒险神器和buff
2415
2416
2417
2418
  function Adv:backChooseArtifact()
  	self:pushBackEvent(AdvBackEventType.ChooseArtifact, {})
  end
  
85ded242   zhouhaihai   丰富返回事件
2419
2420
2421
2422
  function Adv:backCost(items)
  	self:pushBackEvent(AdvBackEventType.Cost, {items = items})
  end
  
8955225b   zhouhaihai   快速拾取。快速使用
2423
2424
2425
2426
2427
2428
  --[=[
  tag
  1 自动使用
  --]=] 
  function Adv:backUse(items, tag)
  	self:pushBackEvent(AdvBackEventType.Use, {items = items, tag = tag})
85ded242   zhouhaihai   丰富返回事件
2429
2430
2431
  end
  
  
bbf64622   zhouhaihai   冒险
2432
  function Adv:scoreChange(scoreType, score)
43babcff   zhouhaihai   优化冒险结构 增加夹层功能
2433
  	self.score[scoreType] = self.score[scoreType] or 0
bbf64622   zhouhaihai   冒险
2434
  	self.score[scoreType] = self.score[scoreType] + score
b0fe1817   zhouahaihai   冒险分数
2435
2436
2437
  end
  
  function Adv:getScore()
a80fee7c   zhouhaihai   光环
2438
2439
2440
2441
2442
  	local allScore = 0
  	for _, score in pairs(self.score) do
  		allScore = allScore + math.floor(score)
  	end
  	return allScore
b0fe1817   zhouahaihai   冒险分数
2443
2444
  end
  
46fac6f1   zhouahaihai   酱料
2445
2446
  function Adv:popBackEvents()
  	local events = self.backEvents
46fac6f1   zhouahaihai   酱料
2447
2448
2449
2450
2451
2452
  	self.backEvents = {}
  	return events
  end
  
  --回合事件处理
  function Adv:afterRound()
4faef572   zhouhaihai   冒险任务,冒险扫荡, 冒险中继
2453
  	self.round = self.round + 1
46fac6f1   zhouahaihai   酱料
2454
2455
2456
  	if self.battle then
  		self.battle:afterRound()
  	end
36c30c5c   zhouahaihai   冒险
2457
2458
  end
  
46fac6f1   zhouahaihai   酱料
2459
  return Adv