Commit 289a4927e12daaa8b3f57d14925bf224fac99729
1 parent
4288160b
fix diner talent
Showing
4 changed files
with
60 additions
and
40 deletions
Show diff stats
.gitignore
src/actions/DinerAction.lua
... | ... | @@ -14,7 +14,7 @@ function _M.addSellRpc( agent, data ) |
14 | 14 | local sells = json.decode(role.dinerData:getProperty("sells")) |
15 | 15 | if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then |
16 | 16 | return 0 |
17 | - end | |
17 | + end | |
18 | 18 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then |
19 | 19 | return 1 |
20 | 20 | end |
... | ... | @@ -242,7 +242,7 @@ function _M.levelUpRpc( agent, data ) |
242 | 242 | |
243 | 243 | local cost = buildingData.starCost:toNumMap() |
244 | 244 | if not role:checkItemEnough(cost) then |
245 | - return | |
245 | + return | |
246 | 246 | end |
247 | 247 | |
248 | 248 | role:costItems(cost) |
... | ... | @@ -255,45 +255,64 @@ end |
255 | 255 | function _M.talentUpRpc( agent, data ) |
256 | 256 | local role = agent.role |
257 | 257 | local msg = MsgPack.unpack(data) |
258 | - | |
259 | 258 | local dish = msg.dish |
260 | - local dishSet = csvdb["diner_dishCsv"][dish] | |
261 | - if not dishSet then | |
262 | - return | |
263 | - end | |
264 | - | |
265 | 259 | local dishTree = role.dinerData:getProperty("dishTree") |
266 | 260 | local dishLevel = dishTree:getv(dish, 0) |
267 | - local cost = {} | |
268 | - local treePoint = {} | |
269 | - if dishLevel == 0 then | |
270 | - local dishData = dishSet[1] | |
271 | - if dishData.unlock_tree > 0 then | |
272 | - if dishTree:getv(dishData.unlock_tree, 0) == 0 then | |
273 | - return | |
274 | - end | |
275 | - end | |
276 | - if dishData.unlock_carbon > 0 then | |
277 | - local hangPass = role:getProperty("hangPass") | |
278 | - if not hangPass[dishData.unlock_carbon] then | |
279 | - return | |
280 | - end | |
281 | - end | |
282 | - cost = globalCsv.diner_sell_dish_talent_unlock:toNumMap() | |
283 | - else | |
284 | - if dishLevel >= #dishSet then | |
285 | - return | |
261 | + | |
262 | + local talentSet = csvdb["diner_talentCsv"][dish] | |
263 | + if not talentSet then | |
264 | + return 1 | |
265 | + end | |
266 | + | |
267 | + local talentData = talentSet[dishLevel] | |
268 | + if not talentData then | |
269 | + return 2 | |
270 | + end | |
271 | + | |
272 | + if not talentSet[dishLevel+1] then | |
273 | + return 21 | |
274 | + end | |
275 | + | |
276 | + local typ = math.floor(dish/100 + 1) | |
277 | + local treeSet = csvdb["diner_treeCsv"][typ] | |
278 | + if not treeSet then | |
279 | + return 3 | |
280 | + end | |
281 | + | |
282 | + local treeData = treeSet[dish] | |
283 | + if not treeData then | |
284 | + return 4 | |
285 | + end | |
286 | + | |
287 | + local limit = treeData.pointFront:toNumMap() | |
288 | + for k,v in pairs(limit) do | |
289 | + local lv = dishTree:getv(k, 0) | |
290 | + if lv < v then | |
291 | + return 5 | |
286 | 292 | end |
287 | - local dishData = dishSet[dishLevel] | |
288 | - cost = dishData.tree_material:toNumMap() | |
289 | - treePoint = dishData.tree_point:toNumMap() | |
290 | 293 | end |
294 | + | |
295 | + local cost = talentData.cost:toNumMap() | |
291 | 296 | if not role:checkItemEnough(cost) then |
292 | - return | |
297 | + return 6 | |
298 | + end | |
299 | + | |
300 | + -- 正在贩卖不能升级 | |
301 | + local sells = json.decode(role.dinerData:getProperty("sells")) | |
302 | + for slot, _ in pairs(sells) do | |
303 | + role.dinerData:updateSell(slot) | |
304 | + end | |
305 | + sells = json.decode(role.dinerData:getProperty("sells")) | |
306 | + for _, sell in pairs(sells) do | |
307 | + if sell.dish == msg.dish then | |
308 | + return 7 | |
309 | + end | |
293 | 310 | end |
294 | 311 | |
295 | 312 | role:costItems(cost) |
296 | 313 | role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) |
314 | + -- talentData.tree_point = "40=1" | |
315 | + local treePoint = talentData.tree_point:toNumMap() | |
297 | 316 | if next(treePoint) then |
298 | 317 | role:award(treePoint) |
299 | 318 | end |
... | ... | @@ -382,7 +401,7 @@ function _M.updateTaskRpc( agent, data ) |
382 | 401 | if not taskData then |
383 | 402 | return 5 |
384 | 403 | end |
385 | - | |
404 | + | |
386 | 405 | |
387 | 406 | if cmd == 0 then |
388 | 407 | if order.status ~= 0 then |
... | ... | @@ -446,8 +465,8 @@ function _M.refreshTaskRpc( agent, data ) |
446 | 465 | end |
447 | 466 | end |
448 | 467 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
449 | - | |
450 | - SendPacket(actionCodes.Diner_refreshTaskRpc, '') | |
468 | + | |
469 | + SendPacket(actionCodes.Diner_refreshTaskRpc, '') | |
451 | 470 | return true |
452 | 471 | end |
453 | 472 | ... | ... |
src/models/Diner.lua
... | ... | @@ -9,7 +9,7 @@ Diner.schema = { |
9 | 9 | order = {"string", "[]"}, -- 特殊订单 |
10 | 10 | sells = {"string", "[]"}, -- 贩卖位置 |
11 | 11 | hot = {"string", ""}, -- 今日热门 |
12 | - dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 | |
12 | + dishTree = {"string", "1=1 101=1 201=1"}, -- 料理天赋 | |
13 | 13 | skillTree = {"string", ""}, -- 支援天赋 |
14 | 14 | popular = {"number",0}, -- 累计人气 |
15 | 15 | expedite = {"number",1}, --每日加速次数 |
... | ... | @@ -25,7 +25,7 @@ function Diner:refreshDailyData(notify) |
25 | 25 | for index, dishData in ipairs(csvdb["diner_dishCsv"]) do |
26 | 26 | local check = true |
27 | 27 | local dish = dishData[1] |
28 | - if dish.unlock_tree > 0 and not dishTree[dish.unlock_tree] then | |
28 | + if not dishTree[dish.id] then | |
29 | 29 | check = false |
30 | 30 | end |
31 | 31 | if dish.unlock_carbon > 0 and not hangPass[dish.unlock_carbon] then |
... | ... | @@ -76,8 +76,8 @@ end |
76 | 76 | |
77 | 77 | function Diner:updateProperty(params) |
78 | 78 | params = params or {} |
79 | - if not self.schema[params.field] then | |
80 | - return | |
79 | + if not self.schema[params.field] then | |
80 | + return | |
81 | 81 | end |
82 | 82 | local oldValue = self:getProperty(params.field) |
83 | 83 | if params.value then |
... | ... | @@ -177,7 +177,7 @@ function Diner:updateSell(slot, calOnly) |
177 | 177 | if slot.hot then |
178 | 178 | sellTime = sellTime * dishData.popularity |
179 | 179 | end |
180 | - | |
180 | + | |
181 | 181 | deltaCount = math.floor(timePass / sellTime) |
182 | 182 | if deltaCount < sell.count then |
183 | 183 | deltaTime = math.floor(timePass - sellTime * deltaCount) | ... | ... |