Commit ba33bcac0ff5664fe7f93872f144d517d93d8bba
1 parent
e6845afa
挂机章节解锁
Showing
4 changed files
with
39 additions
and
1 deletions
Show diff stats
src/ProtocolCode.lua
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 | ... | ... |
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 | ... | ... |