Commit 9ced5432f646ff799228d8124547281c1f3644f6
1 parent
6fe355d6
冒险支援效果 保底事件
Showing
8 changed files
with
368 additions
and
63 deletions
Show diff stats
src/ProtocolCode.lua
@@ -63,6 +63,7 @@ actionCodes = { | @@ -63,6 +63,7 @@ actionCodes = { | ||
63 | Adv_repayWheelSurfRpc = 168, | 63 | Adv_repayWheelSurfRpc = 168, |
64 | Adv_rankRpc = 169, | 64 | Adv_rankRpc = 169, |
65 | Adv_quickHangRpc = 170, | 65 | Adv_quickHangRpc = 170, |
66 | + Adv_refreshSupportRpc = 171, | ||
66 | 67 | ||
67 | Hero_loadInfos = 201, | 68 | Hero_loadInfos = 201, |
68 | Hero_updateProperty = 202, | 69 | Hero_updateProperty = 202, |
src/actions/AdvAction.lua
@@ -84,6 +84,7 @@ function _M.startAdvRpc( agent, data ) | @@ -84,6 +84,7 @@ function _M.startAdvRpc( agent, data ) | ||
84 | local chapterId = msg.chapterId --关卡id | 84 | local chapterId = msg.chapterId --关卡id |
85 | local layer = msg.layer or 1 --选择层数 | 85 | local layer = msg.layer or 1 --选择层数 |
86 | local format = msg.format --编队 | 86 | local format = msg.format --编队 |
87 | + local supportIdx = msg.supportIdx --选择的支援效果 | ||
87 | 88 | ||
88 | --上一个关卡结束才可以开始新的关卡 | 89 | --上一个关卡结束才可以开始新的关卡 |
89 | if role:getAdvData():isRunning() then return 8 end | 90 | if role:getAdvData():isRunning() then return 8 end |
@@ -109,7 +110,7 @@ function _M.startAdvRpc( agent, data ) | @@ -109,7 +110,7 @@ function _M.startAdvRpc( agent, data ) | ||
109 | local relayData = role:getAdvData():isHaveRelay(layer, chapterId) | 110 | local relayData = role:getAdvData():isHaveRelay(layer, chapterId) |
110 | if not relayData then return end -- 不是中继层 | 111 | if not relayData then return end -- 不是中继层 |
111 | if advElM < relayData.unlockfloor then return end --未解锁 | 112 | if advElM < relayData.unlockfloor then return end --未解锁 |
112 | - end | 113 | + end |
113 | else -- 普通模式判断 | 114 | else -- 普通模式判断 |
114 | if role.dailyData:getProperty("advC") >= role:getAdvHangLimit() then return 2 end -- 是否有体力 | 115 | if role.dailyData:getProperty("advC") >= role:getAdvHangLimit() then return 2 end -- 是否有体力 |
115 | if layer > chapterData.limitlevel then return 4 end | 116 | if layer > chapterData.limitlevel then return 4 end |
@@ -137,9 +138,30 @@ function _M.startAdvRpc( agent, data ) | @@ -137,9 +138,30 @@ function _M.startAdvRpc( agent, data ) | ||
137 | role.dailyData:updateProperty({field = "advC", delta = 1}) | 138 | role.dailyData:updateProperty({field = "advC", delta = 1}) |
138 | end | 139 | end |
139 | 140 | ||
140 | - role:getAdvData():initByChapter(chapterId, layer, false, false, layer ~= 1, true) | 141 | + local support = {} -- 支援效果 |
142 | + if AdvCommon.isEndless(chapterId) then | ||
143 | + -- 选择的支援效果 | ||
144 | + local advSup = role:getProperty("advSup") | ||
145 | + if supportIdx then | ||
146 | + if advSup[supportIdx] then | ||
147 | + table.insert(support, advSup[supportIdx]) | ||
148 | + end | ||
149 | + role:advRandomSupportEffect() -- 选完就重新随机 | ||
150 | + end | ||
151 | + -- 增加 默认增加的支援效果 | ||
152 | + local active = role:getAdvActiveSupportEffect() | ||
153 | + for aId, _ in pairs(active) do | ||
154 | + local curData = csvdb["adv_supportCsv"][aId] | ||
155 | + if curData.type == 2 then | ||
156 | + table.insert(support, aId) | ||
157 | + end | ||
158 | + end | ||
159 | + end | ||
160 | + | ||
161 | + role:getAdvData():initByChapter(chapterId, layer, false, false, layer ~= 1, true, support) | ||
141 | role:checkTaskEnter("AdvStart", {id = chapterId}) | 162 | role:checkTaskEnter("AdvStart", {id = chapterId}) |
142 | role:checkTaskEnter("AdvStartSelf", {id = chapterId}) | 163 | role:checkTaskEnter("AdvStartSelf", {id = chapterId}) |
164 | + adv:popBackEvents() -- 清一下事件 | ||
143 | SendPacket(actionCodes.Adv_startAdvRpc, '') | 165 | SendPacket(actionCodes.Adv_startAdvRpc, '') |
144 | return true | 166 | return true |
145 | end | 167 | end |
@@ -647,18 +669,18 @@ end | @@ -647,18 +669,18 @@ end | ||
647 | function _M.finishAchievRpc(agent, data) | 669 | function _M.finishAchievRpc(agent, data) |
648 | local role = agent.role | 670 | local role = agent.role |
649 | local msg = MsgPack.unpack(data) | 671 | local msg = MsgPack.unpack(data) |
650 | - -- local ctype = msg.ctype -- 领取类型 1 成就 2 pt累计奖励 | 672 | + local ctype = msg.ctype or 2 -- 领取类型 1 成就 2 pt累计奖励 |
651 | local chapterId = msg.chapterId --章节id | 673 | local chapterId = msg.chapterId --章节id |
652 | local taskId = msg.taskId -- 领取id | 674 | local taskId = msg.taskId -- 领取id |
653 | 675 | ||
654 | local adv = role:getAdvData() | 676 | local adv = role:getAdvData() |
655 | 677 | ||
656 | local status, reward | 678 | local status, reward |
657 | - -- if ctype == 1 then | ||
658 | - -- status = adv:finishAchievement(chapterId, taskId) | ||
659 | - -- elseif ctype == 2 then | 679 | + if ctype == 1 then |
680 | + status, reward = adv:finishAchievement(chapterId, taskId) | ||
681 | + elseif ctype == 2 then | ||
660 | status, reward = adv:getAchievementReward(chapterId, taskId) | 682 | status, reward = adv:getAchievementReward(chapterId, taskId) |
661 | - -- end | 683 | + end |
662 | if not status then return end | 684 | if not status then return end |
663 | adv:updateAchievement() | 685 | adv:updateAchievement() |
664 | SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack({reward = reward})) | 686 | SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack({reward = reward})) |
@@ -701,4 +723,23 @@ function _M.rankRpc(agent, data) | @@ -701,4 +723,23 @@ function _M.rankRpc(agent, data) | ||
701 | return true | 723 | return true |
702 | end | 724 | end |
703 | 725 | ||
726 | +function _M.refreshSupportRpc(agent, data) | ||
727 | + local role = agent.role | ||
728 | + | ||
729 | + local cr = role.dailyData:getProperty("advSupRe") | ||
730 | + local al = role:getAdvSupportFreeCount() | ||
731 | + | ||
732 | + if cr < al then --免费 | ||
733 | + role.dailyData:updateProperty({field = advSupRe, delta = 1}) | ||
734 | + else -- 付费 | ||
735 | + if not role:checkItemEnough({[ItemId.Diamond] = globalCsv.adv_support_refresh_cost}) then return end | ||
736 | + role:costItems({[ItemId.Diamond] = globalCsv.adv_support_refresh_cost}) | ||
737 | + end | ||
738 | + | ||
739 | + role:advRandomSupportEffect() | ||
740 | + | ||
741 | + SendPacket(actionCodes.Adv_refreshSupportRpc, '') | ||
742 | + return true | ||
743 | +end | ||
744 | + | ||
704 | return _M | 745 | return _M |
705 | \ No newline at end of file | 746 | \ No newline at end of file |
src/adv/Adv.lua
@@ -38,6 +38,7 @@ function Adv:initByInfo(advInfo) | @@ -38,6 +38,7 @@ function Adv:initByInfo(advInfo) | ||
38 | self.waitArtifact = advInfo.waitAF | 38 | self.waitArtifact = advInfo.waitAF |
39 | self.cacheUnlock = advInfo.cacheUnlock or {} | 39 | self.cacheUnlock = advInfo.cacheUnlock or {} |
40 | self.shopStatus = advInfo.shopStatus or {} | 40 | self.shopStatus = advInfo.shopStatus or {} |
41 | + self.support = advInfo.support or {} | ||
41 | 42 | ||
42 | self.maps = {} | 43 | self.maps = {} |
43 | for id, map in ipairs(advInfo.maps or {}) do | 44 | for id, map in ipairs(advInfo.maps or {}) do |
@@ -62,7 +63,7 @@ function Adv:isHaveRelay(level, chapterId) | @@ -62,7 +63,7 @@ function Adv:isHaveRelay(level, chapterId) | ||
62 | end | 63 | end |
63 | 64 | ||
64 | -- 随机新的地图 | 65 | -- 随机新的地图 |
65 | -function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnter) | 66 | +function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnter, support) |
66 | if not self.chapterId then -- 开始新的章节 | 67 | if not self.chapterId then -- 开始新的章节 |
67 | self.chapterId = chapterId | 68 | self.chapterId = chapterId |
68 | self:checkAchievement(Adv.AchievType.StartBattle, 1) | 69 | self:checkAchievement(Adv.AchievType.StartBattle, 1) |
@@ -78,6 +79,11 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt | @@ -78,6 +79,11 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt | ||
78 | self.lchoose = self.lchoose or {} | 79 | self.lchoose = self.lchoose or {} |
79 | self.cacheUnlock = self.cacheUnlock or {} | 80 | self.cacheUnlock = self.cacheUnlock or {} |
80 | self.shopStatus = self.shopStatus or {} | 81 | self.shopStatus = self.shopStatus or {} |
82 | + self.support = self.support or {} | ||
83 | + | ||
84 | + if isEnter then -- 把 支援效果初始化为易用用的形式 | ||
85 | + self:initSupport(support or {}) | ||
86 | + end | ||
81 | 87 | ||
82 | -- 随机出地图 | 88 | -- 随机出地图 |
83 | local mapId | 89 | local mapId |
@@ -112,6 +118,9 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt | @@ -112,6 +118,9 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt | ||
112 | 118 | ||
113 | self:initLayerTask() | 119 | self:initLayerTask() |
114 | 120 | ||
121 | + -- 支援效果生效一些 | ||
122 | + self:activeSomeSupport() | ||
123 | + | ||
115 | self:checkTask(Adv.TaskType.Arrive) | 124 | self:checkTask(Adv.TaskType.Arrive) |
116 | self:checkAdvUnlock(1, self.level) | 125 | self:checkAdvUnlock(1, self.level) |
117 | if isToNext then | 126 | if isToNext then |
@@ -137,34 +146,7 @@ function Adv:clear() | @@ -137,34 +146,7 @@ function Adv:clear() | ||
137 | self.isRelay = nil | 146 | self.isRelay = nil |
138 | self.cacheUnlock = {} | 147 | self.cacheUnlock = {} |
139 | self.shopStatus = {} | 148 | self.shopStatus = {} |
140 | -end | ||
141 | - | ||
142 | -function Adv:isRunning() | ||
143 | - if self.chapterId then return true end | ||
144 | - return false | ||
145 | -end | ||
146 | - | ||
147 | --- 强制结束 | ||
148 | -function Adv:forceOver(notNotify) | ||
149 | - if self:isRunning() then | ||
150 | - self:clear() | ||
151 | - local advTeam = self.owner:getProperty("advTeam") | ||
152 | - advTeam.player = nil | ||
153 | - | ||
154 | - local reward = self.owner:getProperty("advItems"):toNumMap() | ||
155 | - for itemId, count in pairs(reward) do | ||
156 | - reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 | ||
157 | - end | ||
158 | - self.owner:award(reward) | ||
159 | - | ||
160 | - self.owner:updateProperties({ | ||
161 | - advInfo = {}, | ||
162 | - advTeam = advTeam, | ||
163 | - advItems = "", | ||
164 | - advAFGet = {}, | ||
165 | - advAFWear = {}, | ||
166 | - }, notNotify) | ||
167 | - end | 149 | + self.support = {} |
168 | end | 150 | end |
169 | 151 | ||
170 | function Adv:saveDB(notNotify) | 152 | function Adv:saveDB(notNotify) |
@@ -182,6 +164,7 @@ function Adv:saveDB(notNotify) | @@ -182,6 +164,7 @@ function Adv:saveDB(notNotify) | ||
182 | advInfo.waitAF = self.waitArtifact | 164 | advInfo.waitAF = self.waitArtifact |
183 | advInfo.cacheUnlock = self.cacheUnlock | 165 | advInfo.cacheUnlock = self.cacheUnlock |
184 | advInfo.shopStatus = self.shopStatus | 166 | advInfo.shopStatus = self.shopStatus |
167 | + advInfo.support = self.support | ||
185 | advInfo.maps = {} | 168 | advInfo.maps = {} |
186 | 169 | ||
187 | self.battle:saveDB() | 170 | self.battle:saveDB() |
@@ -201,6 +184,161 @@ function Adv:saveDB(notNotify) | @@ -201,6 +184,161 @@ function Adv:saveDB(notNotify) | ||
201 | self.owner:updateProperties({advInfo = advInfo, advTeam = advTeam}, notNotify) | 184 | self.owner:updateProperties({advInfo = advInfo, advTeam = advTeam}, notNotify) |
202 | end | 185 | end |
203 | 186 | ||
187 | +function Adv:initSupport(supports) | ||
188 | + self.support = {} | ||
189 | + | ||
190 | + local supportEffect = {} | ||
191 | + -- 获得道具 1=道具id=道具数量 | ||
192 | + supportEffect[1] = function(_, itemId, num) | ||
193 | + self.support[1] = self.support[1] or {} | ||
194 | + self.support[1][itemId] = (self.support[1][itemId] or 0) + num | ||
195 | + end | ||
196 | + | ||
197 | + -- 获得mapbuff 2=mapbuffid | ||
198 | + supportEffect[2] = function(_, buffId) | ||
199 | + self.support[2] = self.support[2] or {} | ||
200 | + table.insert(self.support[2], buffId) | ||
201 | + end | ||
202 | + | ||
203 | + -- 获得mappassive 3=mappassive | ||
204 | + supportEffect[3] = function(_, passiveId) | ||
205 | + self.support[3] = self.support[3] or {} | ||
206 | + table.insert(self.support[3], passiveId) | ||
207 | + end | ||
208 | + | ||
209 | + -- 首层额外刷新 4=类型=id=数量(类型1=choose/2=building/3=click/4=drop/5=shop) | ||
210 | + supportEffect[4] = function(_, etype, id, num) | ||
211 | + self.support[4] = self.support[4] or {} | ||
212 | + self.support[4][etype] = self.support[4][etype] or {} | ||
213 | + self.support[4][etype][id] = (self.support[4][etype][id] or 0) + num | ||
214 | + end | ||
215 | + | ||
216 | + -- 每层额外刷新 5=类型=id=数量(类型1=choose/2=building/3=click/4=drop/5=shop) | ||
217 | + supportEffect[5] = function(_, etype, id, num) | ||
218 | + self.support[5] = self.support[5] or {} | ||
219 | + self.support[5][etype] = self.support[5][etype] or {} | ||
220 | + self.support[5][etype][id] = (self.support[5][etype][id] or 0) + num | ||
221 | + end | ||
222 | + | ||
223 | + -- 获得随机神器 6=数量 | ||
224 | + supportEffect[6] = function(num) | ||
225 | + self.support[6] = (self.support[6] or 0) + num | ||
226 | + end | ||
227 | + | ||
228 | + -- 获得3选1神器 7=选择次数(连续选择,每次选择重新随机) | ||
229 | + supportEffect[7] = function(num) | ||
230 | + self.support[7] = (self.support[7] or 0) + num | ||
231 | + end | ||
232 | + | ||
233 | + for _, supportId in ipairs(supports) do | ||
234 | + local supportData = csvdb["adv_supportCsv"][supportId] | ||
235 | + for _, effect in ipairs(supportData.effect:toArray()) do | ||
236 | + local cur = effect:toArray(true, "=") | ||
237 | + if supportEffect[cur[1]] then | ||
238 | + supportEffect[cur[1]](table.unpack(cur)) | ||
239 | + end | ||
240 | + end | ||
241 | + end | ||
242 | +end | ||
243 | + | ||
244 | +function Adv:activeSomeSupport() | ||
245 | + -- 奖励物品 | ||
246 | + if self.support[1] then | ||
247 | + self:award(self.support[1]) | ||
248 | + self.support[1] = nil | ||
249 | + end | ||
250 | + | ||
251 | + -- 加buff | ||
252 | + if self.support[2] then | ||
253 | + for _, buffId in ipairs(self.support[2]) do | ||
254 | + self.battle.player:addBuff(buffId) | ||
255 | + end | ||
256 | + self.support[2] = nil | ||
257 | + end | ||
258 | + | ||
259 | + --加被动技 | ||
260 | + if self.support[3] then | ||
261 | + for _, passiveId in ipairs(self.support[3]) do | ||
262 | + self.battle.player:addPassive({id = passiveId}) | ||
263 | + end | ||
264 | + self.support[3] = nil | ||
265 | + end | ||
266 | + | ||
267 | + -- 加随机神器 | ||
268 | + if self.support[6] then | ||
269 | + local pool = {} | ||
270 | + for id, temp in pairs(csvdb["adv_artifactCsv"]) do | ||
271 | + if not self:isHaveArtifact(id) and self.owner:isArtifactOpen(id, self:isEndless()) then | ||
272 | + table.insert(pool, id) | ||
273 | + end | ||
274 | + end | ||
275 | + for i = 1, math.min(self.support[6], #pool) do | ||
276 | + local idx = math.randomInt(1, #pool) | ||
277 | + self:award({[pool[idx]] = 1}) | ||
278 | + table.remove(pool, idx) | ||
279 | + end | ||
280 | + self.support[6] = nil | ||
281 | + end | ||
282 | + | ||
283 | + self:supportChooseArtifact() | ||
284 | +end | ||
285 | + | ||
286 | +function Adv:supportChooseArtifact() | ||
287 | + -- 加 三选一 神器 | ||
288 | + if self.support[7] then | ||
289 | + if self.support[7] > 0 then | ||
290 | + self:waitChooseArtifact() | ||
291 | + end | ||
292 | + self.support[7] = self.support[7] - 1 | ||
293 | + if self.support[7] <= 0 then | ||
294 | + self.support[7] = nil | ||
295 | + end | ||
296 | + end | ||
297 | +end | ||
298 | + | ||
299 | +function Adv:supportFirstLayerAddEvent() | ||
300 | + if self.support[4] then | ||
301 | + local temp = self.support[4] | ||
302 | + self.support[4] = nil | ||
303 | + return temp | ||
304 | + end | ||
305 | +end | ||
306 | + | ||
307 | +function Adv:supportEveryLayerAddEvent() | ||
308 | + return self.support[5] | ||
309 | +end | ||
310 | + | ||
311 | + | ||
312 | +function Adv:isRunning() | ||
313 | + if self.chapterId then return true end | ||
314 | + return false | ||
315 | +end | ||
316 | + | ||
317 | +-- 强制结束 | ||
318 | +function Adv:forceOver(notNotify) | ||
319 | + if self:isRunning() then | ||
320 | + self:clear() | ||
321 | + local advTeam = self.owner:getProperty("advTeam") | ||
322 | + advTeam.player = nil | ||
323 | + | ||
324 | + local reward = self.owner:getProperty("advItems"):toNumMap() | ||
325 | + for itemId, count in pairs(reward) do | ||
326 | + reward[itemId] = math.ceil(count * globalCsv.adv_fail_reward_ratio / 100) -- 奖励相当于失败 | ||
327 | + end | ||
328 | + self.owner:award(reward) | ||
329 | + | ||
330 | + self.owner:updateProperties({ | ||
331 | + advInfo = {}, | ||
332 | + advTeam = advTeam, | ||
333 | + advItems = "", | ||
334 | + advAFGet = {}, | ||
335 | + advAFWear = {}, | ||
336 | + }, notNotify) | ||
337 | + end | ||
338 | +end | ||
339 | + | ||
340 | + | ||
341 | + | ||
204 | -- 1=抵达x层;2=通关x层;3=完成指定事件;4=完成指定连锁事件 | 342 | -- 1=抵达x层;2=通关x层;3=完成指定事件;4=完成指定连锁事件 |
205 | function Adv:checkAdvUnlock(utype, value) | 343 | function Adv:checkAdvUnlock(utype, value) |
206 | if not self.chapterId then return end | 344 | if not self.chapterId then return end |
@@ -453,6 +591,10 @@ function Adv:chooseArtifact(index) | @@ -453,6 +591,10 @@ function Adv:chooseArtifact(index) | ||
453 | if not self.waitArtifact or not self.waitArtifact[index] then return end | 591 | if not self.waitArtifact or not self.waitArtifact[index] then return end |
454 | self:award({[self.waitArtifact[index]] = 1}) | 592 | self:award({[self.waitArtifact[index]] = 1}) |
455 | self.waitArtifact = nil | 593 | self.waitArtifact = nil |
594 | + | ||
595 | + -- 支援效果继续选择 | ||
596 | + self:supportChooseArtifact() | ||
597 | + | ||
456 | return true | 598 | return true |
457 | end | 599 | end |
458 | 600 |
src/adv/AdvMap.lua
@@ -392,6 +392,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) | @@ -392,6 +392,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) | ||
392 | end | 392 | end |
393 | end | 393 | end |
394 | 394 | ||
395 | + -- 低保事件 | ||
396 | + local exEvent = {} | ||
397 | + -- 首层额外刷新 | ||
398 | + if isEnter then | ||
399 | + local first = self.adv:supportFirstLayerAddEvent() | ||
400 | + if first then | ||
401 | + exEvent = first | ||
402 | + end | ||
403 | + end | ||
404 | + -- 每层额外刷新 | ||
405 | + if not self.adv.isRelay then | ||
406 | + local every = self.adv:supportEveryLayerAddEvent() | ||
407 | + if every then | ||
408 | + for etype, events in pairs(every) do | ||
409 | + exEvent[etype] = exEvent[etype] or {} | ||
410 | + for id, num in pairs(events) do | ||
411 | + exEvent[etype][id] = (exEvent[etype][id] or 0) + num | ||
412 | + end | ||
413 | + end | ||
414 | + end | ||
415 | + end | ||
416 | + local lastCount = stagePool["global"][AdvCodeRandomStage] and #stagePool["global"][AdvCodeRandomStage] or 0 | ||
417 | + for etype, events in pairs(exEvent) do | ||
418 | + if lastCount <= 0 then break end | ||
419 | + for id, num in pairs(events) do | ||
420 | + if lastCount <= 0 then break end | ||
421 | + for i = 1, num do | ||
422 | + if lastCount <= 0 then break end | ||
423 | + | ||
424 | + local idx = math.randomInt(1, lastCount) | ||
425 | + local cur = stagePool["global"][AdvCodeRandomStage][idx] | ||
426 | + | ||
427 | + giveEvent(cur["room"], cur["block"], etype, id) | ||
428 | + | ||
429 | + table.remove(stagePool["global"][AdvCodeRandomStage], idx) | ||
430 | + lastCount = lastCount - 1 | ||
431 | + stagePool[cur["room"]][AdvCodeRandomStage][cur["block"]] = nil | ||
432 | + end | ||
433 | + end | ||
434 | + end | ||
435 | + | ||
436 | + | ||
395 | -- 全地图事件 优先级高 | 437 | -- 全地图事件 优先级高 |
396 | for stageType, events in pairs(mapData["events"]) do | 438 | for stageType, events in pairs(mapData["events"]) do |
397 | for _, event in ipairs(events) do | 439 | for _, event in ipairs(events) do |
src/adv/AdvTask.lua
@@ -225,9 +225,13 @@ function AdvTask.bind(Adv) | @@ -225,9 +225,13 @@ function AdvTask.bind(Adv) | ||
225 | 225 | ||
226 | local advAchievChange = {} | 226 | local advAchievChange = {} |
227 | 227 | ||
228 | - local function insertChange(chapterId, taskId, value) | 228 | + local function insertChange(chapterId, taskId, value, pts) |
229 | local achievField = AdvCommon.isEndless(chapterId) and "advEAchiev" or "advAchiev" | 229 | local achievField = AdvCommon.isEndless(chapterId) and "advEAchiev" or "advAchiev" |
230 | - table.insert(advAchievChange, {type = achievField, field = {chapterId, taskId}, value = value}) | 230 | + if pts then |
231 | + table.insert(advAchievChange, {type = achievField, field = {chapterId, "pts", taskId}, value = value}) | ||
232 | + else | ||
233 | + table.insert(advAchievChange, {type = achievField, field = {chapterId, taskId}, value = value}) | ||
234 | + end | ||
231 | end | 235 | end |
232 | 236 | ||
233 | function Adv:checkAchievement(taskType, count, cond, cond2) | 237 | function Adv:checkAchievement(taskType, count, cond, cond2) |
@@ -302,35 +306,48 @@ function AdvTask.bind(Adv) | @@ -302,35 +306,48 @@ function AdvTask.bind(Adv) | ||
302 | status = oldStatus + count | 306 | status = oldStatus + count |
303 | end | 307 | end |
304 | end | 308 | end |
305 | - if (status or -1) >= data.value1 then | ||
306 | - status = -1 | ||
307 | - end | ||
308 | - if status and status ~= oldStatus then | ||
309 | - insertChange(self.chapterId, taskId, status) | ||
310 | - if status == -1 then | ||
311 | - local ptcount = (self.owner:getProperty(achievField)[self.chapterId] or {})[-1] or 0 | ||
312 | - ptcount = ptcount + data.pt | ||
313 | - insertChange(self.chapterId, -1, ptcount) | 309 | + |
310 | + if self:isEndless() then | ||
311 | + if status and status ~= oldStatus then | ||
312 | + insertChange(self.chapterId, taskId, status) | ||
313 | + end | ||
314 | + else | ||
315 | + if (status or -1) >= data.value1 then | ||
316 | + status = -1 | ||
317 | + end | ||
318 | + if status and status ~= oldStatus then | ||
319 | + insertChange(self.chapterId, taskId, status) | ||
320 | + if status == -1 then | ||
321 | + local ptcount = (self.owner:getProperty(achievField)[self.chapterId] or {})[-1] or 0 | ||
322 | + ptcount = ptcount + data.pt | ||
323 | + insertChange(self.chapterId, -1, ptcount) | ||
324 | + end | ||
314 | end | 325 | end |
315 | end | 326 | end |
316 | - | ||
317 | end | 327 | end |
318 | end | 328 | end |
319 | end | 329 | end |
320 | 330 | ||
321 | - -- --说不用领取 注释掉 | ||
322 | - -- function Adv:finishAchievement(chapterId, taskId) | ||
323 | - -- local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId] | ||
324 | - -- local status = (self.owner:getProperty("advAchiev")[chapterId] or {})[taskId] or -1 | ||
325 | - | ||
326 | - -- if status >= achievData.value1 then | ||
327 | - -- insertChange(chapterId, taskId, -1) | ||
328 | - -- local count = (self.owner:getProperty("advAchiev")[chapterId] or {})[-1] or 0 | ||
329 | - -- count = count + achievData.pt | ||
330 | - -- insertChange(chapterId, -1, count) | ||
331 | - -- return true | ||
332 | - -- end | ||
333 | - -- end | 331 | + -- 说不用领取 注释掉 |
332 | + -- 又说要领取 打开 修改 | ||
333 | + function Adv:finishAchievement(chapterId, taskId) | ||
334 | + if not AdvCommon.isEndless(chapterId) then return end -- 暂时只有无尽可以领奖 | ||
335 | + local achievField = AdvCommon.isEndless(chapterId) and "advEAchiev" or "advAchiev" | ||
336 | + local achievData = (csvdb["adv_achievementCsv"][chapterId] or {})[taskId] | ||
337 | + local status = (self.owner:getProperty(achievField)[chapterId] or {})[taskId] or -1 | ||
338 | + | ||
339 | + local reward = {} | ||
340 | + if status >= achievData.value1 then | ||
341 | + insertChange(chapterId, taskId, -1) | ||
342 | + local count = (self.owner:getProperty(achievField)[chapterId] or {})[-1] or 0 | ||
343 | + count = count + achievData.pt | ||
344 | + insertChange(chapterId, -1, count) | ||
345 | + | ||
346 | + -- 发放奖励 | ||
347 | + reward = self.owner:award(achievData.reward) | ||
348 | + return true, reward | ||
349 | + end | ||
350 | + end | ||
334 | 351 | ||
335 | function Adv:getAchievementReward(chapterId, taskId) | 352 | function Adv:getAchievementReward(chapterId, taskId) |
336 | local achievField = AdvCommon.isEndless(chapterId) and "advEAchiev" or "advAchiev" | 353 | local achievField = AdvCommon.isEndless(chapterId) and "advEAchiev" or "advAchiev" |
@@ -340,7 +357,7 @@ function AdvTask.bind(Adv) | @@ -340,7 +357,7 @@ function AdvTask.bind(Adv) | ||
340 | if status == -1 or count < achievData.pt then return end | 357 | if status == -1 or count < achievData.pt then return end |
341 | 358 | ||
342 | local reward = self.owner:award(achievData.reward) | 359 | local reward = self.owner:award(achievData.reward) |
343 | - insertChange(chapterId, taskId, -1) | 360 | + insertChange(chapterId, taskId, -1, true) |
344 | return true, reward | 361 | return true, reward |
345 | end | 362 | end |
346 | 363 |
src/models/Daily.lua
@@ -22,6 +22,8 @@ Daily.schema = { | @@ -22,6 +22,8 @@ Daily.schema = { | ||
22 | 22 | ||
23 | dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计 | 23 | dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计 |
24 | dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计 | 24 | dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计 |
25 | + | ||
26 | + advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 | ||
25 | } | 27 | } |
26 | 28 | ||
27 | function Daily:updateProperty(params) | 29 | function Daily:updateProperty(params) |
@@ -92,6 +94,7 @@ function Daily:data() | @@ -92,6 +94,7 @@ function Daily:data() | ||
92 | pvpFree = self:getProperty("pvpFree"), | 94 | pvpFree = self:getProperty("pvpFree"), |
93 | dailySDC = self:getProperty("dailySDC"), | 95 | dailySDC = self:getProperty("dailySDC"), |
94 | dailySDD = self:getProperty("dailySDD"), | 96 | dailySDD = self:getProperty("dailySDD"), |
97 | + advSupRe = self:getProperty("advSupRe"), | ||
95 | } | 98 | } |
96 | end | 99 | end |
97 | 100 |
src/models/Role.lua
@@ -76,7 +76,8 @@ Role.schema = { | @@ -76,7 +76,8 @@ Role.schema = { | ||
76 | advShop = {"table", {}}, -- 冒险內的商店限制购买次数记录 {goodId = count} | 76 | advShop = {"table", {}}, -- 冒险內的商店限制购买次数记录 {goodId = count} |
77 | advEAchiev = {"table", {}}, -- 冒险无尽冒险手册 | 77 | advEAchiev = {"table", {}}, -- 冒险无尽冒险手册 |
78 | advRelay = {"table", {}}, -- 冒险中继点记录 {[chapter] = {[level] = 1}, [-1] = {[level] = 1}} -- -1 无尽 方便重置 | 78 | advRelay = {"table", {}}, -- 冒险中继点记录 {[chapter] = {[level] = 1}, [-1] = {[level] = 1}} -- -1 无尽 方便重置 |
79 | - | 79 | + advSup = {"table", {}}, -- 冒险支援效果 待选项 |
80 | + | ||
80 | --挂机相关 | 81 | --挂机相关 |
81 | hangPass = {"table", {}}, -- 挂机通过的最大关卡 | 82 | hangPass = {"table", {}}, -- 挂机通过的最大关卡 |
82 | hangTeam = {"table", {}}, -- 挂机队伍 | 83 | hangTeam = {"table", {}}, -- 挂机队伍 |
@@ -266,6 +267,7 @@ function Role:data() | @@ -266,6 +267,7 @@ function Role:data() | ||
266 | advDrawB = self:getProperty("advDrawB"), | 267 | advDrawB = self:getProperty("advDrawB"), |
267 | advShop = self:getProperty("advShop"), | 268 | advShop = self:getProperty("advShop"), |
268 | advEAchiev = self:getProperty("advEAchiev"), | 269 | advEAchiev = self:getProperty("advEAchiev"), |
270 | + advSup = self:getProperty("advSup"), | ||
269 | 271 | ||
270 | hangPass = self:getProperty("hangPass"), | 272 | hangPass = self:getProperty("hangPass"), |
271 | hangTeam = self:getProperty("hangTeam"), | 273 | hangTeam = self:getProperty("hangTeam"), |
src/models/RolePlugin.lua
@@ -32,7 +32,9 @@ function RolePlugin.bind(Role) | @@ -32,7 +32,9 @@ function RolePlugin.bind(Role) | ||
32 | self.dailyData:refreshDailyData(notify) | 32 | self.dailyData:refreshDailyData(notify) |
33 | self.dinerData:refreshDailyData(notify) | 33 | self.dinerData:refreshDailyData(notify) |
34 | self:setProperty("dTask", {}) | 34 | self:setProperty("dTask", {}) |
35 | + self:advRandomSupportEffect() | ||
35 | response.dTask = {} | 36 | response.dTask = {} |
37 | + response.advSup = self:getProperty("advSup") | ||
36 | 38 | ||
37 | 39 | ||
38 | if isCrossWeek(ltime, now) then | 40 | if isCrossWeek(ltime, now) then |
@@ -810,6 +812,61 @@ function RolePlugin.bind(Role) | @@ -810,6 +812,61 @@ function RolePlugin.bind(Role) | ||
810 | end | 812 | end |
811 | end | 813 | end |
812 | 814 | ||
815 | + -- 获得激活的冒险效果 | ||
816 | + function Role:getAdvActiveSupportEffect() | ||
817 | + local effect = {} | ||
818 | + local advEAchiev = self:getProperty("advEAchiev") | ||
819 | + for id, status in pairs(advEAchiev[self.advElChapter] or {}) do | ||
820 | + if status == -1 then | ||
821 | + local achvData = csvdb["adv_achievementCsv"][id] | ||
822 | + if achvData.support ~= 0 then | ||
823 | + effect[achvData.support] = 1 | ||
824 | + end | ||
825 | + end | ||
826 | + end | ||
827 | + return effect | ||
828 | + end | ||
829 | + | ||
830 | + --获取冒险支援效果免费刷新次数 | ||
831 | + function Role:getAdvSupportFreeCount() | ||
832 | + local count = 1 --默认每天有1次 | ||
833 | + local openEffects = self:getAdvActiveSupportEffect() | ||
834 | + for aId, _ in pairs(openEffects) do | ||
835 | + local curData = csvdb["adv_supportCsv"][aId] | ||
836 | + if curData.type == 2 then | ||
837 | + for _, effect in ipairs(curData.effect:toArray()) do | ||
838 | + local cur = effect:toArray(true, "=") | ||
839 | + if cur[1] == 8 then | ||
840 | + count = count + cur[2] | ||
841 | + end | ||
842 | + end | ||
843 | + end | ||
844 | + end | ||
845 | + return count | ||
846 | + end | ||
847 | + | ||
848 | + -- 冒险随机新的支援效果 | ||
849 | + function Role:advRandomSupportEffect(notNotify) | ||
850 | + local pool = {} | ||
851 | + local openEffects = self:getAdvActiveSupportEffect() | ||
852 | + for id, data in pairs(csvdb["adv_supportCsv"]) do | ||
853 | + if data.type == 0 then | ||
854 | + if openEffects[id] then | ||
855 | + table.insert(pool, data) | ||
856 | + end | ||
857 | + elseif data.type == 1 then | ||
858 | + table.insert(pool, data) | ||
859 | + end | ||
860 | + end | ||
861 | + | ||
862 | + local advSup = {} | ||
863 | + for i = 1, math.min(3, #pool) do | ||
864 | + local idx = math.randWeight(pool, "showup") | ||
865 | + table.insert(advSup, pool[idx].id) | ||
866 | + table.remove(pool, idx) | ||
867 | + end | ||
868 | + self:updateProperty({field = "advSup", value = advSup, notNotify = notNotify}) | ||
869 | + end | ||
813 | 870 | ||
814 | local StdDinerRankTime = toUnixtime("20190101"..string.format("%02x", RESET_RANK_TIME)) --跨天时间 | 871 | local StdDinerRankTime = toUnixtime("20190101"..string.format("%02x", RESET_RANK_TIME)) --跨天时间 |
815 | function Role:getCurDinerRankKey() | 872 | function Role:getCurDinerRankKey() |