diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index f7f4a8f..7ea7d4a 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -104,4 +104,54 @@ function _M.levelUpRpc( agent, data ) return true end +function _M.talentUpRpc( agent, data ) + local role = agent.role + local msg = MsgPack.unpack(data) + + local dish = msg.dish + local dishSet = csvdb["diner_dishCsv"][dish] + if not dishSet then + return + end + + local dishTree = role.dinerData:getProperty("dishTree") + local dishLevel = dishTree:getv(dish, 0) + local cost = {} + local treePoint = {} + if dishLevel == 0 then + local dishData = dishSet[1] + if dishData.unlock_tree > 0 then + if dishTree:getv(dishData.unlock_tree, 0) == 0 then + return + end + end + if dishData.unlock_carbon > 0 then + local hangPass = role:getProperty("hangPass") + if not hangPass[dishData.unlock_carbon] then + return + end + end + cost = globalCsv.diner_sell_dish_talent_unlock:toNumMap() + else + if dishLevel >= #dishSet then + return + end + local dishData = dishSet[dishLevel] + cost = dishData.tree_material:toNumMap() + treePoint = dishData.tree_point:toNumMap() + end + if not role:checkItemEnough(cost) then + return + end + + role:costItems(cost) + role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) + if next(treePoint) then + role:award(treePoint) + end + + SendPacket(actionCodes.Diner_talentUpRpc, '') + return true +end + return _M \ No newline at end of file -- libgit2 0.21.2