Commit 3ad19fe42ce7c022290d5f769259cd1f8138c44e

Authored by zhangqijia
1 parent 7e2e5cff

feat: 贴纸兑换功能

src/ProtocolCode.lua
... ... @@ -117,6 +117,7 @@ actionCodes = {
117 117 Hero_setWishPoolRpc = 226,
118 118 Hero_changeSparkRpc = 227,
119 119 Hero_saveGeniusTreeRpc = 228,
  120 + Hero_stickersConvertRpc = 229, --兑换英雄贴纸
120 121  
121 122 Hang_startRpc = 251,
122 123 Hang_checkRpc = 252,
... ...
src/actions/HeroAction.lua
... ... @@ -1389,4 +1389,27 @@ function _M.saveGeniusTreeRpc(agent, data)
1389 1389 return true
1390 1390 end
1391 1391  
  1392 +function _M.stickersConvertRpc(agent, data)
  1393 + local role = agent.role
  1394 + local msg = MsgPack.unpack(data)
  1395 + local itemId = msg.itemId
  1396 + local heroType = msg.heroType -- heroId-300 举例 [泡泡]= {[heroType] = 120, [heroId]= 420}
  1397 +
  1398 + local itemData = csvdb[itemCsv][itemId]
  1399 + if not itemData then return 1 end
  1400 +
  1401 + local useEffect = itemData["use_effect"]:toNumMap()
  1402 + if not useEffect[heroType] then return 2 end
  1403 +
  1404 + if not role:isHaveHero(heroType) then return 3 end
  1405 +
  1406 + local cost = {[itemId] = 1}
  1407 + if not role:checkItemEnough(cost) then return 4 end
  1408 + role:costItems({[heroType] = cost}, {log = {desc = "heroStickers"}})
  1409 + local reward, change = role:award({[heroType] = 1}, {log = {desc = "heroStickers"}})
  1410 +
  1411 + SendPacket(actionCodes.Hero_stickersConvertRpc, MsgPack.pack(role:packReward(reward, change)))
  1412 + return true
  1413 +end
  1414 +
1392 1415 return _M
... ...
src/models/RoleLog.lua
... ... @@ -146,6 +146,7 @@ local ItemReason = {
146 146 sparkLvlUp = 1214, -- 火花强化
147 147 sparkQualityUp = 1215, -- 火花升华
148 148 heroGenius = 1216, -- 英雄天赋点
  149 + heroStickers = 1217, -- 英雄贴纸
149 150  
150 151 -- pvp
151 152 pvpCHead = 1301, -- pvp 跨服竞技场头像
... ...