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,7 +14,7 @@ function _M.addSellRpc( agent, data ) | ||
| 14 | local sells = json.decode(role.dinerData:getProperty("sells")) | 14 | local sells = json.decode(role.dinerData:getProperty("sells")) |
| 15 | if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then | 15 | if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then |
| 16 | return 0 | 16 | return 0 |
| 17 | - end | 17 | + end |
| 18 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then | 18 | if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then |
| 19 | return 1 | 19 | return 1 |
| 20 | end | 20 | end |
| @@ -242,7 +242,7 @@ function _M.levelUpRpc( agent, data ) | @@ -242,7 +242,7 @@ function _M.levelUpRpc( agent, data ) | ||
| 242 | 242 | ||
| 243 | local cost = buildingData.starCost:toNumMap() | 243 | local cost = buildingData.starCost:toNumMap() |
| 244 | if not role:checkItemEnough(cost) then | 244 | if not role:checkItemEnough(cost) then |
| 245 | - return | 245 | + return |
| 246 | end | 246 | end |
| 247 | 247 | ||
| 248 | role:costItems(cost) | 248 | role:costItems(cost) |
| @@ -255,45 +255,64 @@ end | @@ -255,45 +255,64 @@ end | ||
| 255 | function _M.talentUpRpc( agent, data ) | 255 | function _M.talentUpRpc( agent, data ) |
| 256 | local role = agent.role | 256 | local role = agent.role |
| 257 | local msg = MsgPack.unpack(data) | 257 | local msg = MsgPack.unpack(data) |
| 258 | - | ||
| 259 | local dish = msg.dish | 258 | local dish = msg.dish |
| 260 | - local dishSet = csvdb["diner_dishCsv"][dish] | ||
| 261 | - if not dishSet then | ||
| 262 | - return | ||
| 263 | - end | ||
| 264 | - | ||
| 265 | local dishTree = role.dinerData:getProperty("dishTree") | 259 | local dishTree = role.dinerData:getProperty("dishTree") |
| 266 | local dishLevel = dishTree:getv(dish, 0) | 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 | end | 292 | end |
| 287 | - local dishData = dishSet[dishLevel] | ||
| 288 | - cost = dishData.tree_material:toNumMap() | ||
| 289 | - treePoint = dishData.tree_point:toNumMap() | ||
| 290 | end | 293 | end |
| 294 | + | ||
| 295 | + local cost = talentData.cost:toNumMap() | ||
| 291 | if not role:checkItemEnough(cost) then | 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 | end | 310 | end |
| 294 | 311 | ||
| 295 | role:costItems(cost) | 312 | role:costItems(cost) |
| 296 | role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) | 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 | if next(treePoint) then | 316 | if next(treePoint) then |
| 298 | role:award(treePoint) | 317 | role:award(treePoint) |
| 299 | end | 318 | end |
| @@ -382,7 +401,7 @@ function _M.updateTaskRpc( agent, data ) | @@ -382,7 +401,7 @@ function _M.updateTaskRpc( agent, data ) | ||
| 382 | if not taskData then | 401 | if not taskData then |
| 383 | return 5 | 402 | return 5 |
| 384 | end | 403 | end |
| 385 | - | 404 | + |
| 386 | 405 | ||
| 387 | if cmd == 0 then | 406 | if cmd == 0 then |
| 388 | if order.status ~= 0 then | 407 | if order.status ~= 0 then |
| @@ -446,8 +465,8 @@ function _M.refreshTaskRpc( agent, data ) | @@ -446,8 +465,8 @@ function _M.refreshTaskRpc( agent, data ) | ||
| 446 | end | 465 | end |
| 447 | end | 466 | end |
| 448 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) | 467 | role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) |
| 449 | - | ||
| 450 | - SendPacket(actionCodes.Diner_refreshTaskRpc, '') | 468 | + |
| 469 | + SendPacket(actionCodes.Diner_refreshTaskRpc, '') | ||
| 451 | return true | 470 | return true |
| 452 | end | 471 | end |
| 453 | 472 |
src/models/Diner.lua
| @@ -9,7 +9,7 @@ Diner.schema = { | @@ -9,7 +9,7 @@ Diner.schema = { | ||
| 9 | order = {"string", "[]"}, -- 特殊订单 | 9 | order = {"string", "[]"}, -- 特殊订单 |
| 10 | sells = {"string", "[]"}, -- 贩卖位置 | 10 | sells = {"string", "[]"}, -- 贩卖位置 |
| 11 | hot = {"string", ""}, -- 今日热门 | 11 | hot = {"string", ""}, -- 今日热门 |
| 12 | - dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 | 12 | + dishTree = {"string", "1=1 101=1 201=1"}, -- 料理天赋 |
| 13 | skillTree = {"string", ""}, -- 支援天赋 | 13 | skillTree = {"string", ""}, -- 支援天赋 |
| 14 | popular = {"number",0}, -- 累计人气 | 14 | popular = {"number",0}, -- 累计人气 |
| 15 | expedite = {"number",1}, --每日加速次数 | 15 | expedite = {"number",1}, --每日加速次数 |
| @@ -25,7 +25,7 @@ function Diner:refreshDailyData(notify) | @@ -25,7 +25,7 @@ function Diner:refreshDailyData(notify) | ||
| 25 | for index, dishData in ipairs(csvdb["diner_dishCsv"]) do | 25 | for index, dishData in ipairs(csvdb["diner_dishCsv"]) do |
| 26 | local check = true | 26 | local check = true |
| 27 | local dish = dishData[1] | 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 | check = false | 29 | check = false |
| 30 | end | 30 | end |
| 31 | if dish.unlock_carbon > 0 and not hangPass[dish.unlock_carbon] then | 31 | if dish.unlock_carbon > 0 and not hangPass[dish.unlock_carbon] then |
| @@ -76,8 +76,8 @@ end | @@ -76,8 +76,8 @@ end | ||
| 76 | 76 | ||
| 77 | function Diner:updateProperty(params) | 77 | function Diner:updateProperty(params) |
| 78 | params = params or {} | 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 | end | 81 | end |
| 82 | local oldValue = self:getProperty(params.field) | 82 | local oldValue = self:getProperty(params.field) |
| 83 | if params.value then | 83 | if params.value then |
| @@ -177,7 +177,7 @@ function Diner:updateSell(slot, calOnly) | @@ -177,7 +177,7 @@ function Diner:updateSell(slot, calOnly) | ||
| 177 | if slot.hot then | 177 | if slot.hot then |
| 178 | sellTime = sellTime * dishData.popularity | 178 | sellTime = sellTime * dishData.popularity |
| 179 | end | 179 | end |
| 180 | - | 180 | + |
| 181 | deltaCount = math.floor(timePass / sellTime) | 181 | deltaCount = math.floor(timePass / sellTime) |
| 182 | if deltaCount < sell.count then | 182 | if deltaCount < sell.count then |
| 183 | deltaTime = math.floor(timePass - sellTime * deltaCount) | 183 | deltaTime = math.floor(timePass - sellTime * deltaCount) |