Commit 3ad19fe42ce7c022290d5f769259cd1f8138c44e
1 parent
7e2e5cff
feat: 贴纸兑换功能
Showing
3 changed files
with
25 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
| @@ -117,6 +117,7 @@ actionCodes = { | @@ -117,6 +117,7 @@ actionCodes = { | ||
| 117 | Hero_setWishPoolRpc = 226, | 117 | Hero_setWishPoolRpc = 226, |
| 118 | Hero_changeSparkRpc = 227, | 118 | Hero_changeSparkRpc = 227, |
| 119 | Hero_saveGeniusTreeRpc = 228, | 119 | Hero_saveGeniusTreeRpc = 228, |
| 120 | + Hero_stickersConvertRpc = 229, --兑换英雄贴纸 | ||
| 120 | 121 | ||
| 121 | Hang_startRpc = 251, | 122 | Hang_startRpc = 251, |
| 122 | Hang_checkRpc = 252, | 123 | Hang_checkRpc = 252, |
src/actions/HeroAction.lua
| @@ -1389,4 +1389,27 @@ function _M.saveGeniusTreeRpc(agent, data) | @@ -1389,4 +1389,27 @@ function _M.saveGeniusTreeRpc(agent, data) | ||
| 1389 | return true | 1389 | return true |
| 1390 | end | 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 | return _M | 1415 | return _M |
src/models/RoleLog.lua
| @@ -146,6 +146,7 @@ local ItemReason = { | @@ -146,6 +146,7 @@ local ItemReason = { | ||
| 146 | sparkLvlUp = 1214, -- 火花强化 | 146 | sparkLvlUp = 1214, -- 火花强化 |
| 147 | sparkQualityUp = 1215, -- 火花升华 | 147 | sparkQualityUp = 1215, -- 火花升华 |
| 148 | heroGenius = 1216, -- 英雄天赋点 | 148 | heroGenius = 1216, -- 英雄天赋点 |
| 149 | + heroStickers = 1217, -- 英雄贴纸 | ||
| 149 | 150 | ||
| 150 | -- pvp | 151 | -- pvp |
| 151 | pvpCHead = 1301, -- pvp 跨服竞技场头像 | 152 | pvpCHead = 1301, -- pvp 跨服竞技场头像 |