Commit dbd0ca58e0d6ecdb07297c30730d0a1f4769fec4
1 parent
289a4927
car 营养剂制作
Showing
4 changed files
with
49 additions
and
5 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/DinerAction.lua
| ... | ... | @@ -297,7 +297,7 @@ function _M.talentUpRpc( agent, data ) |
| 297 | 297 | return 6 |
| 298 | 298 | end |
| 299 | 299 | |
| 300 | - -- 正在贩卖不能升级 | |
| 300 | + -- 正在贩卖不能升级料理天赋 | |
| 301 | 301 | local sells = json.decode(role.dinerData:getProperty("sells")) |
| 302 | 302 | for slot, _ in pairs(sells) do |
| 303 | 303 | role.dinerData:updateSell(slot) |
| ... | ... | @@ -309,9 +309,13 @@ function _M.talentUpRpc( agent, data ) |
| 309 | 309 | end |
| 310 | 310 | end |
| 311 | 311 | |
| 312 | + -- 正在冒险不能升级营养剂天赋 | |
| 313 | + if talentData.effect:split2()[1] == 2 then | |
| 314 | + if next(role.advTeam) then return 8 end | |
| 315 | + end | |
| 316 | + | |
| 312 | 317 | role:costItems(cost) |
| 313 | 318 | role.dinerData:updateProperty({field = "dishTree", value = dishTree:setv(dish, dishLevel + 1)}) |
| 314 | - -- talentData.tree_point = "40=1" | |
| 315 | 319 | local treePoint = talentData.tree_point:toNumMap() |
| 316 | 320 | if next(treePoint) then |
| 317 | 321 | role:award(treePoint) |
| ... | ... | @@ -501,4 +505,40 @@ function _M.getGreenhouseRpc( agent, data ) |
| 501 | 505 | return true |
| 502 | 506 | end |
| 503 | 507 | |
| 508 | +function _M.makePotionRpc( agent, data ) | |
| 509 | + local role = agent.role | |
| 510 | + local msg = MsgPack.unpack(data) | |
| 511 | + local potionId = msg.id | |
| 512 | + local count = msg.count | |
| 513 | + if count < 1 then return 0 end | |
| 514 | + local potionBag = role:getProperty("potionBag") | |
| 515 | + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0) | |
| 516 | + if potionLv < 1 then return 1 end | |
| 517 | + | |
| 518 | + local potionSet = csvdb["adv_potionCsv"][potionId] | |
| 519 | + if not potionSet then return 2 end | |
| 520 | + | |
| 521 | + local potionData = potionSet[potionLv] | |
| 522 | + if not potionData then return 3 end | |
| 523 | + | |
| 524 | + local own = potionBag[potionId] or 0 | |
| 525 | + if own+count > potionData.limit then | |
| 526 | + return 4 | |
| 527 | + end | |
| 528 | + | |
| 529 | + local cost = potionData.material:toNumMap() | |
| 530 | + for _, n in pairs(cost) do | |
| 531 | + n = n * count | |
| 532 | + end | |
| 533 | + if not role:checkItemEnough(cost) then | |
| 534 | + return 5 | |
| 535 | + end | |
| 536 | + | |
| 537 | + role:costItems(cost) | |
| 538 | + potionBag[potionId] = own + count | |
| 539 | + role:updateProperty({field = "potionBag", value = potionBag}) | |
| 540 | + SendPacket(actionCodes.Diner_makePotionRpc, MsgPack.pack({potionBag = potionBag})) | |
| 541 | + return true | |
| 542 | +end | |
| 543 | + | |
| 504 | 544 | return _M |
| 505 | 545 | \ No newline at end of file | ... | ... |
src/models/Role.lua
| ... | ... | @@ -52,6 +52,7 @@ Role.schema = { |
| 52 | 52 | hangBag = {"table", {}}, -- 背包 |
| 53 | 53 | hangBagLimit = {"number", globalCsv.idle_field_origin}, --背包上限 |
| 54 | 54 | |
| 55 | + potionBag = {"table", {}}, -- 营养剂背包 | |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | |
| ... | ... | @@ -113,7 +114,7 @@ function Role:changeUpdates(params, notNotify) |
| 113 | 114 | error("[ERROR:] need handler for changeUpdate, field : " .. fieldType) |
| 114 | 115 | return |
| 115 | 116 | end |
| 116 | - --支持多深度单字段 | |
| 117 | + --支持多深度单字段 | |
| 117 | 118 | local curValue = self:getProperty(fieldType) |
| 118 | 119 | if type(info["field"]) == "table" then |
| 119 | 120 | for _idx, _field in ipairs(info["field"]) do |
| ... | ... | @@ -155,7 +156,7 @@ function Role:data() |
| 155 | 156 | loveStatus = self:getProperty("loveStatus"):toNumMap(), |
| 156 | 157 | diamond = self:getAllDiamond(), |
| 157 | 158 | bagLimit = self:getProperty("bagLimit"), |
| 158 | - | |
| 159 | + | |
| 159 | 160 | advPass = self:getProperty("advPass"), |
| 160 | 161 | advInfo = self:getProperty("advInfo"), |
| 161 | 162 | advItems = self:getProperty("advItems"):toNumMap(), |
| ... | ... | @@ -166,6 +167,8 @@ function Role:data() |
| 166 | 167 | hangInfo = self:getProperty("hangInfo"), |
| 167 | 168 | hangBag = self:getProperty("hangBag"), |
| 168 | 169 | hangBagLimit = self:getProperty("hangBagLimit"), |
| 170 | + | |
| 171 | + potionBag = self:getProperty("potionBag"), | |
| 169 | 172 | } |
| 170 | 173 | end |
| 171 | 174 | ... | ... |