Commit 8c7272a5ee1eb4a31bf66f41d81f4ecfb2ba0cef
1 parent
ca865c7e
冒险 地图刷新需求
Showing
2 changed files
with
67 additions
and
28 deletions
Show diff stats
src/adv/AdvMap.lua
... | ... | @@ -24,12 +24,13 @@ end |
24 | 24 | |
25 | 25 | function Map:loadRooms(rooms, isNewRelay) |
26 | 26 | local mapData = csvdb["map_" .. csvdb["mapCsv"][self.mapId]["path"] .. "Csv"] |
27 | + | |
27 | 28 | for roomId, roomName in pairs(mapData["rooms"]) do |
28 | 29 | if roomName == "path" then |
29 | - self.rooms[roomId] = Room.new(self, roomId, mapData["path"], rooms[roomId], true, isNewRelay) | |
30 | + self.rooms[roomId] = Room.new(self, roomId, mapData["path"], rooms[roomId], true, isNewRelay, mapData.type) | |
30 | 31 | else |
31 | 32 | roomName = roomName:gsub("/", "_") |
32 | - self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], rooms[roomId], false, isNewRelay) | |
33 | + self.rooms[roomId] = Room.new(self, roomId, csvdb["room_" .. roomName .. "Csv"], rooms[roomId], false, isNewRelay, mapData.type) | |
33 | 34 | end |
34 | 35 | end |
35 | 36 | end |
... | ... | @@ -250,6 +251,31 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
250 | 251 | error("mapId " .. mapId .. " dont exist!") |
251 | 252 | return |
252 | 253 | end |
254 | + | |
255 | + local etypeToStr = { | |
256 | + [AdvEventType.Choose] = "choose", | |
257 | + [AdvEventType.Drop] = "drop", | |
258 | + [AdvEventType.Monster] = "monster", | |
259 | + [AdvEventType.Trader] = "trader", | |
260 | + [AdvEventType.Build] = "building", | |
261 | + [AdvEventType.Trap] = "trap", | |
262 | + [AdvEventType.Click] = "click", | |
263 | + } | |
264 | + | |
265 | + local highLevelEvent = {} | |
266 | + for _etype, _str in pairs(etypeToStr) do | |
267 | + if mapCsvData[_str] ~= "" then | |
268 | + highLevelEvent[_etype] = {} | |
269 | + end | |
270 | + for _id, _count in pairs(mapCsvData[_str]:toNumMap()) do | |
271 | + local _curData = csvdb["event_" .. _str .. "Csv"][_id] | |
272 | + if _curData then | |
273 | + highLevelEvent[_etype][_curData.BlockEventType] = highLevelEvent[_etype][_curData.BlockEventType] or {} | |
274 | + highLevelEvent[_etype][_curData.BlockEventType][id] = {showup = _curData.showup, limit = _count, dlimit = _curData.limit} | |
275 | + end | |
276 | + end | |
277 | + end | |
278 | + | |
253 | 279 | --事件随机 |
254 | 280 | local eventLib = getEventLib(self) -- 同时记录出现次数 |
255 | 281 | local monsterEvents = {} --处理钥匙掉落 |
... | ... | @@ -270,22 +296,42 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
270 | 296 | local randomFunc = {} |
271 | 297 | |
272 | 298 | local function randomCommon() |
273 | - if not eventLib[etype] or not next(eventLib[etype]) or not eventLib[etype][especial] or not next(eventLib[etype][especial]) then return false end | |
274 | - event.id = math.randWeight(eventLib[etype][especial], "showup") | |
275 | - if not event.id then return false end | |
276 | - | |
277 | - -- 不是 0 才会记录 | |
278 | - if eventLib[etype][especial][event.id].dlimit ~= 0 then | |
279 | - eventLimit[etype] = eventLimit[etype] or {} | |
280 | - eventLimit[etype][event.id] = (eventLimit[etype][event.id] or 0) + 1 | |
299 | + -- 刷新地图专属的 | |
300 | + | |
301 | + local function randomByLevelLib(lib) | |
302 | + -- 刷新通用的 | |
303 | + if not lib[etype] or not next(lib[etype]) or not lib[etype][especial] then return false end | |
304 | + -- 清一下全关卡次数用完的 | |
305 | + for _eid, _edata in pairs(lib[etype][especial]) do | |
306 | + if _edata.dlimit ~= 0 and ((eventLimit[etype] or {})[_eid] or 0) >= _edata.dlimit then | |
307 | + lib[etype][especial][_eid] = nil | |
308 | + end | |
309 | + end | |
310 | + | |
311 | + if not next(lib[etype][especial]) then return false end | |
312 | + event.id = math.randWeight(lib[etype][especial], "showup") | |
313 | + if not event.id then return false end | |
314 | + | |
315 | + -- 不是 0 才会记录 | |
316 | + if lib[etype][especial][event.id].dlimit ~= 0 then | |
317 | + eventLimit[etype] = eventLimit[etype] or {} | |
318 | + eventLimit[etype][event.id] = (eventLimit[etype][event.id] or 0) + 1 | |
319 | + end | |
320 | + | |
321 | + -- 消除单层次数用完的 | |
322 | + if lib[etype][especial][event.id].limit > 1 then | |
323 | + lib[etype][especial][event.id].limit = lib[etype][especial][event.id].limit - 1 | |
324 | + elseif lib[etype][especial][event.id].limit == 1 then | |
325 | + lib[etype][especial][event.id] = nil | |
326 | + end | |
327 | + return true | |
281 | 328 | end |
282 | 329 | |
283 | - -- 消除 | |
284 | - if eventLib[etype][especial][event.id].limit > 1 then | |
285 | - eventLib[etype][especial][event.id].limit = eventLib[etype][especial][event.id].limit - 1 | |
286 | - elseif eventLib[etype][especial][event.id].limit == 1 then | |
287 | - eventLib[etype][especial][event.id] = nil | |
330 | + local status = randomByLevelLib(highLevelEvent) | |
331 | + if not status then | |
332 | + status = randomByLevelLib(eventLib) | |
288 | 333 | end |
334 | + return status | |
289 | 335 | end |
290 | 336 | |
291 | 337 | --入口 |
... | ... | @@ -581,15 +627,8 @@ getEventLib = function(self, needEventType) -- needEventType 需要的事件 |
581 | 627 | end |
582 | 628 | end |
583 | 629 | |
584 | - -- data.limit 改为 整个冒险全程 | |
585 | - local limit = data.limit | |
586 | - if data.limit ~= 0 then | |
587 | - limit = data.limit - ((eventLimit[etype] or {})[id] or 0) | |
588 | - if limit <= 0 then | |
589 | - add = false | |
590 | - end | |
591 | - end | |
592 | - | |
630 | + -- limit 单次上限 默认无限 | |
631 | + local limit = 0 | |
593 | 632 | if add and (etype == AdvEventType.LinkChoose or etype == AdvEventType.Choose) then --只能有一次 |
594 | 633 | limit = 1 |
595 | 634 | end | ... | ... |
src/adv/AdvRoom.lua
... | ... | @@ -5,7 +5,7 @@ local Block = require "adv.AdvBlock" |
5 | 5 | local Passive = require "adv.AdvPassive" |
6 | 6 | |
7 | 7 | local Room = class("AdvRoom") |
8 | -function Room:ctor(map, roomId, csvData, info, isPath, isNewRelay) | |
8 | +function Room:ctor(map, roomId, csvData, info, isPath, isNewRelay, mapType) | |
9 | 9 | self.map = map |
10 | 10 | self.roomId = roomId |
11 | 11 | self.col, self.row = AdvCommon.getCrById(self.roomId) |
... | ... | @@ -15,10 +15,10 @@ function Room:ctor(map, roomId, csvData, info, isPath, isNewRelay) |
15 | 15 | self.battleAfterCall = {} |
16 | 16 | |
17 | 17 | self.blocks = {} |
18 | - self:loadBlocks(csvData, info, isNewRelay) | |
18 | + self:loadBlocks(csvData, info, isNewRelay, mapType) | |
19 | 19 | end |
20 | 20 | |
21 | -function Room:loadBlocks(csvData, info, isNewRelay) | |
21 | +function Room:loadBlocks(csvData, info, isNewRelay, mapType) | |
22 | 22 | local isFirstOpen = false |
23 | 23 | for blockId, _ in pairs(csvData["blocks"]) do |
24 | 24 | self.blocks[blockId] = Block.new(self, blockId, info.event[blockId], info.open == 1 or info.open[blockId], info.trap[blockId]) |
... | ... | @@ -38,7 +38,7 @@ function Room:loadBlocks(csvData, info, isNewRelay) |
38 | 38 | end |
39 | 39 | end |
40 | 40 | --中继层全部开放 boss 房间 开启所有的地块 |
41 | - if (self.map.adv.isRelay and not isNewRelay) or (self.isBossRoom and self.isShow and isFirstOpen) then | |
41 | + if (self.map.adv.isRelay and not isNewRelay) or (self.isBossRoom and self.isShow and isFirstOpen) or mapType == 2 or (isFirstOpen and mapType == 1) then | |
42 | 42 | table.insert(self.battleAfterCall, function() |
43 | 43 | for _, block in pairs(self.blocks) do |
44 | 44 | self:openBlock(block) | ... | ... |