Commit 7d44dca251802172fcfbfbc168c417010d2cc833

Authored by zhengshouren
1 parent f9c6cac9

支援技能升级逻辑

Showing 2 changed files with 35 additions and 0 deletions   Show diff stats
src/ProtocolCode.lua
@@ -62,6 +62,7 @@ actionCodes = { @@ -62,6 +62,7 @@ actionCodes = {
62 Diner_getSellRewardRpc = 302, 62 Diner_getSellRewardRpc = 302,
63 Diner_levelUpRpc = 303, 63 Diner_levelUpRpc = 303,
64 Diner_talentUpRpc = 304, 64 Diner_talentUpRpc = 304,
  65 + Diner_skillUpRpc = 305,
65 } 66 }
66 67
67 rpcResponseBegin = 10000 68 rpcResponseBegin = 10000
src/actions/DinerAction.lua
@@ -164,4 +164,38 @@ function _M.talentUpRpc( agent, data ) @@ -164,4 +164,38 @@ function _M.talentUpRpc( agent, data )
164 return true 164 return true
165 end 165 end
166 166
  167 +function _M.skillUpRpc( agent, data )
  168 + local role = agent.role
  169 + local msg = MsgPack.unpack(data)
  170 +
  171 + local skill = msg.skill
  172 + local skillSet = csvdb["diner_skillCsv"][skill]
  173 + if not skillSet then
  174 + return
  175 + end
  176 +
  177 + local skillTree = role.dinerData:getProperty("skillTree")
  178 + local skillLevel = skillTree:getv(skill, 1)
  179 + local skillData = skillSet[skillLevel]
  180 + if not skillData then
  181 + return
  182 + end
  183 + if skillData.unlock ~= "" then
  184 + local id, level = skillData.unlock:math("(%d+)=(%d+)")
  185 + if skillTree:getv(tonumber(id), 1) < tonumber(level) then
  186 + return
  187 + end
  188 + end
  189 + local cost = skillData.cost:toNumMap()
  190 + if not role:checkItemEnough(cost) then
  191 + return
  192 + end
  193 +
  194 + role:costItems(cost)
  195 + role.dinerData:updateProperty({field = "skillTree", value = skillTree:setv(skill, skillLevel + 1)})
  196 +
  197 + SendPacket(actionCodes.Diner_skillUpRpc, '')
  198 + return true
  199 +end
  200 +
167 return _M 201 return _M
168 \ No newline at end of file 202 \ No newline at end of file