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 {} -- 分数
|
040c6558
suhongyang
体力改为mp
|
115
|
local power = advInfo.power or 100 --MP
|
b0fe1817
zhouahaihai
冒险分数
|
116
|
|
46fac6f1
zhouahaihai
酱料
|
117
118
119
120
121
122
123
124
125
|
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
|
126
127
128
129
|
if not next(pool) then
error("mapIds is empty!")
return
end
|
46fac6f1
zhouahaihai
酱料
|
130
131
132
|
local mapId = pool[math.randomInt(1, #pool)]
--随出事件
local mapData = csvdb["map_" .. csvdb["mapCsv"][mapId]["path"] .. "Csv"]
|
1607a7f0
zhouahaihai
冒险事件 new
|
133
134
135
136
|
if not mapData then
error("mapId " .. mapId .. " dont exist!")
return
end
|
46fac6f1
zhouahaihai
酱料
|
137
|
|
46fac6f1
zhouahaihai
酱料
|
138
139
140
141
142
|
table.clear(advInfo)
advInfo.chapter = chapterId
advInfo.level = level
advInfo.mapId = mapId
advInfo.power = power
|
b0fe1817
zhouahaihai
冒险分数
|
143
|
advInfo.score = lastScore
|
46fac6f1
zhouahaihai
酱料
|
144
145
|
advInfo.enemyId = 1 --怪递增的索引
advInfo.rooms = {} -- {[roomId] = {event = {}, open = {}},} -- event 事件信息(具体信息查看randomEvent), open 是否解锁
|
46fac6f1
zhouahaihai
酱料
|
146
|
--事件随机
|
1607a7f0
zhouahaihai
冒险事件 new
|
147
|
local eventLib = getEventLib(chapterId, level) -- 同时记录出现次数
|
46fac6f1
zhouahaihai
酱料
|
148
149
150
151
152
|
local monsterEvents = {} --处理钥匙掉落
local haveBoss = false
local function randomEvent(roomId, blockId, eventType)
if advInfo.rooms[roomId]["event"][blockId] then return end --已经有事件了 不覆盖
|
1607a7f0
zhouahaihai
冒险事件 new
|
153
154
155
156
157
158
159
|
local etype, especial = eventType, 0
if eventType > 100 then -- 特殊事件(固定)
etype = math.floor(eventType / 100)
especial = eventType % 100
end
local event = {etype = etype}
|
46fac6f1
zhouahaihai
酱料
|
160
|
local randomFunc = {}
|
1607a7f0
zhouahaihai
冒险事件 new
|
161
162
163
164
165
166
167
168
169
170
171
|
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")
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
酱料
|
172
173
174
175
|
--入口
randomFunc[AdvEventType.In] = function()end
--出口
randomFunc[AdvEventType.Out] = function() end
|
46fac6f1
zhouahaihai
酱料
|
176
177
|
--boss
randomFunc[AdvEventType.BOSS] = function()
|
1607a7f0
zhouahaihai
冒险事件 new
|
178
179
180
181
|
if haveBoss then return false end
if randomCommon() == false then
return false
end
|
46fac6f1
zhouahaihai
酱料
|
182
|
haveBoss = true
|
46fac6f1
zhouahaihai
酱料
|
183
184
185
|
end
--怪物
randomFunc[AdvEventType.Monster] = function()
|
1607a7f0
zhouahaihai
冒险事件 new
|
186
187
188
|
if randomCommon() == false then
return false
end
|
46fac6f1
zhouahaihai
酱料
|
189
190
|
table.insert(monsterEvents, event)
end
|
1607a7f0
zhouahaihai
冒险事件 new
|
191
|
|
46fac6f1
zhouahaihai
酱料
|
192
|
--选择点
|
1607a7f0
zhouahaihai
冒险事件 new
|
193
|
randomFunc[AdvEventType.Choose] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
194
|
--掉落点
|
1607a7f0
zhouahaihai
冒险事件 new
|
195
|
randomFunc[AdvEventType.Drop] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
196
|
--交易所
|
1607a7f0
zhouahaihai
冒险事件 new
|
197
|
randomFunc[AdvEventType.Trader] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
198
|
--建筑
|
1607a7f0
zhouahaihai
冒险事件 new
|
199
|
randomFunc[AdvEventType.Build] = randomCommon
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
200
201
202
203
204
|
--陷阱
randomFunc[AdvEventType.Trap] = randomCommon
--点击生效
randomFunc[AdvEventType.Click] = randomCommon
|
46fac6f1
zhouahaihai
酱料
|
205
|
|
1607a7f0
zhouahaihai
冒险事件 new
|
206
207
|
if randomFunc[etype] then
if randomFunc[etype]() ~= false then
|
46fac6f1
zhouahaihai
酱料
|
208
209
210
211
|
advInfo.rooms[roomId]["event"][blockId] = event
end
end
end
|
23a38f47
suhongyang
new passives effect
|
212
|
local stagePool = {["global"] = {}}
|
46fac6f1
zhouahaihai
酱料
|
213
214
215
216
217
218
219
220
221
222
223
224
|
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
|
225
|
local eventType = AdvEventType[AdvSpecialStage[stageType]] -- 地块固定类型
|
46fac6f1
zhouahaihai
酱料
|
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
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
local lastCount = #stagePool["global"][stageType]
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
|
287
|
event.item = {ItemId.AdvKey, 1} --掉落钥匙
|
46fac6f1
zhouahaihai
酱料
|
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
|
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
冒险
|
313
|
local enemy = adv.battle:getEnemy(room.roomId, self.blockId)
|
46fac6f1
zhouahaihai
酱料
|
314
315
316
|
if enemy then
enemy:unlock(self.event.mId)
else
|
02c4de8d
zhouahaihai
增加 固有技
|
317
|
enemy = adv.battle:addEnemy(room, self)
|
46fac6f1
zhouahaihai
酱料
|
318
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
319
|
enemy:triggerPassive(Passive.BORN_ONCE)
|
46fac6f1
zhouahaihai
酱料
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
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
冒险
|
343
|
randomFunc[AdvEventType.Build] = function()
|
46fac6f1
zhouahaihai
酱料
|
344
345
346
347
348
349
350
351
|
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
陷阱、点击生效点
|
352
353
354
355
356
|
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
|
357
|
adv:backTrap()
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
358
359
|
room:clearBEvent(self)
end
|
46fac6f1
zhouahaihai
酱料
|
360
361
362
363
364
|
if self.event then -- 随机出具体的事件
if randomFunc[self.event.etype] then
randomFunc[self.event.etype]()
end
end
|
36c30c5c
zhouahaihai
冒险
|
365
|
self.isOpen = true
|
46fac6f1
zhouahaihai
酱料
|
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
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
冒险
|
414
|
if self.isBossRoom then
|
46fac6f1
zhouahaihai
酱料
|
415
|
for _, _block in pairs(self.blocks) do
|
36c30c5c
zhouahaihai
冒险
|
416
417
418
419
420
421
422
423
424
425
|
_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
酱料
|
426
427
428
429
430
431
432
433
434
|
end
end
if allOpen then
self.info.open = 1
else
self.info.open[block.blockId] = 1
end
|
b0fe1817
zhouahaihai
冒险分数
|
435
436
|
adv:scoreChange(AdvScoreType.Block)
|
46fac6f1
zhouahaihai
酱料
|
437
438
439
440
441
442
443
444
445
|
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
陷阱、点击生效点
|
446
447
448
449
|
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
酱料
|
450
451
452
453
454
455
456
457
458
459
460
461
462
|
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
冒险
|
463
|
self.backEvents = {} --发给客户端的事件组
|
e459a5fc
suhongyang
战斗回合检查同步以及回合数据缓存
|
464
|
self.tempBackEvents = {} --发给客户端的事件组(缓存)
|
46fac6f1
zhouahaihai
酱料
|
465
466
467
468
469
470
471
472
473
474
475
|
end
-- 清空自己组织的数据
function Adv:clear()
self.rooms = {}
self.cachePassiveEvent = {} -- 在battle 没有创建成功时 触发的被动技信息
self.battle = nil -- 战斗逻辑
end
--关卡通关,非层 score < 0 失败
function Adv:over(success)
|
b0fe1817
zhouahaihai
冒险分数
|
476
477
|
local score = self:getScore()
local scoreInfo = self.advInfo.score
|
00115a7a
zhouahaihai
奖励发放
|
478
|
local reward
|
46fac6f1
zhouahaihai
酱料
|
479
|
if success then
|
46fac6f1
zhouahaihai
酱料
|
480
|
self.owner:updateProperty({field = "advPass", self.owner:getProperty("advPass"):setv(self.advInfo.chapter, score)})
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
481
|
reward = self.owner:award(self.owner:getProperty("advItems"):toNumMap())
|
00e663bd
zhouhaihai
剧情相关
|
482
483
|
self.owner:checkTaskEnter(self.owner.TaskType.AdvPass, {id = self.advInfo.chapter})
|
46fac6f1
zhouahaihai
酱料
|
484
485
486
487
|
end
table.clear(self.advInfo) --清空advInfo
self.advTeam.player = nil --重置玩家的数据
self:clear()
|
00115a7a
zhouahaihai
奖励发放
|
488
|
|
bedca62d
zhouahaihai
冒险
|
489
|
self.owner:updateProperty({field = "advItems", value = ""})
|
00115a7a
zhouahaihai
奖励发放
|
490
|
|
b0fe1817
zhouahaihai
冒险分数
|
491
|
self:backEnd(success, score, scoreInfo, reward)
|
46fac6f1
zhouahaihai
酱料
|
492
493
|
end
|
ec87b4a5
zhouahaihai
冒险 完善
|
494
|
function Adv:exit()
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
495
|
self:over(false)
|
ec87b4a5
zhouahaihai
冒险 完善
|
496
497
498
|
self:saveDB()
end
|
46fac6f1
zhouahaihai
酱料
|
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
|
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
冒险
|
547
|
level = level or 1
|
46fac6f1
zhouahaihai
酱料
|
548
|
randomAdvMap(self.owner, chapterId, level, notNotify)
|
b0fe1817
zhouahaihai
冒险分数
|
549
550
551
552
|
if not next(self.advInfo) then return end
if level > 1 then
self:scoreChange(AdvScoreType.Level)
end
|
46fac6f1
zhouahaihai
酱料
|
553
|
self:initByInfo() --初始化
|
36c30c5c
zhouahaihai
冒险
|
554
|
self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam}, notNotify)
|
46fac6f1
zhouahaihai
酱料
|
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
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
增加 固有技
|
587
588
589
590
591
592
593
594
595
596
597
|
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
酱料
|
598
599
|
end
end
|
02c4de8d
zhouahaihai
增加 固有技
|
600
601
602
|
if not next(pool) then return end
local idx = math.randomInt(1, #pool)
room, block = pool[idx][1], pool[idx][2]
|
46fac6f1
zhouahaihai
酱料
|
603
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
604
|
|
9cffb42b
zhouahaihai
抉择点 建筑
|
605
606
|
if not monsterId then
local eventLib = getEventLib(self.advInfo.chapter, self.advInfo.level, AdvEventType.Monster)
|
1607a7f0
zhouahaihai
冒险事件 new
|
607
608
|
if not next(eventLib[AdvEventType.Monster][0]) then return false end
monsterId = math.randWeight(eventLib[AdvEventType.Monster][0], "showup")
|
9cffb42b
zhouahaihai
抉择点 建筑
|
609
|
end
|
02c4de8d
zhouahaihai
增加 固有技
|
610
611
612
|
local event = {etype = AdvEventType.Monster, mId = self.advInfo.enemyId}
self.advInfo.enemyId = self.advInfo.enemyId + 1
|
9cffb42b
zhouahaihai
抉择点 建筑
|
613
|
event.id = monsterId
|
46fac6f1
zhouahaihai
酱料
|
614
615
|
block.event = event
room.info.event[block.blockId] = event
|
02c4de8d
zhouahaihai
增加 固有技
|
616
617
|
self.battle:addEnemy(room, block):triggerPassive(Passive.BORN_ONCE)
|
46fac6f1
zhouahaihai
酱料
|
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
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
增加 固有技
|
648
|
if not room then return end
|
46fac6f1
zhouahaihai
酱料
|
649
|
local block = room.blocks[blockId]
|
02c4de8d
zhouahaihai
增加 固有技
|
650
|
if not block then return end
|
46fac6f1
zhouahaihai
酱料
|
651
652
653
654
655
656
|
room:openBlock(block, self)
self:backBlockChange(roomId, blockId)
end
-- 在冒险中获得的物品都发放在冒险背包内
function Adv:award(gift, params)
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
657
|
params = params or {}
|
46fac6f1
zhouahaihai
酱料
|
658
659
660
661
662
663
664
665
666
667
|
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
冒险分数
|
668
669
670
|
if count > 0 then
self:scoreChange(AdvScoreType.Item, {itemId, count})
end
|
46fac6f1
zhouahaihai
酱料
|
671
672
673
674
675
676
677
678
679
|
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
抉择点 建筑
|
680
|
|
46fac6f1
zhouahaihai
酱料
|
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
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
冒险
|
711
|
if self:cost({[ItemId.AdvKey] = 1}, {}) then
|
46fac6f1
zhouahaihai
酱料
|
712
713
714
715
716
717
718
719
720
721
722
723
|
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,快速战斗逻辑
|
724
|
self.battle:battleBegin(room.roomId, block.blockId, params.quick)
|
46fac6f1
zhouahaihai
酱料
|
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
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
|
754
|
for _, block in pairs(room.blocks) do
|
46fac6f1
zhouahaihai
酱料
|
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
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
抉择点 建筑
|
769
770
|
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
增加 固有技
|
771
|
local clearBlock = true
|
e10edb5f
zhouahaihai
冒险事件新
|
772
773
774
775
776
777
|
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
酱料
|
778
|
end
|
e10edb5f
zhouahaihai
冒险事件新
|
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
|
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
增加 固有技
|
798
799
800
|
if clearBlock then
room:clearBEvent(block)
end
|
46fac6f1
zhouahaihai
酱料
|
801
802
803
804
805
806
|
return true
end
local function clickDrop(self, room, block, params)
local reward = {}
if not block.event.item then return end
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
807
|
local reward = self:award({[block.event.item[1]] = block.event.item[2]})
|
46fac6f1
zhouahaihai
酱料
|
808
809
810
811
812
813
814
815
816
817
818
819
820
|
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
冒险事件新
|
821
|
if not self:cost({[traderData.type] = block.event.shop[buyId][3]}, {}) then return end --不够
|
46fac6f1
zhouahaihai
酱料
|
822
|
|
8c199cec
zhengshouren
简化物品奖励接口,设置默认参数
|
823
|
local reward = self:award({[block.event.shop[buyId][1]] = block.event.shop[buyId][2]})
|
46fac6f1
zhouahaihai
酱料
|
824
825
826
827
828
829
830
831
832
|
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
增加 固有技
|
833
|
local clearBlock = true
|
46fac6f1
zhouahaihai
酱料
|
834
835
836
837
838
839
840
841
842
843
|
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
增加 固有技
|
844
845
|
self:addNewMonsterRand(effect[2], {room, block})
clearBlock = false
|
46fac6f1
zhouahaihai
酱料
|
846
847
848
849
850
|
end,
[4] = function() --无事发生
end
}
assert(doEffect[effect[1]], "error effect, event_buildingCsv id :" .. block.event.id)
|
e10edb5f
zhouahaihai
冒险事件新
|
851
|
if not self:cost(buildData.required:toNumMap(), {}) then return end
|
46fac6f1
zhouahaihai
酱料
|
852
|
doEffect[effect[1]]()
|
02c4de8d
zhouahaihai
增加 固有技
|
853
854
855
|
if clearBlock then
room:clearBEvent(block)
end
|
46fac6f1
zhouahaihai
酱料
|
856
857
858
|
return true
end
|
c0b7797f
zhouhaihai
陷阱、点击生效点
|
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
|
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
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
|
ae20365b
suhongyang
Revert "修改冒险战斗逻辑"
|
948
|
--继续战斗
|
e459a5fc
suhongyang
战斗回合检查同步以及回合数据缓存
|
949
|
function Adv:nextBattleTurn(turn)
|
ae20365b
suhongyang
Revert "修改冒险战斗逻辑"
|
950
|
local enemy = self.battle.enemy
|
e459a5fc
suhongyang
战斗回合检查同步以及回合数据缓存
|
951
|
if not enemy or self.battle:checkTurn(turn) then
|
ae20365b
suhongyang
Revert "修改冒险战斗逻辑"
|
952
953
954
955
956
957
958
959
960
961
962
963
|
return
end
local roomId, blockId = self.battle:getRBByEnemyId(enemy.id)
self.battle:doBattleTurn()
if self.battle:isBattleEnd() then
self:backBlockChange(roomId, blockId)
self:afterRound()
end
self:saveDB()
return true
end
|
46fac6f1
zhouahaihai
酱料
|
964
965
966
967
968
969
970
971
972
973
974
975
976
977
|
--使用道具产生效果
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
使用营养技
|
978
|
self.battle.player:releaseSkill(itemData.effect, target)
|
46fac6f1
zhouahaihai
酱料
|
979
980
981
982
983
984
985
986
|
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
冒险
|
987
|
self:saveDB()
|
46fac6f1
zhouahaihai
酱料
|
988
989
990
|
return true
end
|
d27ad5e0
suhongyang
使用营养技
|
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
|
--使用技能
function Adv:usePotion(potionId, potionLevel, target)
-- cost
local potionData = csvdb["adv_potionCsv"][potionId][potionLevel]
-- if self.advInfo.power < skillData.cost then return end
-- self.advInfo.power = self.advInfo.power - skillData.cost
-- target
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
酱料
|
1006
|
else
|
d27ad5e0
suhongyang
使用营养技
|
1007
|
return
|
46fac6f1
zhouahaihai
酱料
|
1008
|
end
|
46fac6f1
zhouahaihai
酱料
|
1009
|
self:afterRound()
|
36c30c5c
zhouahaihai
冒险
|
1010
|
self:saveDB()
|
46fac6f1
zhouahaihai
酱料
|
1011
1012
1013
|
return true
end
|
42f2d1d3
suhongyang
战斗内技能序列逻辑
|
1014
|
--使用战斗技能
|
b67cfabd
suhongyang
Fix name
|
1015
|
function Adv:useSpecialSkill(skillId)
|
42f2d1d3
suhongyang
战斗内技能序列逻辑
|
1016
1017
1018
1019
1020
|
if not csvdb["adv_skill_specialCsv"][skillId] or self.battle:isBattleEnd() then return end
local skillLevel = nil
for slot, heroId in pairs(self.advTeam.heros) do
if self.owner.heros[heroId] then
if csvdb["unitCsv"][self.owner.heros[heroId]:getSkinId()]["adv"] == skillId then
|
0907ad89
suhongyang
Fix bug
|
1021
|
skillLevel = self.owner.heros[heroId]:getSkillLevel(2)
|
42f2d1d3
suhongyang
战斗内技能序列逻辑
|
1022
1023
1024
1025
1026
1027
|
break
end
end
end
if not skillLevel or not csvdb["adv_skill_specialCsv"][skillId][skillLevel] then return end
local skillData = csvdb["adv_skill_specialCsv"][skillId][skillLevel]
|
040c6558
suhongyang
体力改为mp
|
1028
1029
|
--cost
if self.advInfo.power < skillData.cost then return end
|
bc44116d
suhongyang
Fix bug
|
1030
1031
|
self:changePower( -skillData.cost, 0)
-- self.advInfo.power = self.advInfo.power - skillData.cost
|
42f2d1d3
suhongyang
战斗内技能序列逻辑
|
1032
1033
1034
1035
1036
|
local enemy = self.battle.enemy
self.battle.player:addSpecialSkill(skillId, skillLevel, enemy)
return true
end
|
46fac6f1
zhouahaihai
酱料
|
1037
|
--敌人死亡
|
02c4de8d
zhouahaihai
增加 固有技
|
1038
|
function Adv:enemyDead(roomId, blockId, escape)
|
36c30c5c
zhouahaihai
冒险
|
1039
1040
|
local room = self.rooms[roomId]
local block = room.blocks[blockId]
|
46fac6f1
zhouahaihai
酱料
|
1041
1042
|
--死了以后掉东西
if block.event and (block.event.etype == AdvEventType.BOSS or block.event.etype == AdvEventType.Monster) then --处理死亡
|
36c30c5c
zhouahaihai
冒险
|
1043
1044
1045
|
if block.event.etype == AdvEventType.BOSS then
room.isBossRoom = false
end
|
02c4de8d
zhouahaihai
增加 固有技
|
1046
1047
1048
|
if escape then
room:clearBEvent(block)
else
|
b0fe1817
zhouahaihai
冒险分数
|
1049
1050
1051
|
local monsterData = csvdb["event_monsterCsv"][block.event.id]
self:scoreChange(AdvScoreType.Kill, monsterData.type)
|
02c4de8d
zhouahaihai
增加 固有技
|
1052
1053
1054
1055
1056
|
local item = block.event.item
if not item then
if block.event.etype == AdvEventType.BOSS then
item = {ItemId.AdvKey, 1}
else
|
02c4de8d
zhouahaihai
增加 固有技
|
1057
1058
1059
|
local dropData = csvdb["event_dropCsv"][monsterData.dropid]
item = dropData["range"]:randWeight(true)
end
|
46fac6f1
zhouahaihai
酱料
|
1060
|
end
|
4b7c7c96
zhouahaihai
增加 清空 挂机 冒险gm 角色经验
|
1061
1062
1063
1064
1065
1066
1067
|
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
酱料
|
1068
|
end
|
46fac6f1
zhouahaihai
酱料
|
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
|
end
self:backBlockChange(roomId, blockId)
end
--cType 0 or nil 值 1 百分比
function Adv:changePower(value, cType)
cType = cType or 0
if cType == 0 then
self.advInfo.power = self.advInfo.power + value
elseif cType == 1 then
|
7c5054a1
suhongyang
Fix bug
|
1079
|
self.advInfo.power = self.advInfo.power + self.advInfo.power * value / 100
|
46fac6f1
zhouahaihai
酱料
|
1080
1081
|
end
self.advInfo.power = math.floor(math.max(0, self.advInfo.power))
|
ec87b4a5
zhouahaihai
冒险 完善
|
1082
|
self:pushBackEvent(AdvBackEventType.PowerChange)
|
46fac6f1
zhouahaihai
酱料
|
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
|
end
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,快速战斗逻辑
|
1097
1098
1099
1100
|
function Adv:backMiss(enemyId)
self:pushBackEvent(AdvBackEventType.Miss, {enemyId = enemyId})
end
|
46fac6f1
zhouahaihai
酱料
|
1101
1102
1103
1104
|
-- if is player enemyId is nil
function Adv:backAtkChange(enemyId, change)
self:pushBackEvent(AdvBackEventType.AtkChange, {enemyId = enemyId, change = change})
end
|
e996b82a
zhouahaihai
冒险增加防御属性
|
1105
1106
1107
1108
1109
1110
|
-- if is player enemyId is nil
function Adv:backDefChange(enemyId, change)
self:pushBackEvent(AdvBackEventType.DefChange, {enemyId = enemyId, change = change})
end
|
46fac6f1
zhouahaihai
酱料
|
1111
1112
1113
1114
1115
1116
|
-- 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
冒险
|
1117
|
self:pushBackEvent(AdvBackEventType.Skill, {enemyId = enemyId, skillId = skillId, receiver = receiver})
|
46fac6f1
zhouahaihai
酱料
|
1118
1119
|
end
|
4eadc2ab
suhongyang
獲得被動暫時增加log,後面可以去掉
|
1120
1121
1122
1123
1124
|
-- if is player enemyId is nil
function Adv:backPassive(enemyId, passiveId)
self:pushBackEvent(AdvBackEventType.Passive, {enemyId = enemyId, passiveId = passiveId})
end
|
46fac6f1
zhouahaihai
酱料
|
1125
1126
1127
1128
|
function Adv:backNext()
self:pushBackEvent(AdvBackEventType.Next, {})
end
|
b0fe1817
zhouahaihai
冒险分数
|
1129
1130
|
function Adv:backEnd(success, score, scoreInfo, reward)
self:pushBackEvent(AdvBackEventType.End, {success = success, score = score, scoreInfo = scoreInfo, reward = reward})
|
46fac6f1
zhouahaihai
酱料
|
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
|
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
冒险
|
1141
1142
1143
1144
|
function Adv:backDead(enemyId)
self:pushBackEvent(AdvBackEventType.Dead, {enemyId = enemyId})
end
|
39a6e08b
suhongyang
冒险战斗内逻辑调整
|
1145
1146
1147
1148
|
function Adv:backTurnEnd()
self:pushBackEvent(AdvBackEventType.TurnEnd, {})
end
|
8cec27ce
suhongyang
战斗开始
|
1149
1150
1151
1152
|
function Adv:backBattleBegin()
self:pushBackEvent(AdvBackEventType.BattleBegin, {})
end
|
386ca58e
zhouhaihai
优化log
|
1153
1154
1155
|
function Adv:backTrap()
self:pushBackEvent(AdvBackEventType.Trap, {})
end
|
ec87b4a5
zhouahaihai
冒险 完善
|
1156
|
|
b0fe1817
zhouahaihai
冒险分数
|
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
|
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
冒险事件新
|
1186
1187
1188
1189
1190
1191
1192
1193
|
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
冒险分数
|
1194
1195
|
end
|
46fac6f1
zhouahaihai
酱料
|
1196
1197
|
function Adv:popBackEvents()
local events = self.backEvents
|
e459a5fc
suhongyang
战斗回合检查同步以及回合数据缓存
|
1198
1199
|
-- TODO 缓存数据需要分类,防止发错,暂时只有战斗,可以不分
self.tempBackEvents = events
|
46fac6f1
zhouahaihai
酱料
|
1200
1201
1202
1203
1204
1205
1206
1207
1208
|
self.backEvents = {}
return events
end
--回合事件处理
function Adv:afterRound()
if self.battle then
self.battle:afterRound()
end
|
39a6e08b
suhongyang
冒险战斗内逻辑调整
|
1209
|
-- TODO 房间回合事件
|
46fac6f1
zhouahaihai
酱料
|
1210
1211
|
end
|
36c30c5c
zhouahaihai
冒险
|
1212
1213
1214
1215
1216
1217
1218
|
function Adv:saveDB()
if self.battle then
self.battle:getDB()
end
self.owner:updateProperties({advInfo = self.advInfo, advTeam = self.advTeam})
end
|
46fac6f1
zhouahaihai
酱料
|
1219
|
return Adv
|