Commit 9ced5432f646ff799228d8124547281c1f3644f6
1 parent
6fe355d6
冒险支援效果 保底事件
Showing
8 changed files
with
368 additions
and
63 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/AdvAction.lua
| ... | ... | @@ -84,6 +84,7 @@ function _M.startAdvRpc( agent, data ) |
| 84 | 84 | local chapterId = msg.chapterId --关卡id |
| 85 | 85 | local layer = msg.layer or 1 --选择层数 |
| 86 | 86 | local format = msg.format --编队 |
| 87 | + local supportIdx = msg.supportIdx --选择的支援效果 | |
| 87 | 88 | |
| 88 | 89 | --上一个关卡结束才可以开始新的关卡 |
| 89 | 90 | if role:getAdvData():isRunning() then return 8 end |
| ... | ... | @@ -109,7 +110,7 @@ function _M.startAdvRpc( agent, data ) |
| 109 | 110 | local relayData = role:getAdvData():isHaveRelay(layer, chapterId) |
| 110 | 111 | if not relayData then return end -- 不是中继层 |
| 111 | 112 | if advElM < relayData.unlockfloor then return end --未解锁 |
| 112 | - end | |
| 113 | + end | |
| 113 | 114 | else -- 普通模式判断 |
| 114 | 115 | if role.dailyData:getProperty("advC") >= role:getAdvHangLimit() then return 2 end -- 是否有体力 |
| 115 | 116 | if layer > chapterData.limitlevel then return 4 end |
| ... | ... | @@ -137,9 +138,30 @@ function _M.startAdvRpc( agent, data ) |
| 137 | 138 | role.dailyData:updateProperty({field = "advC", delta = 1}) |
| 138 | 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 | 162 | role:checkTaskEnter("AdvStart", {id = chapterId}) |
| 142 | 163 | role:checkTaskEnter("AdvStartSelf", {id = chapterId}) |
| 164 | + adv:popBackEvents() -- 清一下事件 | |
| 143 | 165 | SendPacket(actionCodes.Adv_startAdvRpc, '') |
| 144 | 166 | return true |
| 145 | 167 | end |
| ... | ... | @@ -647,18 +669,18 @@ end |
| 647 | 669 | function _M.finishAchievRpc(agent, data) |
| 648 | 670 | local role = agent.role |
| 649 | 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 | 673 | local chapterId = msg.chapterId --章节id |
| 652 | 674 | local taskId = msg.taskId -- 领取id |
| 653 | 675 | |
| 654 | 676 | local adv = role:getAdvData() |
| 655 | 677 | |
| 656 | 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 | 682 | status, reward = adv:getAchievementReward(chapterId, taskId) |
| 661 | - -- end | |
| 683 | + end | |
| 662 | 684 | if not status then return end |
| 663 | 685 | adv:updateAchievement() |
| 664 | 686 | SendPacket(actionCodes.Adv_finishAchievRpc, MsgPack.pack({reward = reward})) |
| ... | ... | @@ -701,4 +723,23 @@ function _M.rankRpc(agent, data) |
| 701 | 723 | return true |
| 702 | 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 | 745 | return _M |
| 705 | 746 | \ No newline at end of file | ... | ... |
src/adv/Adv.lua
| ... | ... | @@ -38,6 +38,7 @@ function Adv:initByInfo(advInfo) |
| 38 | 38 | self.waitArtifact = advInfo.waitAF |
| 39 | 39 | self.cacheUnlock = advInfo.cacheUnlock or {} |
| 40 | 40 | self.shopStatus = advInfo.shopStatus or {} |
| 41 | + self.support = advInfo.support or {} | |
| 41 | 42 | |
| 42 | 43 | self.maps = {} |
| 43 | 44 | for id, map in ipairs(advInfo.maps or {}) do |
| ... | ... | @@ -62,7 +63,7 @@ function Adv:isHaveRelay(level, chapterId) |
| 62 | 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 | 67 | if not self.chapterId then -- 开始新的章节 |
| 67 | 68 | self.chapterId = chapterId |
| 68 | 69 | self:checkAchievement(Adv.AchievType.StartBattle, 1) |
| ... | ... | @@ -78,6 +79,11 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt |
| 78 | 79 | self.lchoose = self.lchoose or {} |
| 79 | 80 | self.cacheUnlock = self.cacheUnlock or {} |
| 80 | 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 | 89 | local mapId |
| ... | ... | @@ -112,6 +118,9 @@ function Adv:initByChapter(chapterId, level, isToNext, notNotify, isRelay, isEnt |
| 112 | 118 | |
| 113 | 119 | self:initLayerTask() |
| 114 | 120 | |
| 121 | + -- 支援效果生效一些 | |
| 122 | + self:activeSomeSupport() | |
| 123 | + | |
| 115 | 124 | self:checkTask(Adv.TaskType.Arrive) |
| 116 | 125 | self:checkAdvUnlock(1, self.level) |
| 117 | 126 | if isToNext then |
| ... | ... | @@ -137,34 +146,7 @@ function Adv:clear() |
| 137 | 146 | self.isRelay = nil |
| 138 | 147 | self.cacheUnlock = {} |
| 139 | 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 | 150 | end |
| 169 | 151 | |
| 170 | 152 | function Adv:saveDB(notNotify) |
| ... | ... | @@ -182,6 +164,7 @@ function Adv:saveDB(notNotify) |
| 182 | 164 | advInfo.waitAF = self.waitArtifact |
| 183 | 165 | advInfo.cacheUnlock = self.cacheUnlock |
| 184 | 166 | advInfo.shopStatus = self.shopStatus |
| 167 | + advInfo.support = self.support | |
| 185 | 168 | advInfo.maps = {} |
| 186 | 169 | |
| 187 | 170 | self.battle:saveDB() |
| ... | ... | @@ -201,6 +184,161 @@ function Adv:saveDB(notNotify) |
| 201 | 184 | self.owner:updateProperties({advInfo = advInfo, advTeam = advTeam}, notNotify) |
| 202 | 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 | 342 | -- 1=抵达x层;2=通关x层;3=完成指定事件;4=完成指定连锁事件 |
| 205 | 343 | function Adv:checkAdvUnlock(utype, value) |
| 206 | 344 | if not self.chapterId then return end |
| ... | ... | @@ -453,6 +591,10 @@ function Adv:chooseArtifact(index) |
| 453 | 591 | if not self.waitArtifact or not self.waitArtifact[index] then return end |
| 454 | 592 | self:award({[self.waitArtifact[index]] = 1}) |
| 455 | 593 | self.waitArtifact = nil |
| 594 | + | |
| 595 | + -- 支援效果继续选择 | |
| 596 | + self:supportChooseArtifact() | |
| 597 | + | |
| 456 | 598 | return true |
| 457 | 599 | end |
| 458 | 600 | ... | ... |
src/adv/AdvMap.lua
| ... | ... | @@ -392,6 +392,48 @@ createMap = function(self, mapId, isEnter, isNewRelay) |
| 392 | 392 | end |
| 393 | 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 | 438 | for stageType, events in pairs(mapData["events"]) do |
| 397 | 439 | for _, event in ipairs(events) do | ... | ... |
src/adv/AdvTask.lua
| ... | ... | @@ -225,9 +225,13 @@ function AdvTask.bind(Adv) |
| 225 | 225 | |
| 226 | 226 | local advAchievChange = {} |
| 227 | 227 | |
| 228 | - local function insertChange(chapterId, taskId, value) | |
| 228 | + local function insertChange(chapterId, taskId, value, pts) | |
| 229 | 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 | 235 | end |
| 232 | 236 | |
| 233 | 237 | function Adv:checkAchievement(taskType, count, cond, cond2) |
| ... | ... | @@ -302,35 +306,48 @@ function AdvTask.bind(Adv) |
| 302 | 306 | status = oldStatus + count |
| 303 | 307 | end |
| 304 | 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 | 325 | end |
| 315 | 326 | end |
| 316 | - | |
| 317 | 327 | end |
| 318 | 328 | end |
| 319 | 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 | 352 | function Adv:getAchievementReward(chapterId, taskId) |
| 336 | 353 | local achievField = AdvCommon.isEndless(chapterId) and "advEAchiev" or "advAchiev" |
| ... | ... | @@ -340,7 +357,7 @@ function AdvTask.bind(Adv) |
| 340 | 357 | if status == -1 or count < achievData.pt then return end |
| 341 | 358 | |
| 342 | 359 | local reward = self.owner:award(achievData.reward) |
| 343 | - insertChange(chapterId, taskId, -1) | |
| 360 | + insertChange(chapterId, taskId, -1, true) | |
| 344 | 361 | return true, reward |
| 345 | 362 | end |
| 346 | 363 | ... | ... |
src/models/Daily.lua
| ... | ... | @@ -22,6 +22,8 @@ Daily.schema = { |
| 22 | 22 | |
| 23 | 23 | dailySDC = {"table", {}}, -- daily shop diamond count {[id] = count} -- 每日商城购买次数统计 |
| 24 | 24 | dailySDD = {"table", {}}, -- daily shop diamond disount {[id] = 1} -- 每日商城折扣统计 |
| 25 | + | |
| 26 | + advSupRe = {"number", 0}, -- 冒险支援效果刷新次数 | |
| 25 | 27 | } |
| 26 | 28 | |
| 27 | 29 | function Daily:updateProperty(params) |
| ... | ... | @@ -92,6 +94,7 @@ function Daily:data() |
| 92 | 94 | pvpFree = self:getProperty("pvpFree"), |
| 93 | 95 | dailySDC = self:getProperty("dailySDC"), |
| 94 | 96 | dailySDD = self:getProperty("dailySDD"), |
| 97 | + advSupRe = self:getProperty("advSupRe"), | |
| 95 | 98 | } |
| 96 | 99 | end |
| 97 | 100 | ... | ... |
src/models/Role.lua
| ... | ... | @@ -76,7 +76,8 @@ Role.schema = { |
| 76 | 76 | advShop = {"table", {}}, -- 冒险內的商店限制购买次数记录 {goodId = count} |
| 77 | 77 | advEAchiev = {"table", {}}, -- 冒险无尽冒险手册 |
| 78 | 78 | advRelay = {"table", {}}, -- 冒险中继点记录 {[chapter] = {[level] = 1}, [-1] = {[level] = 1}} -- -1 无尽 方便重置 |
| 79 | - | |
| 79 | + advSup = {"table", {}}, -- 冒险支援效果 待选项 | |
| 80 | + | |
| 80 | 81 | --挂机相关 |
| 81 | 82 | hangPass = {"table", {}}, -- 挂机通过的最大关卡 |
| 82 | 83 | hangTeam = {"table", {}}, -- 挂机队伍 |
| ... | ... | @@ -266,6 +267,7 @@ function Role:data() |
| 266 | 267 | advDrawB = self:getProperty("advDrawB"), |
| 267 | 268 | advShop = self:getProperty("advShop"), |
| 268 | 269 | advEAchiev = self:getProperty("advEAchiev"), |
| 270 | + advSup = self:getProperty("advSup"), | |
| 269 | 271 | |
| 270 | 272 | hangPass = self:getProperty("hangPass"), |
| 271 | 273 | hangTeam = self:getProperty("hangTeam"), | ... | ... |
src/models/RolePlugin.lua
| ... | ... | @@ -32,7 +32,9 @@ function RolePlugin.bind(Role) |
| 32 | 32 | self.dailyData:refreshDailyData(notify) |
| 33 | 33 | self.dinerData:refreshDailyData(notify) |
| 34 | 34 | self:setProperty("dTask", {}) |
| 35 | + self:advRandomSupportEffect() | |
| 35 | 36 | response.dTask = {} |
| 37 | + response.advSup = self:getProperty("advSup") | |
| 36 | 38 | |
| 37 | 39 | |
| 38 | 40 | if isCrossWeek(ltime, now) then |
| ... | ... | @@ -810,6 +812,61 @@ function RolePlugin.bind(Role) |
| 810 | 812 | end |
| 811 | 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 | 871 | local StdDinerRankTime = toUnixtime("20190101"..string.format("%02x", RESET_RANK_TIME)) --跨天时间 |
| 815 | 872 | function Role:getCurDinerRankKey() | ... | ... |