Commit ba33bcac0ff5664fe7f93872f144d517d93d8bba

Authored by liuzujun
1 parent e6845afa

挂机章节解锁

src/ProtocolCode.lua
... ... @@ -122,6 +122,7 @@ actionCodes = {
122 122 Hang_bagFieldRpc = 263,
123 123 Hang_chatLineRpc = 264,
124 124 Hang_selectTeamRpc = 265,
  125 + Hang_unlockChapterRpc = 270,
125 126  
126 127 Diner_updateProperty = 300,
127 128 Diner_addSellRpc = 301,
... ...
src/actions/HangAction.lua
... ... @@ -138,6 +138,15 @@ function _M.startRpc( agent, data )
138 138 if not role:checkHangPass(preCarbonId) then return 2 end
139 139 end
140 140  
  141 + local carbonId = msg.carbonId -- 解锁章节id
  142 + local condition = globalCsv.idle_chapter_unlock[carbonId]
  143 + if condition then
  144 + local unlockChapter = role:getProperty("unlockChap")
  145 + if not unlockChapter[carbonId] then
  146 + return 3
  147 + end
  148 + end
  149 +
141 150 if checkReward(role) then
142 151 role:updateProperty({field = "hangBag", value = role:getProperty("hangBag")})
143 152 end
... ... @@ -847,4 +856,28 @@ function _M.selectTeamRpc(agent, data)
847 856 return true
848 857 end
849 858  
  859 +function _M.unlockChapterRpc(agent, data)
  860 + local role = agent.role
  861 + local msg = MsgPack.unpack(data)
  862 + local carbonId = msg.carbonId -- 解锁章节id
  863 + local condition = globalCsv.idle_chapter_unlock[carbonId]
  864 + if not condition then return 1 end
  865 + local conditionMap = condition:toArray(true, "=")
  866 + local count, level = conditionMap[1],conditionMap[2]
  867 + local cnt = 0
  868 + for _, hero in pairs(role.heros) do
  869 + if hero:getProperty("level") >= level then
  870 + cnt = cnt + 1
  871 + end
  872 + end
  873 + if cnt < count then return 2 end
  874 +
  875 + local unlockChapter = role:getProperty("unlockChap")
  876 + unlockChapter[carbonId] = 1
  877 + role:updateProperty({field="unlockChap", value = unlockChapter})
  878 +
  879 + SendPacket(actionCodes.Hang_unlockChapterRpc, '')
  880 + return true
  881 +end
  882 +
850 883 return _M
... ...
1   -Subproject commit 00e1022c3cd5edb6487933d1c839a7d186c0ecc4
  1 +Subproject commit c69c59c16cc4a4b2d121c86461bb62d725768dab
... ...
src/models/Role.lua
... ... @@ -199,6 +199,8 @@ Role.schema = {
199 199 returner = {"table", {}}, -- 回归者 {time = 12334233423, [1] = 1, [2] = 2, status = {[1] = 1}}
200 200  
201 201 roleIncre = {"table", {}}, -- 角色英雄,铭文,火花自增序列 {heroId = 1, runeId = 1, sparkId = 1}
  202 +
  203 + unlockChap = {"table", {}}, -- 解锁的章节
202 204 }
203 205  
204 206  
... ... @@ -432,6 +434,8 @@ function Role:data()
432 434  
433 435 seaport = self:getProperty("seaport"),
434 436 returner = self:getProperty("returner"),
  437 +
  438 + unlockChap = self:getProperty("unlockChap"), -- 解锁的章节
435 439 }
436 440 end
437 441  
... ...