Commit 9c525cf9006f91873396f2688792a16352571fe5

Authored by gaofengduan
1 parent d904b7fd

add car smithy

src/ProtocolCode.lua
... ... @@ -69,7 +69,9 @@ actionCodes = {
69 69 Diner_refreshTaskRpc = 309,
70 70 Diner_expediteSellRpc = 310,
71 71 Diner_getGreenhouseRpc = 311,
72   - Diner_makePotionRpc = 312,
  72 +
  73 + Car_makePotionRpc = 400,
  74 + Car_equipUpRpc = 401,
73 75 }
74 76  
75 77 rpcResponseBegin = 10000
... ...
src/actions/CarAction.lua 0 → 100644
... ... @@ -0,0 +1,92 @@
  1 +local ipairs = ipairs
  2 +local table = table
  3 +local math = math
  4 +local redisproxy = redisproxy
  5 +local MsgPack = MsgPack
  6 +
  7 +local _M = {}
  8 +
  9 +function _M.makePotionRpc( agent, data )
  10 + local role = agent.role
  11 + local msg = MsgPack.unpack(data)
  12 + local potionId = msg.id
  13 + local count = msg.count
  14 + if count < 1 then return 0 end
  15 + local potionBag = role:getProperty("potionBag")
  16 + local potionLv = role.dinerData:getProperty("dishTree"):getv(potionId, 0)
  17 + if potionLv < 1 then return 1 end
  18 +
  19 + local potionSet = csvdb["adv_potionCsv"][potionId]
  20 + if not potionSet then return 2 end
  21 +
  22 + local potionData = potionSet[potionLv]
  23 + if not potionData then return 3 end
  24 +
  25 + local own = potionBag[potionId] or 0
  26 + if own+count > potionData.limit then
  27 + return 4
  28 + end
  29 +
  30 + local cost = potionData.material:toNumMap()
  31 + for _, n in pairs(cost) do
  32 + n = n * count
  33 + end
  34 + if not role:checkItemEnough(cost) then
  35 + return 5
  36 + end
  37 +
  38 + role:costItems(cost)
  39 + potionBag[potionId] = own + count
  40 + role:updateProperty({field = "potionBag", value = potionBag})
  41 + SendPacket(actionCodes.Car_makePotionRpc, MsgPack.pack({potionBag = potionBag}))
  42 + return true
  43 +end
  44 +
  45 +function _M.equipUpRpc( agent, data )
  46 + local role = agent.role
  47 + local msg = MsgPack.unpack(data)
  48 + local id = msg.id
  49 + local count = msg.count
  50 + if count < 1 then return 0 end
  51 + local typ = math.floor((id-7000)/100)
  52 + local lv = (id-7000)%100
  53 +
  54 + local dataSet = csvdb["equipCsv"][typ]
  55 + if not dataSet then return 1 end
  56 + local equipData = dataSet[lv]
  57 + if not equipData then return 21 end
  58 + if equipData.merge < 1 then return 22 end
  59 + local maxLv = 3
  60 + local nextLv = lv+1
  61 + if nextLv%10 > maxLv then
  62 + nextLv = nextLv+10-maxLv
  63 + end
  64 + local nextEquip = dataSet[nextLv]
  65 + if not nextEquip then return 23 end
  66 +
  67 + local own = role:getItemCount(id)
  68 + if own < count then
  69 + return 3
  70 + end
  71 +
  72 + local cost = equipData.cost:toNumMap()
  73 + for _, n in pairs(cost) do
  74 + n = n * count
  75 + end
  76 + if not role:checkItemEnough(cost) then
  77 + return 4
  78 + end
  79 +
  80 + local merge = {[id]=equipData.merge*count}
  81 + if not role:checkItemEnough(merge) then
  82 + return 5
  83 + end
  84 +
  85 + role:costItems(cost)
  86 + role:costItems(merge)
  87 + role:addItem({itemId = nextEquip.id,count = count})
  88 + SendPacket(actionCodes.Car_equipUpRpc, '')
  89 + return true
  90 +end
  91 +
  92 +return _M
0 93 \ No newline at end of file
... ...
src/actions/DinerAction.lua
... ... @@ -505,40 +505,4 @@ function _M.getGreenhouseRpc( agent, data )
505 505 return true
506 506 end
507 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   -
544 508 return _M
545 509 \ No newline at end of file
... ...
1   -Subproject commit 1807df3783895d92aa5b85851aef9c5f222187cb
  1 +Subproject commit a1b5d35f852b178c50c4c570c86c7a2066188f62
... ...
src/models/Hero.lua
... ... @@ -14,7 +14,8 @@ Hero.schema = {
14 14 battleV = {"number", 0}, -- 保存战斗力
15 15 loveExp = {"number", 0}, --好感度经验
16 16 loveL = {"number", 0}, --好感度等级
17   - skin = {"number", 0}, --皮肤 0 、 1、 2、 3
  17 + skin = {"number", 0}, --皮肤 0 、 1、 2、 3
  18 + equip = {"string",""}, --装备 type=level
18 19 }
19 20  
20 21 function Hero:ctor( properties )
... ...