From fb3210753670251ae1d379635b8fa5ab3f52fe5a Mon Sep 17 00:00:00 2001 From: gaofengduan <782277855@qq.com> Date: Thu, 4 Jul 2019 11:37:29 +0800 Subject: [PATCH] add rune up --- src/ProtocolCode.lua | 1 + src/actions/CarAction.lua | 31 +++++++++++++++++++++++++++++++ src/actions/HeroAction.lua | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ProtocolCode.lua b/src/ProtocolCode.lua index 5b4a25d..435939a 100644 --- a/src/ProtocolCode.lua +++ b/src/ProtocolCode.lua @@ -76,6 +76,7 @@ actionCodes = { Car_makePotionRpc = 400, Car_equipUpRpc = 401, + Car_runeUpRpc = 402, } rpcResponseBegin = 10000 diff --git a/src/actions/CarAction.lua b/src/actions/CarAction.lua index 882c1ab..3157091 100644 --- a/src/actions/CarAction.lua +++ b/src/actions/CarAction.lua @@ -90,4 +90,35 @@ function _M.equipUpRpc( agent, data ) return true end +function _M.runeUpRpc( agent, data ) + local role = agent.role + local msg = MsgPack.unpack(data) + local uid = msg.uid + local ownRune = role.runeBag[uid] + if not ownRune then return 1 end + if ownRune:getProperty("refer") ~= 0 then return 2 end + + local typ = ownRune:getProperty("type") + local id = ownRune:getProperty("id") + local level = ownRune:getProperty("level") + + local runeSet = csvdb["runeCsv"][typ] + if not runeSet then return 4 end + local runeData = runeSet[id] + if not runeData then return 5 end + + local maxLv = #csvdb["rune_buildCsv"] + if level >= maxLv then return 6 end + local lvData = csvdb["rune_buildCsv"][level+1] + local cost = lvData.cost:toNumMap() + if not role:checkItemEnough(cost) then + return 7 + end + + role:costItems(cost) + ownRune:updateProperty({field = "level",value = level+1}) + SendPacket(actionCodes.Car_runeUpRpc, '') + return true +end + return _M \ No newline at end of file diff --git a/src/actions/HeroAction.lua b/src/actions/HeroAction.lua index d1f88c1..c476cc7 100644 --- a/src/actions/HeroAction.lua +++ b/src/actions/HeroAction.lua @@ -541,7 +541,7 @@ function _M.referRunesRpc(agent, data) local runeSet = csvdb["runeCsv"][typ] if not runeSet then return 5 end - local runeData = runeSet[ownRune.id] + local runeData = runeSet[ownRune:getProperty("id")] if not runeData then return 6 end end end -- libgit2 0.21.2