diff --git a/.gitignore b/.gitignore index 397b4a7..f0cdea5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.log +dump.rdb diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index f1f2b7c..b0ccff5 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -14,7 +14,7 @@ function _M.addSellRpc( agent, data ) local sells = json.decode(role.dinerData:getProperty("sells")) if sells[slot] and sells[slot].count and sells[slot].count ~= 0 then return 0 - end + end if math.illegalNum(slot, 1, role.dinerData:getMaxSlots()) then return 1 end @@ -242,7 +242,7 @@ function _M.levelUpRpc( agent, data ) local cost = buildingData.starCost:toNumMap() if not role:checkItemEnough(cost) then - return + return end role:costItems(cost) @@ -255,45 +255,64 @@ 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 + + local talentSet = csvdb["diner_talentCsv"][dish] + if not talentSet then + return 1 + end + + local talentData = talentSet[dishLevel] + if not talentData then + return 2 + end + + if not talentSet[dishLevel+1] then + return 21 + end + + local typ = math.floor(dish/100 + 1) + local treeSet = csvdb["diner_treeCsv"][typ] + if not treeSet then + return 3 + end + + local treeData = treeSet[dish] + if not treeData then + return 4 + end + + local limit = treeData.pointFront:toNumMap() + for k,v in pairs(limit) do + local lv = dishTree:getv(k, 0) + if lv < v then + return 5 end - local dishData = dishSet[dishLevel] - cost = dishData.tree_material:toNumMap() - treePoint = dishData.tree_point:toNumMap() end + + local cost = talentData.cost:toNumMap() if not role:checkItemEnough(cost) then - return + return 6 + end + + -- 正在贩卖不能升级 + local sells = json.decode(role.dinerData:getProperty("sells")) + for slot, _ in pairs(sells) do + role.dinerData:updateSell(slot) + end + sells = json.decode(role.dinerData:getProperty("sells")) + for _, sell in pairs(sells) do + if sell.dish == msg.dish then + return 7 + end end role:costItems(cost) role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) + -- talentData.tree_point = "40=1" + local treePoint = talentData.tree_point:toNumMap() if next(treePoint) then role:award(treePoint) end @@ -382,7 +401,7 @@ function _M.updateTaskRpc( agent, data ) if not taskData then return 5 end - + if cmd == 0 then if order.status ~= 0 then @@ -446,8 +465,8 @@ function _M.refreshTaskRpc( agent, data ) end end role.dinerData:updateProperty({field = "order", value = json.encode(orders)}) - - SendPacket(actionCodes.Diner_refreshTaskRpc, '') + + SendPacket(actionCodes.Diner_refreshTaskRpc, '') return true end diff --git a/src/csvdata b/src/csvdata index b3c136e..9c9b513 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit b3c136ed3c1915513552fe327ec0e724a1acb35c +Subproject commit 9c9b5130c9acea03c877095d5bd8f3e34437bdb8 diff --git a/src/models/Diner.lua b/src/models/Diner.lua index 1af7953..2540714 100644 --- a/src/models/Diner.lua +++ b/src/models/Diner.lua @@ -9,7 +9,7 @@ Diner.schema = { order = {"string", "[]"}, -- 特殊订单 sells = {"string", "[]"}, -- 贩卖位置 hot = {"string", ""}, -- 今日热门 - dishTree = {"string", "1=1 2=1 3=1"}, -- 料理天赋 + dishTree = {"string", "1=1 101=1 201=1"}, -- 料理天赋 skillTree = {"string", ""}, -- 支援天赋 popular = {"number",0}, -- 累计人气 expedite = {"number",1}, --每日加速次数 @@ -25,7 +25,7 @@ function Diner:refreshDailyData(notify) for index, dishData in ipairs(csvdb["diner_dishCsv"]) do local check = true local dish = dishData[1] - if dish.unlock_tree > 0 and not dishTree[dish.unlock_tree] then + if not dishTree[dish.id] then check = false end if dish.unlock_carbon > 0 and not hangPass[dish.unlock_carbon] then @@ -76,8 +76,8 @@ end function Diner:updateProperty(params) params = params or {} - if not self.schema[params.field] then - return + if not self.schema[params.field] then + return end local oldValue = self:getProperty(params.field) if params.value then @@ -177,7 +177,7 @@ function Diner:updateSell(slot, calOnly) if slot.hot then sellTime = sellTime * dishData.popularity end - + deltaCount = math.floor(timePass / sellTime) if deltaCount < sell.count then deltaTime = math.floor(timePass - sellTime * deltaCount) -- libgit2 0.21.2