46fac6f1
zhouahaihai
酱料
|
1
2
|
local Passive = require "adv.AdvPassive"
|
61dc5eb6
suhongyang
fix global to local
|
3
|
-- 工具函数--第一象限 < 10000 < 第二象限 < 20000 < 第四象限 < 30000 < 第三象限
|
46fac6f1
zhouahaihai
酱料
|
4
|
local function getIdByCr(c, r)
|
61dc5eb6
suhongyang
fix global to local
|
5
|
local crId = math.abs(r) + math.abs(c) * 100 -- row + column * 100
|
46fac6f1
zhouahaihai
酱料
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
if c < 0 then
crId = crId + 10000
end
if r < 0 then
crId = crId + 20000
end
return crId
end
local function getCrById(crId)
local c = math.floor(crId % 10000 / 100)
local r = crId % 100
local last = math.floor(crId / 10000)
if last == 3 then
c, r = -c, -r
elseif last == 1 then
c = -c
elseif last == 2 then
r = -r
end
return c, r
end
-----------------------------随机地图-----------------------------
|
61dc5eb6
suhongyang
fix global to local
|
30
|
--检查 是否满足层数限制条件 -- if checktype == 1 then check value in range a=b else check value in array a=b=c
|
46fac6f1
zhouahaihai
酱料
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
local function checkIsIn(checkValue, checkType, checkRange)
if not checkValue then return end
if checkType == 1 then
local limits = checkRange:toNumMap()
for min, max in pairs(limits) do
if checkValue >= min and checkValue <= max then
return true
end
end
else
local limit = checkRange:toArray(true, "=")
for _, _l in ipairs(limit) do
if _l == checkValue then
return true
end
end
end
end
--关卡事件库
|
1607a7f0
zhouahaihai
冒险事件 new
|
51
|
local function getEventLib(chapterId, level, needEventType) -- needEventType 需要的事件
|
46fac6f1
zhouahaihai
酱料
|
52
53
54
|
local chapter = math.floor(chapterId / 100) % 100
local libsToType = {
|
1bd8f8ee
zhouahaihai
精英怪
|
55
|
["event_monsterCsv"] = {AdvEventType.Monster, AdvEventType.BOSS, AdvEventType.Monster},
|
46fac6f1
zhouahaihai
酱料
|
56
57
58
59
|
["event_chooseCsv"] = AdvEventType.Choose,
["event_dropCsv"] = AdvEventType.Drop,
["event_buildingCsv"] = AdvEventType.Build,
["event_traderCsv"] = AdvEventType.Trader,
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
60
61
|
["event_trapCsv"] = AdvEventType.Trap,
["event_clickCsv"] = AdvEventType.Click,
|
46fac6f1
zhouahaihai
酱料
|
62
63
64
65
|
}
local eventLib = {}
for lib, eventType in pairs(libsToType) do
|
23a38f47
suhongyang
new passives effect
|
66
|
-- init eventLib
|
46fac6f1
zhouahaihai
酱料
|
67
68
69
70
71
72
73
|
if type(eventType) == "table" then
for _, temp in ipairs(eventType) do
eventLib[temp] = {}
end
else
eventLib[eventType] = {}
end
|
23a38f47
suhongyang
new passives effect
|
74
|
-- needEventType 只获取这个事件类型
|
46fac6f1
zhouahaihai
酱料
|
75
76
77
78
79
|
if not needEventType or eventLib[needEventType] then
for id, data in pairs(csvdb[lib]) do
if data.levelchapter == chapter then
if checkIsIn(level, data.leveltype, data.levellimit) then
if type(eventType) == "table" then
|
1607a7f0
zhouahaihai
冒险事件 new
|
80
81
|
eventLib[eventType[data.type]][data.BlockEventType] = eventLib[eventType[data.type]][data.BlockEventType] or {}
eventLib[eventType[data.type]][data.BlockEventType][id] = {showup = data.showup, limit = data.limit}
|
46fac6f1
zhouahaihai
酱料
|
82
|
else
|
1607a7f0
zhouahaihai
冒险事件 new
|
83
84
|
eventLib[eventType][data.BlockEventType] = eventLib[eventType][data.BlockEventType] or {}
eventLib[eventType][data.BlockEventType][id] = {showup = data.showup, limit = data.limit}
|
46fac6f1
zhouahaihai
酱料
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
end
end
end
end
if needEventType then
break
end
end
end
return eventLib
end
-- 生成地图 是否可以生成地图上层判断
local function randomAdvMap(role, chapterId, level, notNotify)
local chapterData = csvdb["adv_chapterCsv"][chapterId]
|
1607a7f0
zhouahaihai
冒险事件 new
|
100
101
102
103
104
105
106
107
|
if not chapterData then
error("chapterId " .. chapterId .. " dont exist!")
return
end
if level > chapterData.limitlevel then
error("level overflow!")
return
end
|
46fac6f1
zhouahaihai
酱料
|
108
109
110
|
--随出地图
local raw_pool = chapterData.mapid:toArray(true, "=")
local advInfo = role:getProperty("advInfo")
|
b0fe1817
zhouahaihai
冒险分数
|
111
|
|
46fac6f1
zhouahaihai
酱料
|
112
113
|
local lastMapId = advInfo.mapId --非同一层不连续随出同一张类似的地图
local lastChapterId = advInfo.chapter
|
b0fe1817
zhouahaihai
冒险分数
|
114
|
local lastScore = advInfo.score or {} -- 分数
|
b0fe1817
zhouahaihai
冒险分数
|
115
|
|
46fac6f1
zhouahaihai
酱料
|
116
117
118
119
120
121
122
123
124
|
local pool = {}
for _, mapId in ipairs(raw_pool) do
local temp = csvdb["mapCsv"][mapId]
if temp and (lastChapterId == chapterId or lastMapId ~= mapId) then --非同一层不连续随出同一张类似的地图
if checkIsIn(level, temp.leveltype, temp.levellimit) then
table.insert(pool, mapId)
end
end
end
|
1607a7f0
zhouahaihai
冒险事件 new
|
125
126
127
128
|
if not next(pool) then
error("mapIds is empty!")
return
end
|
46fac6f1
zhouahaihai
酱料
|
129
130
131
|
local mapId = pool[math.randomInt(1, #pool)]
--随出事件
local mapData = csvdb["map_" .. csvdb["mapCsv"][mapId]["path"] .. "Csv"]
|
1607a7f0
zhouahaihai
冒险事件 new
|
132
133
134
135
|
if not mapData then
error("mapId " .. mapId .. " dont exist!")
return
end
|
46fac6f1
zhouahaihai
酱料
|
136
|
|
46fac6f1
zhouahaihai
酱料
|
137
138
139
140
|
table.clear(advInfo)
advInfo.chapter = chapterId
advInfo.level = level
advInfo.mapId = mapId
|
b0fe1817
zhouahaihai
冒险分数
|
141
|
advInfo.score = lastScore
|
46fac6f1
zhouahaihai
酱料
|
142
143
|
advInfo.enemyId = 1 --怪递增的索引
advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁
|
46fac6f1
zhouahaihai
酱料
|
144
|
--事件随机
|
1607a7f0
zhouahaihai
冒险事件 new
|
145
|
local eventLib = getEventLib(chapterId, level) -- 同时记录出现次数
|
46fac6f1
zhouahaihai
酱料
|
146
147
148
149
150
|
local monsterEvents = {} --处理钥匙掉落
local haveBoss = false
local function randomEvent(roomId, blockId, eventType)
if advInfo.rooms[roomId]["event"][blockId] then return end --已经有事件了 不覆盖
|
1607a7f0
zhouahaihai
冒险事件 new
|
151
152
153
154
155
156
157
|
local etype, especial = eventType, 0
if eventType > 100 then -- 特殊事件(固定)
etype = math.floor(eventType / 100)
especial = eventType % 100
end
local event = {etype = etype}
|
46fac6f1
zhouahaihai
酱料
|
158
|
local randomFunc = {}
|
1607a7f0
zhouahaihai
冒险事件 new
|
159
160
161
162
|
local function randomCommon()
if not eventLib[etype] or not next(eventLib[etype]) or not eventLib[etype][especial] or not next(eventLib[etype][especial]) then return false end
event.id = math.randWeight(eventLib[etype][especial], "showup")
|
3f9c1e7a
zhouhaihai
加个保护
|
163
|
if not event.id then return false end
|
1607a7f0
zhouahaihai
冒险事件 new
|
164
165
166
167
168
169
170
|
if eventLib[etype][especial][event.id].limit > 1 then
eventLib[etype][especial][event.id].limit = eventLib[etype][especial][event.id].limit - 1
elseif eventLib[etype][especial][event.id].limit == 1 then
eventLib[etype][especial][event.id] = nil
end
end
|
46fac6f1
zhouahaihai
酱料
|
171
172
173
174
|
--入口
randomFunc[AdvEventType.In] = function()end
--出口
randomFunc[AdvEventType.Out] = function() end
|
46fac6f1
zhouahaihai
酱料
|
175
176
|
--boss
randomFunc[AdvEventType.BOSS] = function()
|
1607a7f0
zhouahaihai
冒险事件 new
|
177
178
179
180
|
if haveBoss then return false end
if randomCommon() == false then
return false
end
|
46fac6f1
zhouahaihai
酱料
|
181
|
haveBoss = true
|
46fac6f1
zhouahaihai
酱料
|
182
183
184
|
end
--怪物
randomFunc[AdvEventType.Monster] = function()
|
1607a7f0
zhouahaihai
冒险事件 new
|
185
186
187
|
if randomCommon() == false then
return false
end
|
46fac6f1
zhouahaihai
酱料
|
188
189
|
table.insert(monsterEvents, event)
end
|
1607a7f0
zhouahaihai
冒险事件 new
|
190
|
|
46fac6f1
zhouahaihai
酱料
|
191
|
--选择点
|
1607a7f0
zhouahaihai
冒险事件 new
|
192
|
randomFunc[AdvEventType.Choose] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
193
|
--掉落点
|
1607a7f0
zhouahaihai
冒险事件 new
|
194
|
randomFunc[AdvEventType.Drop] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
195
|
--交易所
|
1607a7f0
zhouahaihai
冒险事件 new
|
196
|
randomFunc[AdvEventType.Trader] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
197
|
--建筑
|
1607a7f0
zhouahaihai
冒险事件 new
|
198
|
randomFunc[AdvEventType.Build] = randomCommon
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
199
200
201
202
203
|
--陷阱
randomFunc[AdvEventType.Trap] = randomCommon
--点击生效
randomFunc[AdvEventType.Click] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
204
|
|
1607a7f0
zhouahaihai
冒险事件 new
|
205
206
|
if randomFunc[etype] then
if randomFunc[etype]() ~= false then
|
46fac6f1
zhouahaihai
酱料
|
207
208
209
210
|
advInfo.rooms[roomId]["event"][blockId] = event
end
end
end
|
23a38f47
suhongyang
new passives effect
|
211
|
local stagePool = {["global"] = {}}
|
46fac6f1
zhouahaihai
酱料
|
212
213
214
215
216
217
218
219
220
221
222
223
|
for roomId, roomName in pairs(mapData["rooms"]) do
stagePool[roomId] = {}
advInfo.rooms[roomId] = {event = {}, open = {}} -- 事件, open open == 1 房间内地块全部开放
local roomData
if roomName == "path" then
roomData = mapData["path"]
else
roomName = roomName:gsub("/", "_")
roomData = csvdb["room_" .. roomName .. "Csv"]
end
for blockId, stageType in pairs(roomData["blocks"]) do
if AdvSpecialStage[stageType] then
|
61dc5eb6
suhongyang
fix global to local
|
224
|
local eventType = AdvEventType[AdvSpecialStage[stageType]] -- 地块固定类型
|
46fac6f1
zhouahaihai
酱料
|
225
226
227
228
229
230
231
232
233
234
235
236
|
randomEvent(roomId, blockId, eventType)
else
stagePool["global"][stageType] = stagePool["global"][stageType] or {}
stagePool[roomId][stageType] = stagePool[roomId][stageType] or {}
table.insert(stagePool["global"][stageType], {room = roomId, block = blockId})
stagePool[roomId][stageType][blockId] = 1
end
end
end
-- 全地图事件 优先级高
for stageType, events in pairs(mapData["events"]) do
for _, event in ipairs(events) do
|
58559948
zhouhaihai
getall gm
|
237
|
local lastCount = stagePool["global"][stageType] and #stagePool["global"][stageType] or 0
|
46fac6f1
zhouahaihai
酱料
|
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
if lastCount <= 0 then break end
if math.randomFloat(0, 1) <= (event["rate"] or 1) then
local count = math.randomInt(math.min(lastCount, event["minc"]), math.min(lastCount, event["maxc"]))
for i = 1, count do
local idx = math.randomInt(1, lastCount)
local cur = stagePool["global"][stageType][idx]
randomEvent(cur["room"], cur["block"], event["event"])
table.remove(stagePool["global"][stageType], idx)
lastCount = lastCount - 1
stagePool[cur["room"]][stageType][cur["block"]] = nil
end
end
end
end
-- 随机单个房间的事件
for roomId, roomName in pairs(mapData["rooms"]) do
local roomData
if roomName == "path" then
roomData = mapData["path"]
else
roomName = roomName:gsub("/", "_")
roomData = csvdb["room_" .. roomName .. "Csv"]
end
for stageType, events in pairs(roomData["events"]) do
local bpool = {}
if stagePool[roomId][stageType] then
for block, _ in pairs(stagePool[roomId][stageType]) do
table.insert(bpool, block)
end
end
for _, event in ipairs(events) do
if #bpool <= 0 then break end
if math.randomFloat(0, 1) <= (event["rate"] or 1) then
local count = math.randomInt(math.min(#bpool, event["minc"]), math.min(#bpool, event["maxc"]))
for i = 1, count do
local idx = math.randomInt(1, #bpool)
randomEvent(roomId, bpool[idx], event["event"])
table.remove(bpool, idx)
end
end
end
end
end
if not haveBoss then
if not next(monsterEvents) then
print("这个地图没有钥匙!!! mapId : " .. mapId)
else
local event = monsterEvents[math.randomInt(1, #monsterEvents)]
|
1607a7f0
zhouahaihai
冒险事件 new
|
286
|
event.item = {ItemId.AdvKey, 1} --掉落钥匙
|
46fac6f1
zhouahaihai
酱料
|
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
|
end
end
end
--块类型
local Block = class("Block")
function Block:ctor(blockId, event, isOpen)
self.blockId = blockId
self.col, self.row = getCrById(self.blockId)
self.isOpen = isOpen and true or false
self.event = event -- 拿到的是引用可以直接更新
end
function Block:isBoss()
if not self.event then return end
return self.event["etype"] == AdvEventType.BOSS
end
--事件有需要额外处理的部分
function Block:open(adv, room)
--如果翻开有数据处理在这里处理
local randomFunc = {}
--怪
randomFunc[AdvEventType.Monster] = function()
self.event.mId = adv.advInfo.enemyId --给怪一个有序id 回合逻辑时使用
adv.advInfo.enemyId = adv.advInfo.enemyId + 1
|
36c30c5c
zhouahaihai
冒险
|
312
|
local enemy = adv.battle:getEnemy(room.roomId, self.blockId)
|
46fac6f1
zhouahaihai
酱料
|
313
314
315
|
if enemy then
enemy:unlock(self.event.mId)
else
|
02c4de8d
zhouahaihai
增加 固有技
|
316
|
enemy = adv.battle:addEnemy(room, self)
|
46fac6f1
zhouahaihai
酱料
|
317
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
318
|
enemy:triggerPassive(Passive.BORN_ONCE)
|
46fac6f1
zhouahaihai
酱料
|
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
end
randomFunc[AdvEventType.BOSS] = randomFunc[AdvEventType.Monster]
--掉落
randomFunc[AdvEventType.Drop] = function()
self.event.item = csvdb["event_dropCsv"][self.event.id]["range"]:randWeight(true)
end
--交易
randomFunc[AdvEventType.Trader] = function()
local data = csvdb["event_traderCsv"][self.event.id]
self.event.shop = {}
self.event.status = "" --购买次数状态 1 就是购买过了 -- 购买id就是shop索引
for i = 1, 10 do
local numS, rangeS = "num" .. i, "range" .. i
if data[numS] and data[rangeS] then
for j = 1, data[numS] do
table.insert(self.event.shop, data[rangeS]:randWeight(true))
end
else
break
end
end
end
--建筑
|
36c30c5c
zhouahaihai
冒险
|
342
|
randomFunc[AdvEventType.Build] = function()
|
46fac6f1
zhouahaihai
酱料
|
343
344
345
346
347
348
349
350
|
local data = csvdb["event_buildingCsv"][self.event.id]
self.event.effect = data["range"]:randWeight(true) --随出建筑效果
if self.event.effect[1] == 1 then --获得某道具
local reward = csvdb["event_dropCsv"][self.event.effect[2]]["range"]:randWeight(true)
self.event.effect[2] = reward[1]
self.event.effect[3] = reward[2]
end
end
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
351
352
353
354
355
|
randomFunc[AdvEventType.Trap] = function()
local data = csvdb["event_trapCsv"][self.event.id]
for _, buffId in ipairs(data.effect:toArray(true, "=")) do
adv.battle.player:addBuff(buffId)
end
|
386ca58e
zhouhaihai
优化log
|
356
|
adv:backTrap()
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
357
358
|
room:clearBEvent(self)
end
|
46fac6f1
zhouahaihai
酱料
|
359
360
361
362
363
|
if self.event then -- 随机出具体的事件
if randomFunc[self.event.etype] then
randomFunc[self.event.etype]()
end
end
|
36c30c5c
zhouahaihai
冒险
|
364
|
self.isOpen = true
|
46fac6f1
zhouahaihai
酱料
|
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
|
end
local Room = class("Room")
function Room:ctor(adv, roomId, csvData, info, isPath)
self.roomId = roomId
self.col, self.row = getCrById(self.roomId)
self.isPath = isPath
self.isBossRoom = false -- boss房间 --击败boss 以后重置为false
self.info = info -- 拿到引用 方便更新advInfo
self.isShow = false
self.blocks = {}
for blockId, _ in pairs(csvData["blocks"]) do
self.blocks[blockId] = Block.new(blockId, info.event[blockId], info.open == 1 or info.open[blockId])
if not self.isPath and self.blocks[blockId]:isBoss() then
self.isBossRoom = true
end
if self.blocks[blockId].isOpen then
self.isShow = true
else
if self.blocks[blockId].event and self.blocks[blockId].event.etype == AdvEventType.In then -- 开放
self.isShow = true
self.blocks[blockId].isOpen = true
self.info.open[blockId] = 1
--入口房间只会在这里首次展示开放 --触发固有技
adv:triggerPassive(Passive.ROOM_SHOW, {roomId = self.roomId})
end
end
end
end
function Room:tranGToL(c, r)
return c - self.col, r - self.row
end
function Room:tranLtoG(c, r)
return c + self.col, r + self.row
end
function Room:getBByGPos(c, r)
local c, r = self:tranGToL(c, r)
return self.blocks[getIdByCr(c, r)]
end
function Room:openBlock(block, adv)
if self.blocks[block.blockId] ~= block then return end
if block.isOpen == true then return end
|
36c30c5c
zhouahaihai
冒险
|
413
|
if self.isBossRoom then
|
46fac6f1
zhouahaihai
酱料
|
414
|
for _, _block in pairs(self.blocks) do
|
36c30c5c
zhouahaihai
冒险
|
415
416
417
418
419
420
421
422
423
424
|
_block:open(adv, self)
end
else
block:open(adv, self)
end
local allOpen = true
for _, _block in pairs(self.blocks) do
if not _block.isOpen then
allOpen = false
break
|
46fac6f1
zhouahaihai
酱料
|
425
426
427
428
429
430
431
432
433
|
end
end
if allOpen then
self.info.open = 1
else
self.info.open[block.blockId] = 1
end
|
b0fe1817
zhouahaihai
冒险分数
|
434
435
|
adv:scoreChange(AdvScoreType.Block)
|
46fac6f1
zhouahaihai
酱料
|
436
437
438
439
440
441
442
443
444
|
if not self.isShow then
self.isShow = true
--首次展示房间
adv:triggerPassive(Passive.ROOM_SHOW, {roomId = self.roomId})
end
end
function Room:clearBEvent(block)
if self.blocks[block.blockId] ~= block then return end
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
445
446
447
448
|
if block.event.etype == AdvEventType.Trap then -- 记录陷阱位置
self.info.trap = self.info.trap or {}
self.info.trap[block.blockId] = block.event.id
end
|
46fac6f1
zhouahaihai
酱料
|
449
450
451
452
453
454
455
456
457
458
459
460
461
|
block.event = nil
self.info.event[block.blockId] = nil
end
local Adv = class("Adv")
function Adv:ctor(owner)
assert(owner, "Adv instance must have owner(role)")
self.owner = owner
self.advInfo = self.owner:getProperty("advInfo") --这个变量置空使用 table.clear
self.advTeam = self.owner:getProperty("advTeam") --这个变量置空使用 table.clear
self:clear()
|
36c30c5c
zhouahaihai
冒险
|
462
|
self.backEvents = {} --发给客户端的事件组
|
e459a5fc
suhongyang
战斗回合检查同步以及回合数据缓存
|
463
|
self.tempBackEvents = {} --发给客户端的事件组(缓存)
|
46fac6f1
zhouahaihai
酱料
|
464
465
466
467
468
469
470
471
472
473
474
|
end
-- 清空自己组织的数据
function Adv:clear()
self.rooms = {}
self.cachePassiveEvent = {} -- 在battle 没有创建成功时 触发的被动技信息
self.battle = nil -- 战斗逻辑
end
--关卡通关,非层 score < 0 失败
function Adv:over(success)
|
b0fe1817
zhouahaihai
冒险分数
|
475
476
|
local score = self:getScore()
local scoreInfo = self.advInfo.score
|
00115a7a
zhouahaihai
奖励发放
|
477
|
local reward
|
46fac6f1
zhouahaihai
酱料
|
478
|
if success then
|
46fac6f1
zhouahaihai
酱料
|
479
|
self.owner:updateProperty({field = "advPass", self.owner:getProperty("advPass"):setv(self.advInfo.chapter, score)})
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
480
|
reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap())
|
00e663bd
zhouhaihai
剧情相关
|
481
482
|
self.owner:checkTaskEnter(self.owner.TaskType.AdvPass, {id = self.advInfo.chapter})
|
46fac6f1
zhouahaihai
酱料
|
483
484
485
486
|
end
table.clear(self.advInfo) --清空advInfo
self.advTeam.player = nil --重置玩家的数据
self:clear()
|
00115a7a
zhouahaihai
奖励发放
|
487
|
|
bedca62d
zhouahaihai
冒险
|
488
|
self.owner:updateProperty({field = "advItems", value = ""})
|
00115a7a
zhouahaihai
奖励发放
|
489
|
|
b0fe1817
zhouahaihai
冒险分数
|
490
|
self:backEnd(success, score, scoreInfo, reward)
|
46fac6f1
zhouahaihai
酱料
|
491
492
|
end
|
ec87b4a5
zhouahaihai
冒险 完善
|
493
|
function Adv:exit()
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
494
|
self:over(false)
|
ec87b4a5
zhouahaihai
冒险 完善
|
495
496
497
|
self:saveDB()
end
|
46fac6f1
zhouahaihai
酱料
|
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
|
function Adv:getMapInfo()
if not next(self.advInfo) then return end
return csvdb["mapCsv"][self.advInfo.mapId]
end
function Adv:getMapData()
local mapInfo = self:getMapInfo()
if not mapInfo then return end
return csvdb["map_" .. self:getMapInfo()["path"] .. "Csv"]
end
function Adv:initByInfo()
self:clear()
if not next(self.advInfo) then return end --未初始化的 advInfo
local mapData = self:getMapData()
if not mapData then return end
for roomId, roomName in pairs(mapData["rooms"]) do
if roomName == "path" then
self.rooms[roomId] = Room.new(self, roomId, mapData["path"], self.advInfo.rooms[roomId], true)
else
roomName = roomName:gsub("/", "_")
self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], self.advInfo.rooms[roomId], false)
end
end
self:initBattle()
return true
end
function Adv:triggerPassive(condType, params)
if not self.battle then
table.insert(self.cachePassiveEvent, {condType, params})
else
self.battle:triggerPassive(condType, params)
end
end
function Adv:initBattle()
self.battle = require("adv.AdvBattle").new(self)
for _, passiveC in ipairs(self.cachePassiveEvent) do
self.battle:triggerPassive(passiveC[1], passiveC[2])
end
self.cachePassiveEvent = {}
end
-- 随机地图
function Adv:initByChapter(chapterId, level, notNotify)
|
36c30c5c
zhouahaihai
冒险
|
546
|
level = level or 1
|
46fac6f1
zhouahaihai
酱料
|
547
|
randomAdvMap(self.owner, chapterId, level, notNotify)
|
b0fe1817
zhouahaihai
冒险分数
|
548
549
550
551
|
if not next(self.advInfo) then return end
if level > 1 then
self:scoreChange(AdvScoreType.Level)
end
|
46fac6f1
zhouahaihai
酱料
|
552
|
self:initByInfo() --初始化
|
36c30c5c
zhouahaihai
冒险
|
553
|
self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}, notNotify)
|
46fac6f1
zhouahaihai
酱料
|
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
|
end
--获取,某个位置上的 room 和 block
function Adv:getRBByPos(c, r)
for roomId, room in pairs(self.rooms) do
local block = room:getBByGPos(c, r)
if block then
return room, block
end
end
end
function Adv:getAroundBlocks(room, block)
local blocks = {}
local range = {1, -1}
local col, row = room:tranLtoG(block.col, block.row)
for _, add in ipairs(range) do
local rroom, rblock = self:getRBByPos(col + add, row)
if rroom then
table.insert(blocks, {rroom, rblock})
end
end
for _, add in ipairs(range) do
local rroom, rblock = self:getRBByPos(col, row + add)
if rroom then
table.insert(blocks, {rroom, rblock})
end
end
return blocks
end
--随机一个空的位置生成怪, 如果没有就没有
|
02c4de8d
zhouahaihai
增加 固有技
|
586
587
588
589
590
591
592
593
594
595
596
|
function Adv:addNewMonsterRand(monsterId, where)
local room, block
if where then
room, block = where[1], where[2]
else
local pool = {}
for _, room_ in pairs(self.rooms) do
for _, block_ in pairs(room_.blocks) do
if block_.isOpen and not block_.event then
table.insert(pool, {room_, block_})
end
|
46fac6f1
zhouahaihai
酱料
|
597
598
|
end
end
|
02c4de8d
zhouahaihai
增加 固有技
|
599
600
601
|
if not next(pool) then return end
local idx = math.randomInt(1, #pool)
room, block = pool[idx][1], pool[idx][2]
|
46fac6f1
zhouahaihai
酱料
|
602
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
603
|
|
9cffb42b
zhouahaihai
抉择点 建筑
|
604
605
|
if not monsterId then
local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster)
|
1607a7f0
zhouahaihai
冒险事件 new
|
606
607
|
if not next(eventLib[AdvEventType.Monster][0]) then return false end
monsterId = math.randWeight(eventLib[AdvEventType.Monster][0], "showup")
|
9cffb42b
zhouahaihai
抉择点 建筑
|
608
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
609
610
611
|
local event = {etype = AdvEventType.Monster, mId = self.advInfo.enemyId}
self.advInfo.enemyId = self.advInfo.enemyId + 1
|
9cffb42b
zhouahaihai
抉择点 建筑
|
612
|
event.id = monsterId
|
46fac6f1
zhouahaihai
酱料
|
613
614
|
block.event = event
room.info.event[block.blockId] = event
|
02c4de8d
zhouahaihai
增加 固有技
|
615
616
|
self.battle:addEnemy(room, block):triggerPassive(Passive.BORN_ONCE)
|
46fac6f1
zhouahaihai
酱料
|
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
|
return room, block
end
-- 随机翻开 num 个 以开放的房间的 地块
function Adv:openBlockRand(num)
local pool = {}
for _, room in pairs(self.rooms) do
if room.isShow and not room.isPath then
for _, block in pairs(room.blocks) do
if not block.isOpen then
table.insert(pool, {room.roomId, block.blockId})
end
end
end
end
if #pool <= num then
for _, temp in ipairs(pool) do
self:openBlock(temp[1], temp[2])
end
else
for i = 1, num do
local idx = math.randomInt(1, #pool)
self:openBlock(pool[idx][1], pool[idx][2])
table.remove(pool, idx)
end
end
end
-- 打开一个地块
function Adv:openBlock(roomId, blockId)
local room = self.rooms[roomId]
|
02c4de8d
zhouahaihai
增加 固有技
|
647
|
if not room then return end
|
46fac6f1
zhouahaihai
酱料
|
648
|
local block = room.blocks[blockId]
|
02c4de8d
zhouahaihai
增加 固有技
|
649
|
if not block then return end
|
46fac6f1
zhouahaihai
酱料
|
650
651
652
653
654
655
|
room:openBlock(block, self)
self:backBlockChange(roomId, blockId)
end
-- 在冒险中获得的物品都发放在冒险背包内
function Adv:award(gift, params)
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
656
|
params = params or {}
|
46fac6f1
zhouahaihai
酱料
|
657
658
659
660
661
662
663
664
665
666
|
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")
for itemId, count in pairs(tgift) do
|
b0fe1817
zhouahaihai
冒险分数
|
667
668
669
|
if count > 0 then
self:scoreChange(AdvScoreType.Item, {itemId, count})
end
|
46fac6f1
zhouahaihai
酱料
|
670
671
672
673
674
675
676
677
678
|
local origin = items:getv(itemId, 0)
local nums = origin + count
if nums <= 0 then
items = items:delk(itemId)
nums = 0
else
items = items:incrv(itemId, count)
end
end
|
9cffb42b
zhouahaihai
抉择点 建筑
|
679
|
|
46fac6f1
zhouahaihai
酱料
|
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
|
self.owner:updateProperty({field = "advItems", value = items, notNotify = params.notNotify})
return tgift
end
-- 消耗物品 优先冒险背包 --check 只是检查够不够
function Adv:cost(item, params, check)
local items = self.owner:getProperty("advItems")
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
end
if next(less) and not self.owner:checkItemEnough(less) then return end --不够
if check then return true end
self:award(advCost, params)
self.owner:costItems(less, params)
return true
end
--事件点击处理
local function clickOut(self, room, block, params)
|
36c30c5c
zhouahaihai
冒险
|
710
|
if self:cost({[ItemId.AdvKey] = 1}, {}) then
|
46fac6f1
zhouahaihai
酱料
|
711
712
713
714
715
716
717
718
719
720
721
722
|
if self.advInfo.level >= csvdb["adv_chapterCsv"][self.advInfo.chapter].limitlevel then --关卡结束
self:over(true)
else
self:initByChapter(self.advInfo.chapter, self.advInfo.level + 1, true)
self:backNext() --下一关
end
return true
end
end
--战斗 普通攻击
local function clickMonster(self, room, block, params)
|
ae9a74b5
suhongyang
返回miss,快速战斗逻辑
|
723
|
self.battle:battleBegin(room.roomId, block.blockId, params.quick)
|
46fac6f1
zhouahaihai
酱料
|
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
|
return true
end
local function clickChoose(self, room, block, params)
local choose = params.choose
local chooseData = csvdb["event_chooseCsv"][block.event.id]
if not chooseData or not chooseData["button".. choose .."cond"] then return end
local cond = chooseData["button".. choose .."cond"]:toArray(true, "=")
local checkCond = {
-- 拥有道具
[1] = function()
if self:cost({[cond[2]] = cond[3]}, {}, true) then
return true
end
end,
-- xx角色(todo 队长)
[2] = function()
for slot, heroId in pairs(self.advTeam.heros) do
if self.owner.heros[heroId] then
if self.owner.heros[heroId]:getProperty("type") == cond[2] then
return true
end
end
end
end,
--消灭所有怪
[3] = function()
for _, room in pairs(self.rooms) do
|
4ae223df
zhouahaihai
Buff bug
|
753
|
for _, block in pairs(room.blocks) do
|
46fac6f1
zhouahaihai
酱料
|
754
755
756
757
758
759
760
761
762
763
764
765
766
767
|
if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then
return
end
end
end
return true
end,
--制定属性 >
[4] = function()
if (self.battle.player[AttsEnumEx[cond[2]]] or 0) > cond[3] then
return true
end
end,
}
|
9cffb42b
zhouahaihai
抉择点 建筑
|
768
769
|
assert(not cond[1] or checkCond[cond[1]], "error cond, event_chooseCsv id :" .. block.event.id)
if cond[1] and not checkCond[cond[1]]() then return end
|
02c4de8d
zhouahaihai
增加 固有技
|
770
|
local clearBlock = true
|
e10edb5f
zhouahaihai
冒险事件新
|
771
772
773
774
775
776
|
local effects = chooseData["button".. choose .."effect"]:toTableArray(true)
for _, effect in ipairs(effects) do
if effect[1] == 1 then
local reward = csvdb["event_dropCsv"][effect[2]]["range"]:randWeight(true)
effect[2] = reward[1]
effect[3] = reward[2]
|
46fac6f1
zhouahaihai
酱料
|
777
|
end
|
e10edb5f
zhouahaihai
冒险事件新
|
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
|
local doEffect = {
[1] = function() -- 获得某道具N个
self:backReward(self:award({[effect[2]] = effect[3]}, {}))
end,
[2] = function() --获得冒险buff
self.battle.player:addBuff(effect[2])
end,
[3] = function() --发现怪物
self:addNewMonsterRand(effect[2], {room, block})
clearBlock = false
end,
[4] = function() --无事发生
end
}
assert(doEffect[effect[1]], "error effect, event_chooseCsv id :" .. block.event.id)
doEffect[effect[1]]()
end
|
02c4de8d
zhouahaihai
增加 固有技
|
797
798
799
|
if clearBlock then
room:clearBEvent(block)
end
|
46fac6f1
zhouahaihai
酱料
|
800
801
802
803
804
805
|
return true
end
local function clickDrop(self, room, block, params)
local reward = {}
if not block.event.item then return end
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
806
|
local reward = self:award({[block.event.item[1]] = block.event.item[2]})
|
46fac6f1
zhouahaihai
酱料
|
807
808
809
810
811
812
813
814
815
816
817
818
819
|
room:clearBEvent(block)
self:backReward(reward)
return true
end
local function clickTrader(self, room, block, params)
local buyId = params.id
local traderData = csvdb["event_traderCsv"][block.event.id]
if not traderData then return end -- 偷偷改表了
if not block.event.shop or not block.event.shop[buyId] then return end
if (block.event.status or ""):getv(buyId, 0) == 1 then return end -- 买过了
|
e10edb5f
zhouahaihai
冒险事件新
|
820
|
if not self:cost({[traderData.type] = block.event.shop[buyId][3]}, {}) then return end --不够
|
46fac6f1
zhouahaihai
酱料
|
821
|
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
822
|
local reward = self:award({[block.event.shop[buyId][1]] = block.event.shop[buyId][2]})
|
46fac6f1
zhouahaihai
酱料
|
823
824
825
826
827
828
829
830
831
|
block.event.status = block.event.status:setv(buyId, 1)
self:backReward(reward)
return true
end
local function clickBuild(self, room, block, params)
local buildData = csvdb["event_buildingCsv"][block.event.id]
if not buildData then return end-- 偷偷改表了
if not block.event.effect then return end -- 没有效果 气人不
|
02c4de8d
zhouahaihai
增加 固有技
|
832
|
local clearBlock = true
|
46fac6f1
zhouahaihai
酱料
|
833
834
835
836
837
838
839
840
841
842
|
local effect = block.event.effect
--todo 效果生效
local doEffect = {
[1] = function() -- 获得某道具N个
self:backReward(self:award({[effect[2]] = effect[3]}, {}))
end,
[2] = function() --获得冒险buff
self.battle.player:addBuff(effect[2])
end,
[3] = function() --发现怪物
|
02c4de8d
zhouahaihai
增加 固有技
|
843
844
|
self:addNewMonsterRand(effect[2], {room, block})
clearBlock = false
|
46fac6f1
zhouahaihai
酱料
|
845
846
847
848
849
|
end,
[4] = function() --无事发生
end
}
assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id)
|
e10edb5f
zhouahaihai
冒险事件新
|
850
|
if not self:cost(buildData.required:toNumMap(), {}) then return end
|
46fac6f1
zhouahaihai
酱料
|
851
|
doEffect[effect[1]]()
|
02c4de8d
zhouahaihai
增加 固有技
|
852
853
854
|
if clearBlock then
room:clearBEvent(block)
end
|
46fac6f1
zhouahaihai
酱料
|
855
856
857
|
return true
end
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
|
local function clickClick(self, room, block, params)
local clickData = csvdb["event_clickCsv"][block.event.id]
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)
reward[item[1]] = (reward[item[1]] or 0) + reward[item[2]]
end
self:backReward(self:award(reward, {}))
end,
}
if clearBlock then
room:clearBEvent(block)
end
|
f20cc9ca
zhouhaihai
点击点返回清空信息
|
880
|
return true
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
881
882
|
end
|
46fac6f1
zhouahaihai
酱料
|
883
884
885
886
887
888
889
890
|
local eventCallFunc = {
[AdvEventType.Out] = clickOut,
[AdvEventType.BOSS] = clickMonster,
[AdvEventType.Monster] = clickMonster,
[AdvEventType.Choose] = clickChoose,
[AdvEventType.Drop] = clickDrop,
[AdvEventType.Trader] = clickTrader,
[AdvEventType.Build] = clickBuild,
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
891
|
[AdvEventType.Click] = clickClick,
|
46fac6f1
zhouahaihai
酱料
|
892
893
894
895
896
897
898
899
900
901
|
}
--点击处理 roomId, blockId
--params 某些事件需要的客户端传递的参数
function Adv:clickBlock(roomId, blockId, params)
local room = self.rooms[roomId]
if not room then return end
local block = room.blocks[blockId]
if not block then return end
|
46fac6f1
zhouahaihai
酱料
|
902
|
local status = false
|
36c30c5c
zhouahaihai
冒险
|
903
|
local clickEvent = false
|
46fac6f1
zhouahaihai
酱料
|
904
|
if not block.isOpen then
|
36c30c5c
zhouahaihai
冒险
|
905
906
907
908
909
910
911
912
913
|
local canOpen = false --如果未开放是否可以开放
local hadMonster = false -- 周围是否有解锁的怪未击败
for _, one in ipairs(self:getAroundBlocks(room, block)) do
local _room, _block = one[1], one[2]
if _block.isOpen then canOpen = true end
if _block.isOpen and _block.event and (_block.event.etype == AdvEventType.BOSS or _block.event.etype == AdvEventType.Monster) then
hadMonster = true
end
end
|
46fac6f1
zhouahaihai
酱料
|
914
915
916
917
918
|
if canOpen and not hadMonster then --开放
room:openBlock(block, self)
status = true
end
else
|
36c30c5c
zhouahaihai
冒险
|
919
|
clickEvent = true
|
46fac6f1
zhouahaihai
酱料
|
920
921
922
923
924
|
--点了空地
if not block.event then
return
end
--可点击的事件
|
36c30c5c
zhouahaihai
冒险
|
925
|
if not room.isBossRoom or block.event.etype == AdvEventType.BOSS then
|
46fac6f1
zhouahaihai
酱料
|
926
927
928
929
930
|
if eventCallFunc[block.event.etype] then
status = eventCallFunc[block.event.etype](self, room, block, params)
end
end
end
|
39a6e08b
suhongyang
冒险战斗内逻辑调整
|
931
|
local needChange = true
|
ae20365b
suhongyang
Revert "修改冒险战斗逻辑"
|
932
933
934
935
936
937
938
|
if clickEvent and block.event then
if block.event.etype == AdvEventType.Out then
needChange = false
end
if (block.event.etype == AdvEventType.Monster or block.event.etype == AdvEventType.BOSS) and not self.battle:isBattleEnd() then
needChange = false
end
|
39a6e08b
suhongyang
冒险战斗内逻辑调整
|
939
940
|
end
if status and needChange then --出去了就不计算回合了
|
46fac6f1
zhouahaihai
酱料
|
941
942
943
|
self:backBlockChange(roomId, blockId)
self:afterRound()
end
|
36c30c5c
zhouahaihai
冒险
|
944
|
self:saveDB()
|
46fac6f1
zhouahaihai
酱料
|
945
946
947
|
return status
end
|
46fac6f1
zhouahaihai
酱料
|
948
949
950
951
952
953
954
955
956
957
958
959
960
961
|
--使用道具产生效果
function Adv:useItem(itemId, count, target)
count = count or 1
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 not self:cost({[itemId] = count}, {}, true) then return true end
--消耗
if itemData["function"] == 0 or itemData["function"] == 1 then
self:cost({[itemId] = count}, {})
end
--生效
if itemData.type == 1 or itemData.type == 0 then --技能
|
d27ad5e0
suhongyang
使用营养技
|
962
|
self.battle.player:releaseSkill(itemData.effect, target)
|
46fac6f1
zhouahaihai
酱料
|
963
964
965
966
967
968
969
970
|
elseif itemData.type == 2 then --掉落
local item = csvdb["event_dropCsv"][itemData.effect]["range"]:randWeight(true)
self:backReward(self:award({[item[1]] = item[2]}, {}))
else
return
end
self:afterRound()
|
36c30c5c
zhouahaihai
冒险
|
971
|
self:saveDB()
|
46fac6f1
zhouahaihai
酱料
|
972
973
974
|
return true
end
|
d27ad5e0
suhongyang
使用营养技
|
975
976
977
978
|
--使用技能
function Adv:usePotion(potionId, potionLevel, target)
-- cost
local potionData = csvdb["adv_potionCsv"][potionId][potionLevel]
|
d27ad5e0
suhongyang
使用营养技
|
979
980
981
982
983
984
985
986
|
local enemy = self.battle:getEnemy(target.roomId, target.blockId)
if not enemy then return end
--生效
if potionData.type == 1 or potionData.type == 0 then --技能
self.battle.player:releaseSkill(potionData.effect, enemy)
elseif potionData.type == 2 then --掉落
local item = csvdb["event_dropCsv"][potionData.effect]["range"]:randWeight(true)
self:backReward(self:award({[item[1]] = item[2]}, {}))
|
46fac6f1
zhouahaihai
酱料
|
987
|
else
|
d27ad5e0
suhongyang
使用营养技
|
988
|
return
|
46fac6f1
zhouahaihai
酱料
|
989
|
end
|
46fac6f1
zhouahaihai
酱料
|
990
|
self:afterRound()
|
36c30c5c
zhouahaihai
冒险
|
991
|
self:saveDB()
|
46fac6f1
zhouahaihai
酱料
|
992
993
994
|
return true
end
|
46fac6f1
zhouahaihai
酱料
|
995
|
--敌人死亡
|
02c4de8d
zhouahaihai
增加 固有技
|
996
|
function Adv:enemyDead(roomId, blockId, escape)
|
36c30c5c
zhouahaihai
冒险
|
997
998
|
local room = self.rooms[roomId]
local block = room.blocks[blockId]
|
46fac6f1
zhouahaihai
酱料
|
999
1000
|
--死了以后掉东西
if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then --处理死亡
|
36c30c5c
zhouahaihai
冒险
|
1001
1002
1003
|
if block.event.etype == AdvEventType.BOSS then
room.isBossRoom = false
end
|
02c4de8d
zhouahaihai
增加 固有技
|
1004
1005
1006
|
if escape then
room:clearBEvent(block)
else
|
b0fe1817
zhouahaihai
冒险分数
|
1007
1008
1009
|
local monsterData = csvdb["event_monsterCsv"][block.event.id]
self:scoreChange(AdvScoreType.Kill, monsterData.type)
|
02c4de8d
zhouahaihai
增加 固有技
|
1010
1011
1012
1013
1014
|
local item = block.event.item
if not item then
if block.event.etype == AdvEventType.BOSS then
item = {ItemId.AdvKey, 1}
else
|
02c4de8d
zhouahaihai
增加 固有技
|
1015
1016
1017
|
local dropData = csvdb["event_dropCsv"][monsterData.dropid]
item = dropData["range"]:randWeight(true)
end
|
46fac6f1
zhouahaihai
酱料
|
1018
|
end
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
1019
1020
1021
1022
1023
1024
1025
|
if item[1] == 0 then
room:clearBEvent(block)
else
table.clear(block.event)
block.event.etype = AdvEventType.Drop
block.event.item = item
end
|
46fac6f1
zhouahaihai
酱料
|
1026
|
end
|
46fac6f1
zhouahaihai
酱料
|
1027
1028
1029
1030
|
end
self:backBlockChange(roomId, blockId)
end
|
46fac6f1
zhouahaihai
酱料
|
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
|
function Adv:pushBackEvent(btype, params)
table.insert(self.backEvents, {btype = btype, params = params})
end
function Adv:backReward(items)
self:pushBackEvent(AdvBackEventType.Reward, {items = items})
end
-- if is player enemyId is nil
--isMax 是否是改变血量上限
function Adv:backHpChange(enemyId, change, isMax)
self:pushBackEvent(AdvBackEventType.HpChange, {enemyId = enemyId, change = change, isMax = isMax})
end
|
ae9a74b5
suhongyang
返回miss,快速战斗逻辑
|
1044
1045
1046
1047
|
function Adv:backMiss(enemyId)
self:pushBackEvent(AdvBackEventType.Miss, {enemyId = enemyId})
end
|
46fac6f1
zhouahaihai
酱料
|
1048
1049
1050
1051
|
-- if is player enemyId is nil
function Adv:backAtkChange(enemyId, change)
self:pushBackEvent(AdvBackEventType.AtkChange, {enemyId = enemyId, change = change})
end
|
e996b82a
zhouahaihai
冒险增加防御属性
|
1052
1053
1054
1055
1056
1057
|
-- if is player enemyId is nil
function Adv:backDefChange(enemyId, change)
self:pushBackEvent(AdvBackEventType.DefChange, {enemyId = enemyId, change = change})
end
|
46fac6f1
zhouahaihai
酱料
|
1058
1059
1060
1061
1062
1063
|
-- if is player enemyId is nil
function Adv:backBuff(enemyId, buffId, isDel)
self:pushBackEvent(AdvBackEventType.Buff, {enemyId = enemyId, buffId = buffId, isDel = isDel})
end
-- if is player enemyId is nil
function Adv:backSkill(enemyId, skillId, receiver)
|
36c30c5c
zhouahaihai
冒险
|
1064
|
self:pushBackEvent(AdvBackEventType.Skill, {enemyId = enemyId, skillId = skillId, receiver = receiver})
|
46fac6f1
zhouahaihai
酱料
|
1065
1066
|
end
|
4eadc2ab
suhongyang
獲得被動暫時增加log,後面可以去掉
|
1067
1068
1069
1070
1071
|
-- if is player enemyId is nil
function Adv:backPassive(enemyId, passiveId)
self:pushBackEvent(AdvBackEventType.Passive, {enemyId = enemyId, passiveId = passiveId})
end
|
46fac6f1
zhouahaihai
酱料
|
1072
1073
1074
1075
|
function Adv:backNext()
self:pushBackEvent(AdvBackEventType.Next, {})
end
|
b0fe1817
zhouahaihai
冒险分数
|
1076
1077
|
function Adv:backEnd(success, score, scoreInfo, reward)
self:pushBackEvent(AdvBackEventType.End, {success = success, score = score, scoreInfo = scoreInfo, reward = reward})
|
46fac6f1
zhouahaihai
酱料
|
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
|
end
function Adv:backBlockChange(roomId, blockId)
self:pushBackEvent(AdvBackEventType.BlockChange, {roomId = roomId, blockId = blockId})
end
function Adv:backAtk(enemyId, receiver)
self:pushBackEvent(AdvBackEventType.Atk, {enemyId = enemyId, receiver = receiver})
end
|
bedca62d
zhouahaihai
冒险
|
1088
1089
1090
1091
|
function Adv:backDead(enemyId)
self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
end
|
386ca58e
zhouhaihai
优化log
|
1092
1093
1094
|
function Adv:backTrap()
self:pushBackEvent(AdvBackEventType.Trap, {})
end
|
ec87b4a5
zhouahaihai
冒险 完善
|
1095
|
|
b0fe1817
zhouahaihai
冒险分数
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
|
function Adv:scoreChange(scoreType, pms)
local cutTypes = {}
local score = 0
cutTypes[AdvScoreType.Level] = function()
score = globalCsv.adv_score_floor
end
cutTypes[AdvScoreType.Kill] = function()
local chapterData = csvdb["adv_chapterCsv"][self.advInfo.chapter]
score = globalCsv.adv_score_monster[pms] * chapterData["monRatio"]
end
cutTypes[AdvScoreType.Item] = function()
score = csvdb["itemCsv"][pms[1]].adv_score_item * pms[2]
end
cutTypes[AdvScoreType.Hurt] = function()
score = globalCsv.adv_score_hurt * pms
end
cutTypes[AdvScoreType.Block] = function()
score = globalCsv.adv_score_block
end
if cutTypes[scoreType] then
cutTypes[scoreType]()
else
return
end
self.advInfo.score[scoreType] = self.advInfo.score[scoreType] or 0
self.advInfo.score[scoreType] = self.advInfo.score[scoreType] + score
end
function Adv:getScore()
|
e10edb5f
zhouahaihai
冒险事件新
|
1125
1126
1127
1128
1129
1130
1131
1132
|
self.advInfo.score[AdvScoreType.Level] = math.floor(self.advInfo.score[AdvScoreType.Level] or 0)
self.advInfo.score[AdvScoreType.Block] = math.floor(self.advInfo.score[AdvScoreType.Block] or 0)
self.advInfo.score[AdvScoreType.Hurt] = math.max(math.floor(self.advInfo.score[AdvScoreType.Hurt] or 0), - (self.advInfo.score[AdvScoreType.Level] + self.advInfo.score[AdvScoreType.Block]))
self.advInfo.score[AdvScoreType.Kill] = math.floor(self.advInfo.score[AdvScoreType.Kill] or 0)
self.advInfo.score[AdvScoreType.Item] = math.floor(self.advInfo.score[AdvScoreType.Item] or 0)
return self.advInfo.score[AdvScoreType.Level] + self.advInfo.score[AdvScoreType.Block] + self.advInfo.score[AdvScoreType.Hurt]
+ self.advInfo.score[AdvScoreType.Kill] + self.advInfo.score[AdvScoreType.Item]
|
b0fe1817
zhouahaihai
冒险分数
|
1133
1134
|
end
|
46fac6f1
zhouahaihai
酱料
|
1135
1136
|
function Adv:popBackEvents()
local events = self.backEvents
|
e459a5fc
suhongyang
战斗回合检查同步以及回合数据缓存
|
1137
1138
|
-- TODO 缓存数据需要分类,防止发错,暂时只有战斗,可以不分
self.tempBackEvents = events
|
46fac6f1
zhouahaihai
酱料
|
1139
1140
1141
1142
1143
1144
1145
1146
1147
|
self.backEvents = {}
return events
end
--回合事件处理
function Adv:afterRound()
if self.battle then
self.battle:afterRound()
end
|
39a6e08b
suhongyang
冒险战斗内逻辑调整
|
1148
|
-- TODO 房间回合事件
|
46fac6f1
zhouahaihai
酱料
|
1149
1150
|
end
|
36c30c5c
zhouahaihai
冒险
|
1151
1152
1153
1154
1155
1156
1157
|
function Adv:saveDB()
if self.battle then
self.battle:getDB()
end
self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam})
end
|
46fac6f1
zhouahaihai
酱料
|
1158
|
return Adv
|