Commit 0e3ab88d04e95b0378457c1b2d17da34e701a6a6

Authored by zhouhaihai
1 parent 76dc6fb7

中继层

src/GlobalVar.lua
... ... @@ -60,7 +60,7 @@ ItemType = {
60 60 --在这个里面的会记录的是功能开放 对应类型open 而不是 ID
61 61 FuncOpenType = {
62 62 AdvEndless = 2, -- 无尽模式
63   - AdvRelay = 3, -- 中继开放
  63 + AdvRelay = 3, -- 中继开放 -- 删掉了
64 64 AdvWS = 6, -- 工坊解锁
65 65 AdvWheelSurf = 7, -- 抽奖解锁
66 66 TimeBoxSlot = 8, -- 时钟箱槽
... ... @@ -102,6 +102,9 @@ AdvSpecialStage = {
102 102 [2] = "Out",
103 103 [3] = "BOSS",
104 104 [4] = "LinkChoose",
  105 + [5] = "Exit",
  106 + [6] = "InOut",
  107 + [7] = "Diner"
105 108 }
106 109 --客户端需要知道这个
107 110 AdvEventType = {
... ... @@ -110,6 +113,11 @@ AdvEventType = {
110 113 Out = -2, --出口
111 114 BOSS = -3, -- boss
112 115 LinkChoose = -4, -- 连续选择
  116 + Exit = -5, -- 中继点专属退出出口
  117 + InOut = -6, -- 出入口集合体
  118 + Diner = -7, -- 料理台
  119 +
  120 +
113 121 -- 普通事件(随机)
114 122 Choose = 1, --选择点
115 123 Drop = 2, --物品掉落点
... ...
src/actions/AdvAction.lua
... ... @@ -91,36 +91,32 @@ function _M.startAdvRpc( agent, data )
91 91 local chapterData = csvdb["adv_chapterCsv"][chapterId]
92 92 if not chapterData or layer < 1 then return 1 end
93 93  
94   - --是否是中继层
95   - if (layer - 1) % globalCsv.adv_can_out_layer_pre ~= 0 then return 3 end
96   -
97 94 local advPass = role:getProperty("advPass")
98   - if AdvCommon.isEndless(chapterId) then
  95 +
  96 + if AdvCommon.isEndless(chapterId) then -- 无尽模式判断
  97 +
99 98 if chapterId ~= role.advElChapter then return end -- 不是当前进行的章节
100 99 if not isOpenEndless(role) then return end
  100 +
101 101 if role.dailyData:getProperty("advElC") >= role:getAdvElLimit() then return 2 end -- 是否有体力
102   - if not role:isFuncOpen(FuncOpenType.AdvEndless) or not role:isFuncOpen(FuncOpenType.AdvRelay) then return 11 end -- 开放了中继模式 和 无尽模式 才可以玩儿无尽模式
103   - local maxl = math.floor(role:getProperty("advElM") / 10) * 10
104   - local openLayer = {}
105   - for i = 0, (globalCsv.adv_endless_open_relay - 1) do
106   - local l = maxl - i * globalCsv.adv_can_out_layer_pre
107   - if l < 0 then
108   - break
109   - end
110   - openLayer[l] = 1
111   - end
112   - if not openLayer[layer - 1] then return 10 end
  102 + if not role:isFuncOpen(FuncOpenType.AdvEndless) then return 11 end -- 无尽模式 才可以玩儿无尽模式
  103 +
  104 + local advElM = role:getProperty("advElM") --最高通关的层数
113 105  
114 106 if layer == 1 then
115 107 if not role:advChapterIsOpen(chapterId, layer) then return 13 end
  108 + else
  109 + local relayData = role:getAdvData():isHaveRelay(layer, chapterId)
  110 + if not relayData then return end -- 不是中继层
  111 + if advElM < relayData.unlockfloor then return end --未解锁
116 112 end
117   - else
  113 + else -- 普通模式判断
118 114 if role.dailyData:getProperty("advC") >= role:getAdvHangLimit() then return 2 end -- 是否有体力
119 115 if layer > chapterData.limitlevel then return 4 end
120 116 -- 关卡开放判断
121 117 if not role:advChapterIsOpen(chapterId, layer) then return 5 end
122   - --中继开放判断
123   - if layer ~= 1 and (not role:isFuncOpen(FuncOpenType.AdvRelay) or (advPass[chapterId] or 0) < (layer - 1)) then return 6 end
  118 + -- 普通模式没有中继 只能从1 开始 中继开放判断
  119 + if layer ~= 1 then return 6 end
124 120 end
125 121  
126 122 if not checkFormat(role, format) then return 7 end
... ... @@ -141,7 +137,7 @@ function _M.startAdvRpc( agent, data )
141 137 role.dailyData:updateProperty({field = "advC", delta = 1})
142 138 end
143 139  
144   - role:getAdvData():initByChapter(chapterId, layer)
  140 + role:getAdvData():initByChapter(chapterId, layer, false, false, layer ~= 1, true)
145 141 role:checkTaskEnter("AdvStart", {id = chapterId})
146 142 role:checkTaskEnter("AdvStartSelf", {id = chapterId})
147 143 SendPacket(actionCodes.Adv_startAdvRpc, '')
... ... @@ -241,10 +237,10 @@ function _M.buyAdvCountRpc(agent , data)
241 237 local isEl = msg.isEl -- 是否是无尽模式
242 238 local cost
243 239 if isEl then
244   - if math.illegalNum(count, 1, math.min(globalCsv.adv_endless_daily_buy_count - role.dailyData:getProperty("advElBC"), role.dailyData:getProperty("advElC"))) then return end
  240 + if math.illegalNum(count, 1, globalCsv.adv_endless_daily_buy_count - role.dailyData:getProperty("advElBC")) then return end
245 241 cost = {[ItemId.Diamond] = count * globalCsv.adv_endless_daily_buy_cost}
246 242 else
247   - if math.illegalNum(count, 1, math.min(globalCsv.adv_daily_buy_count - role.dailyData:getProperty("advBC"), role.dailyData:getProperty("advC"))) then return end
  243 + if math.illegalNum(count, 1, globalCsv.adv_daily_buy_count - role.dailyData:getProperty("advBC")) then return end
248 244 cost = {[ItemId.Diamond] = count * globalCsv.adv_daily_buy_cost}
249 245 end
250 246  
... ...
src/adv/Adv.lua
... ... @@ -31,6 +31,7 @@ function Adv:initByInfo(advInfo)
31 31 self.level = advInfo.level or 1
32 32 self.round = advInfo.round or 0
33 33 self.score = advInfo.score or {}
  34 + self.isRelay = advInfo.isRelay
34 35 self.lastEnemyId = advInfo.lastEId or 1
35 36 self.mapStack = advInfo.mstack or {}
36 37 self.lchoose = advInfo.lch or {}
... ... @@ -45,9 +46,23 @@ function Adv:initByInfo(advInfo)
45 46  
46 47 self:initBattle()
47 48 end
  49 +-- 找出level 是否存在中继层
  50 +function Adv:isHaveRelay(level, chapterId)
  51 + level = chapterId or self.level
  52 + chapterId = chapterId or self.chapterId
  53 + if level == 1 then return end
  54 +
  55 + local campsiteCsv = csvdb["adv_chapter_campsiteCsv"][chapterId]
  56 + for _, campsite in ipairs(campsiteCsv) do
  57 + if campsite.floor == level then
  58 + return campsite
  59 + end
  60 + end
  61 + return nil
  62 +end
48 63  
49 64 -- 随机新的地图
50   -function Adv:initByChapter(chapterId, level, isToNext, notNotify)
  65 +function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnter)
51 66 if not self.chapterId then -- 开始新的章节
52 67 self.chapterId = chapterId
53 68 self:checkAchievement(Adv.AchievType.StartBattle, 1)
... ... @@ -65,9 +80,33 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify)
65 80 self.shopStatus = self.shopStatus or {}
66 81  
67 82 -- 随机出地图
68   - local mapId = self:randomMapId(chapterId, level)
  83 + local mapId
  84 + if isRelay then
  85 + local relayData = self:isHaveRelay(level, chapterId)
  86 + if relayData then
  87 + mapId = relayData.map
  88 + else
  89 + isRelay = false
  90 + mapId = self:randomMapId(chapterId, level)
  91 + end
  92 + else
  93 + mapId = self:randomMapId(chapterId, level)
  94 + end
  95 + self.isRelay = isRelay
  96 + local isNewRelay = false
  97 + if self.isRelay then -- 中继层
  98 + local advRelay = self.owner:getProperty("advRelay")
  99 + local chapter = self:isEndless() and -1 or self.chapterId
  100 + if not (advRelay[chapter] or {})[self.level] then
  101 + isNewRelay = true
  102 + advRelay[chapter] = advRelay[chapter] or {}
  103 + advRelay[chapter][self.level] = 1
  104 + self.owner:updateProperty({field = advRelay, value = advRelay})
  105 + end
  106 + end
  107 +
69 108 self.maps = {}
70   - self.maps[1] = AdvMap.new(self, 1, mapId)
  109 + self.maps[1] = AdvMap.new(self, 1, mapId, isEnter, isNewRelay)
71 110  
72 111 self:initBattle()
73 112  
... ... @@ -95,6 +134,7 @@ function Adv:clear()
95 134 self.maps = {}
96 135 self.battle = nil
97 136 self.waitArtifact = nil
  137 + self.isRelay = nil
98 138 self.cacheUnlock = {}
99 139 self.shopStatus = {}
100 140 end
... ... @@ -128,6 +168,7 @@ function Adv:saveDB(notNotify)
128 168 advInfo.level = self.level
129 169 advInfo.round = self.round
130 170 advInfo.score = self.score
  171 + advInfo.isRelay = self.isRelay
131 172 advInfo.lastEId = self.lastEnemyId
132 173 advInfo.mstack = self.mapStack
133 174 advInfo.lch = self.lchoose
... ... @@ -586,14 +627,12 @@ local function clickOut(self, room, block, params)
586 627 self.owner:changeUpdates({{type = "advPass", field = self.chapterId, value = self.level}})
587 628 end
588 629 end
589   - if params.relay then
590   - if self.level % globalCsv.adv_can_out_layer_pre ~= 0 or not self.owner:isFuncOpen(FuncOpenType.AdvRelay) then return end
591   - end
592   -
  630 +
593 631 self:checkAchievement(Adv.AchievType.OverWin, 1, self.level)
594 632 self:checkAdvUnlock(2, self.level)
595 633 local levellimit = csvdb["adv_chapterCsv"][self.chapterId].limitlevel
596   - if params.relay or (not self:isEndless() and (self.level >= levellimit or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1))) then --关卡结束
  634 +
  635 + if not self:isEndless() and (self.level >= levellimit or not self.owner:advChapterIsOpen(self.chapterId, self.level + 1)) then --关卡结束
597 636 self:over(true, not self:isEndless() and self.level >= levellimit)
598 637 else
599 638 self.battle.player:triggerPassive(Passive.DOWN_LAYER)
... ... @@ -601,7 +640,12 @@ local function clickOut(self, room, block, params)
601 640 if curFloorData then
602 641 self:backReward(self:award({[ItemId.AdvPoint] = curFloorData.exp}))
603 642 end
604   - self:initByChapter(self.chapterId, self.level + 1, true, true)
  643 + local isHaveRelay = self:isHaveRelay(self.level)
  644 + if isHaveRelay and not self.isRelay then
  645 + self:initByChapter(self.chapterId, self.level, true, true, true, false)
  646 + else
  647 + self:initByChapter(self.chapterId, self.level + 1, true, true, false, false)
  648 + end
605 649 self:backNext() --下一关
606 650 end
607 651  
... ... @@ -611,6 +655,11 @@ local function clickOut(self, room, block, params)
611 655 end
612 656 end
613 657  
  658 +local function clickExit(self, room, block, params)
  659 + self:over(true, not self:isEndless() and self.level >= levellimit)
  660 + return true
  661 +end
  662 +
614 663 --战斗 普通攻击
615 664 local function clickMonster(self, room, block, params)
616 665 self.battle:battleBegin(room.roomId, block.blockId, params)
... ... @@ -937,6 +986,8 @@ end
937 986  
938 987 local eventCallFunc = {
939 988 [AdvEventType.Out] = clickOut,
  989 + [AdvEventType.InOut] = clickOut,
  990 + [AdvEventType.Exit] = clickExit,
940 991 [AdvEventType.BOSS] = clickMonster,
941 992 [AdvEventType.Monster] = clickMonster,
942 993 [AdvEventType.Choose] = clickChoose,
... ... @@ -991,7 +1042,7 @@ function Adv:clickBlock(roomId, blockId, params)
991 1042 end
992 1043 local needChange = true
993 1044 if clickEvent and block.event then
994   - if block:getEventType() == AdvEventType.Out then
  1045 + if block:getEventType() == AdvEventType.Out or block:getEventType() == AdvEventType.InOut or block:getEventType() == AdvEventType.Exit then
995 1046 needChange = false
996 1047 end
997 1048 end
... ...
src/adv/AdvBattle.lua
... ... @@ -63,6 +63,10 @@ function Battle:initPlayer()
63 63  
64 64 player = {}
65 65 player.level = 1
  66 + if self.adv.level ~= 1 then
  67 + local relayData = self.adv:isHaveRelay()
  68 + player.level = relayData.level
  69 + end
66 70 player.exp = 0
67 71 player.sp = getAdvLvAttrUp(advAddAttrs, "sp", 100)
68 72 player.growth = {}
... ... @@ -89,6 +93,7 @@ function Battle:initPlayer()
89 93 end
90 94 player[attrName] = getAdvLvAttrUp(advAddAttrs, attrName, player[attrName])
91 95 player.growth[attrName] = player[attrName] * 0.025
  96 + player[attrName] = player[attrName] + player.growth[attrName] * (player.level - 1)
92 97 end
93 98  
94 99 player.hpMax = player.hp or 0
... ...
src/adv/AdvMap.lua
... ... @@ -8,10 +8,10 @@ local Map = class(&quot;AdvMap&quot;)
8 8 local createMap, getEventLib
9 9  
10 10  
11   -function Map:ctor(adv, mapIdx, mapInfo)
  11 +function Map:ctor(adv, mapIdx, mapInfo, isEnter, isNewRelay)
12 12 self.adv = adv
13 13 if type(mapInfo) == "number" then -- mapInfo 传入 id
14   - mapInfo = createMap(self, mapInfo) -- 生成地图
  14 + mapInfo = createMap(self, mapInfo, isEnter, isNewRelay) -- 生成地图
15 15 end
16 16 if not mapInfo then return end
17 17  
... ... @@ -217,7 +217,8 @@ end
217 217  
218 218 -----------------------------随机地图-----------------------------
219 219  
220   -createMap = function(self, mapId)
  220 +-- isEnter isNewRelay 区分中继层的类型 --是否是开始进入 是否是第一次进入
  221 +createMap = function(self, mapId, isEnter, isNewRelay)
221 222 local mapInfo = {}
222 223 mapInfo.rooms = {}
223 224 mapInfo.mapId = mapId
... ... @@ -260,6 +261,18 @@ createMap = function(self, mapId)
260 261 randomFunc[AdvEventType.In] = function()end
261 262 --出口
262 263 randomFunc[AdvEventType.Out] = function() end
  264 + --中继点出口
  265 + randomFunc[AdvEventType.Exit] = function()
  266 + if not self.adv.isRelay or isEnter then return false end
  267 + end
  268 + --开放出口
  269 + randomFunc[AdvEventType.InOut] = function() end
  270 +
  271 + --开放出口
  272 + randomFunc[AdvEventType.Diner] = function()
  273 + if not self.adv.isRelay or isEnter or isNewRelay then return false end
  274 + end
  275 +
263 276 --boss
264 277 randomFunc[AdvEventType.BOSS] = function()
265 278 if haveBoss then return false end
... ... @@ -294,9 +307,15 @@ createMap = function(self, mapId)
294 307 --掉落点
295 308 randomFunc[AdvEventType.Drop] = randomCommon
296 309 --交易所
297   - randomFunc[AdvEventType.Trader] = randomCommon
  310 + randomFunc[AdvEventType.Trader] = function()
  311 + if self.adv.isRelay and isNewRelay then return false end
  312 + return randomCommon()
  313 + end
298 314 --建筑
299   - randomFunc[AdvEventType.Build] = randomCommon
  315 + randomFunc[AdvEventType.Build] = function()
  316 + if self.adv.isRelay and isEnter then return false end
  317 + return randomCommon()
  318 + end
300 319 --陷阱
301 320 randomFunc[AdvEventType.Trap] = randomCommon
302 321 --点击生效
... ...
src/adv/AdvRoom.lua
... ... @@ -15,19 +15,22 @@ function Room:ctor(map, roomId, csvData, info, isPath)
15 15  
16 16 self.blocks = {}
17 17 self:loadBlocks(csvData, info)
18   -
19 18 end
20 19  
21 20 function Room:loadBlocks(csvData, info)
22 21 for blockId, _ in pairs(csvData["blocks"]) do
23 22 self.blocks[blockId] = Block.new(self, blockId, info.event[blockId], info.open == 1 or info.open[blockId], info.trap[blockId])
  23 + if self.map.adv.isRelay then -- 中继层全部开放
  24 + self.blocks[blockId].isOpen = true
  25 + self.blocks[blockId]:randomEvent()
  26 + end
24 27 if not self.isPath and self.blocks[blockId]:isBoss() then
25 28 self.isBossRoom = true
26 29 end
27 30 if self.blocks[blockId].isOpen then
28 31 self.isShow = true
29 32 else
30   - if self.blocks[blockId]:getEventType() == AdvEventType.In then -- 开放
  33 + if self.blocks[blockId]:getEventType() == AdvEventType.In or self.blocks[blockId]:getEventType() == AdvEventType.InOut then -- 开放
31 34 self.isShow = true
32 35 self.blocks[blockId].isOpen = true
33 36 --入口房间只会在这里首次展示开放 --触发固有技
... ...
src/models/Daily.lua
... ... @@ -48,7 +48,11 @@ function Daily:refreshDailyData(notify)
48 48 redisproxy:del(FRIEND_POINT:format(self.owner:getProperty("id")))
49 49 local dataMap = {}
50 50 for field, schema in pairs(self.schema) do
51   - if field ~= "key" then
  51 + if field == "advC" or field == "advElC" then
  52 + if self:getProperty("field") > 0 then
  53 + dataMap[field] = 0
  54 + end
  55 + elseif field ~= "key" then
52 56 local typ, def = table.unpack(schema)
53 57 dataMap[field] = def
54 58 end
... ...
src/models/Role.lua
... ... @@ -75,6 +75,7 @@ Role.schema = {
75 75 advStoryB = {"table", {}}, -- 冒险故事完成记录 (连锁事件绑定的故事) -- {storyId = 1}
76 76 advShop = {"table", {}}, -- 冒险內的商店限制购买次数记录 {goodId = count}
77 77 advEAchiev = {"table", {}}, -- 冒险无尽冒险手册
  78 + advRelay = {"table", {}}, -- 冒险中继点记录 {[chapter] = {[level] = 1}, [-1] = {[level] = 1}} -- -1 无尽 方便重置
78 79  
79 80 --挂机相关
80 81 hangPass = {"table", {}}, -- 挂机通过的最大关卡
... ... @@ -257,6 +258,7 @@ function Role:data()
257 258 advAchiev = self:getProperty("advAchiev"),
258 259 advL = self:getProperty("advL"),
259 260 advElM = self:getProperty("advElM"),
  261 + advElS = self:getProperty("advElS"),
260 262 advElChapter = self.advElChapter,
261 263 advOverTime = self.advOverTime,
262 264 advAFGet = self:getProperty("advAFGet"),
... ...
src/models/RolePlugin.lua
... ... @@ -776,11 +776,10 @@ function RolePlugin.bind(Role)
776 776 -- 重置一下冒险
777 777 local nowSeason = tonum(redisproxy:hget("adv_season", "idx"))
778 778 if self:getProperty("advElS") ~= nowSeason then
779   - local ml = self:getProperty("advElM")
780   -
781   - local nl = math.max(0, ml - (math.floor(ml / 50) + 2) * 10)
782   - self:setProperty("advElM", math.floor(nl / 10) * 10)
783   - self:setProperty("advElS", nowSeason)
  779 + -- 胡博文让注释掉 衰减 从0开始
  780 + -- local ml = self:getProperty("advElM")
  781 + -- local nl = math.max(0, ml - (math.floor(ml / 50) + 2) * 10)
  782 + -- self:setProperty("advElM", math.floor(nl / 10) * 10)
784 783  
785 784 -- 正在无尽冒险清掉
786 785 local adv = self:getAdvData()
... ... @@ -801,6 +800,8 @@ function RolePlugin.bind(Role)
801 800 -- 清掉冒险手册
802 801 self:updateProperties({
803 802 advEAchiev = {},
  803 + advElM = 0,
  804 + advElS = nowSeason,
804 805 }, notNotify)
805 806 end
806 807 end
... ...