From ba33bcac0ff5664fe7f93872f144d517d93d8bba Mon Sep 17 00:00:00 2001 From: liuzujun <307836273@qq.com> Date: Tue, 6 Apr 2021 19:52:17 +0800 Subject: [PATCH] 挂机章节解锁 --- src/ProtocolCode.lua | 1 + src/actions/HangAction.lua | 33 +++++++++++++++++++++++++++++++++ src/csvdata | 2 +- src/models/Role.lua | 4 ++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index fa12c7a..b734eae 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -122,6 +122,7 @@ actionCodes = { Hang_bagFieldRpc = 263, Hang_chatLineRpc = 264, Hang_selectTeamRpc = 265, + Hang_unlockChapterRpc = 270, Diner_updateProperty = 300, Diner_addSellRpc = 301, diff --git a/src/actions/HangAction.lua b/src/actions/HangAction.lua index 4473841..a9b6166 100644 --- a/src/actions/HangAction.lua +++ b/src/actions/HangAction.lua @@ -138,6 +138,15 @@ function _M.startRpc( agent, data ) if not role:checkHangPass(preCarbonId) then return 2 end end + local carbonId = msg.carbonId -- 解锁章节id + local condition = globalCsv.idle_chapter_unlock[carbonId] + if condition then + local unlockChapter = role:getProperty("unlockChap") + if not unlockChapter[carbonId] then + return 3 + end + end + if checkReward(role) then role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")}) end @@ -847,4 +856,28 @@ function _M.selectTeamRpc(agent, data) return true end +function _M.unlockChapterRpc(agent, data) + local role = agent.role + local msg = MsgPack.unpack(data) + local carbonId = msg.carbonId -- 解锁章节id + local condition = globalCsv.idle_chapter_unlock[carbonId] + if not condition then return 1 end + local conditionMap = condition:toArray(true, "=") + local count, level = conditionMap[1],conditionMap[2] + local cnt = 0 + for _, hero in pairs(role.heros) do + if hero:getProperty("level") >= level then + cnt = cnt + 1 + end + end + if cnt < count then return 2 end + + local unlockChapter = role:getProperty("unlockChap") + unlockChapter[carbonId] = 1 + role:updateProperty({field="unlockChap", value = unlockChapter}) + + SendPacket(actionCodes.Hang_unlockChapterRpc, '') + return true +end + return _M diff --git a/src/csvdata b/src/csvdata index 00e1022..c69c59c 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 00e1022c3cd5edb6487933d1c839a7d186c0ecc4 +Subproject commit c69c59c16cc4a4b2d121c86461bb62d725768dab diff --git a/src/models/Role.lua b/src/models/Role.lua index 4c392d1..3a3a044 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -199,6 +199,8 @@ Role.schema = { returner = {"table", {}}, -- 回归者 {time = 12334233423, [1] = 1, [2] = 2, status = {[1] = 1}} roleIncre = {"table", {}}, -- 角色英雄,铭文,火花自增序列 {heroId = 1, runeId = 1, sparkId = 1} + + unlockChap = {"table", {}}, -- 解锁的章节 } @@ -432,6 +434,8 @@ function Role:data() seaport = self:getProperty("seaport"), returner = self:getProperty("returner"), + + unlockChap = self:getProperty("unlockChap"), -- 解锁的章节 } end -- libgit2 0.21.2