Commit b67180e8d7c31132cb329bafaa970ab88376d001
1 parent
36204e3c
餐厅天赋升级
Showing
1 changed file
with
50 additions
and
0 deletions
 
Show diff stats
src/actions/DinerAction.lua
| ... | ... | @@ -104,4 +104,54 @@ function _M.levelUpRpc( agent, data ) | 
| 104 | 104 | return true | 
| 105 | 105 | end | 
| 106 | 106 | |
| 107 | +function _M.talentUpRpc( agent, data ) | |
| 108 | + local role = agent.role | |
| 109 | + local msg = MsgPack.unpack(data) | |
| 110 | + | |
| 111 | + local dish = msg.dish | |
| 112 | + local dishSet = csvdb["diner_dishCsv"][dish] | |
| 113 | + if not dishSet then | |
| 114 | + return | |
| 115 | + end | |
| 116 | + | |
| 117 | + local dishTree = role.dinerData:getProperty("dishTree") | |
| 118 | + local dishLevel = dishTree:getv(dish, 0) | |
| 119 | + local cost = {} | |
| 120 | + local treePoint = {} | |
| 121 | + if dishLevel == 0 then | |
| 122 | + local dishData = dishSet[1] | |
| 123 | + if dishData.unlock_tree > 0 then | |
| 124 | + if dishTree:getv(dishData.unlock_tree, 0) == 0 then | |
| 125 | + return | |
| 126 | + end | |
| 127 | + end | |
| 128 | + if dishData.unlock_carbon > 0 then | |
| 129 | + local hangPass = role:getProperty("hangPass") | |
| 130 | + if not hangPass[dishData.unlock_carbon] then | |
| 131 | + return | |
| 132 | + end | |
| 133 | + end | |
| 134 | + cost = globalCsv.diner_sell_dish_talent_unlock:toNumMap() | |
| 135 | + else | |
| 136 | + if dishLevel >= #dishSet then | |
| 137 | + return | |
| 138 | + end | |
| 139 | + local dishData = dishSet[dishLevel] | |
| 140 | + cost = dishData.tree_material:toNumMap() | |
| 141 | + treePoint = dishData.tree_point:toNumMap() | |
| 142 | + end | |
| 143 | + if not role:checkItemEnough(cost) then | |
| 144 | + return | |
| 145 | + end | |
| 146 | + | |
| 147 | + role:costItems(cost) | |
| 148 | + role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) | |
| 149 | + if next(treePoint) then | |
| 150 | + role:award(treePoint) | |
| 151 | + end | |
| 152 | + | |
| 153 | + SendPacket(actionCodes.Diner_talentUpRpc, '') | |
| 154 | + return true | |
| 155 | +end | |
| 156 | + | |
| 107 | 157 | return _M | 
| 108 | 158 | \ No newline at end of file | ... | ... |