Commit fb3210753670251ae1d379635b8fa5ab3f52fe5a
1 parent
ee3ac0b5
add rune up
Showing
3 changed files
with
33 additions
and
1 deletions
Show diff stats
src/ProtocolCode.lua
src/actions/CarAction.lua
... | ... | @@ -90,4 +90,35 @@ function _M.equipUpRpc( agent, data ) |
90 | 90 | return true |
91 | 91 | end |
92 | 92 | |
93 | +function _M.runeUpRpc( agent, data ) | |
94 | + local role = agent.role | |
95 | + local msg = MsgPack.unpack(data) | |
96 | + local uid = msg.uid | |
97 | + local ownRune = role.runeBag[uid] | |
98 | + if not ownRune then return 1 end | |
99 | + if ownRune:getProperty("refer") ~= 0 then return 2 end | |
100 | + | |
101 | + local typ = ownRune:getProperty("type") | |
102 | + local id = ownRune:getProperty("id") | |
103 | + local level = ownRune:getProperty("level") | |
104 | + | |
105 | + local runeSet = csvdb["runeCsv"][typ] | |
106 | + if not runeSet then return 4 end | |
107 | + local runeData = runeSet[id] | |
108 | + if not runeData then return 5 end | |
109 | + | |
110 | + local maxLv = #csvdb["rune_buildCsv"] | |
111 | + if level >= maxLv then return 6 end | |
112 | + local lvData = csvdb["rune_buildCsv"][level+1] | |
113 | + local cost = lvData.cost:toNumMap() | |
114 | + if not role:checkItemEnough(cost) then | |
115 | + return 7 | |
116 | + end | |
117 | + | |
118 | + role:costItems(cost) | |
119 | + ownRune:updateProperty({field = "level",value = level+1}) | |
120 | + SendPacket(actionCodes.Car_runeUpRpc, '') | |
121 | + return true | |
122 | +end | |
123 | + | |
93 | 124 | return _M |
94 | 125 | \ No newline at end of file | ... | ... |
src/actions/HeroAction.lua
... | ... | @@ -541,7 +541,7 @@ function _M.referRunesRpc(agent, data) |
541 | 541 | |
542 | 542 | local runeSet = csvdb["runeCsv"][typ] |
543 | 543 | if not runeSet then return 5 end |
544 | - local runeData = runeSet[ownRune.id] | |
544 | + local runeData = runeSet[ownRune:getProperty("id")] | |
545 | 545 | if not runeData then return 6 end |
546 | 546 | end |
547 | 547 | end | ... | ... |