diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index cde77fc..e59ca7b 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -69,6 +69,7 @@ actionCodes = { Diner_refreshTaskRpc = 309, Diner_expediteSellRpc = 310, Diner_getGreenhouseRpc = 311, + Diner_makePotionRpc = 312, } rpcResponseBegin = 10000 diff --git a/src/actions/DinerAction.lua b/src/actions/DinerAction.lua index b0ccff5..1efe492 100644 --- a/src/actions/DinerAction.lua +++ b/src/actions/DinerAction.lua @@ -297,7 +297,7 @@ function _M.talentUpRpc( agent, data ) return 6 end - -- 正在贩卖不能升级 + -- 正在贩卖不能升级料理天赋 local sells = json.decode(role.dinerData:getProperty("sells")) for slot, _ in pairs(sells) do role.dinerData:updateSell(slot) @@ -309,9 +309,13 @@ function _M.talentUpRpc( agent, data ) end end + -- 正在冒险不能升级营养剂天赋 + if talentData.effect:split2()[1] == 2 then + if next(role.advTeam) then return 8 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) @@ -501,4 +505,40 @@ function _M.getGreenhouseRpc( agent, data ) return true end +function _M.makePotionRpc( agent, data ) + local role = agent.role + local msg = MsgPack.unpack(data) + local potionId = msg.id + local count = msg.count + if count < 1 then return 0 end + local potionBag = role:getProperty("potionBag") + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0) + if potionLv < 1 then return 1 end + + local potionSet = csvdb["adv_potionCsv"][potionId] + if not potionSet then return 2 end + + local potionData = potionSet[potionLv] + if not potionData then return 3 end + + local own = potionBag[potionId] or 0 + if own+count > potionData.limit then + return 4 + end + + local cost = potionData.material:toNumMap() + for _, n in pairs(cost) do + n = n * count + end + if not role:checkItemEnough(cost) then + return 5 + end + + role:costItems(cost) + potionBag[potionId] = own + count + role:updateProperty({field = "potionBag", value = potionBag}) + SendPacket(actionCodes.Diner_makePotionRpc, MsgPack.pack({potionBag = potionBag})) + return true +end + return _M \ No newline at end of file diff --git a/src/csvdata b/src/csvdata index 9c9b513..48bcf09 160000 --- a/src/csvdata +++ b/src/csvdata @@ -1 +1 @@ -Subproject commit 9c9b5130c9acea03c877095d5bd8f3e34437bdb8 +Subproject commit 48bcf09fd9d9b66f7c7f06553f3b3a49d723364e diff --git a/src/models/Role.lua b/src/models/Role.lua index 9b514ec..cb3fe08 100644 --- a/src/models/Role.lua +++ b/src/models/Role.lua @@ -52,6 +52,7 @@ Role.schema = { hangBag = {"table", {}}, -- 背包 hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 + potionBag = {"table", {}}, -- 营养剂背包 } @@ -113,7 +114,7 @@ function Role:changeUpdates(params, notNotify) error("[ERROR:] need handler for changeUpdate, field : " .. fieldType) return end - --支持多深度单字段 + --支持多深度单字段 local curValue = self:getProperty(fieldType) if type(info["field"]) == "table" then for _idx, _field in ipairs(info["field"]) do @@ -155,7 +156,7 @@ function Role:data() loveStatus = self:getProperty("loveStatus"):toNumMap(), diamond = self:getAllDiamond(), bagLimit = self:getProperty("bagLimit"), - + advPass = self:getProperty("advPass"), advInfo = self:getProperty("advInfo"), advItems = self:getProperty("advItems"):toNumMap(), @@ -166,6 +167,8 @@ function Role:data() hangInfo = self:getProperty("hangInfo"), hangBag = self:getProperty("hangBag"), hangBagLimit = self:getProperty("hangBagLimit"), + + potionBag = self:getProperty("potionBag"), } end -- libgit2 0.21.2