Commit 3ad19fe42ce7c022290d5f769259cd1f8138c44e
1 parent
7e2e5cff
feat: 贴纸兑换功能
Showing
3 changed files
with
25 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
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