Commit 24dbed0fec4c69fdc686794a5b92159b7aa27a18
Merge branch 'cn/develop' into cn/publish/preview
Showing
3 changed files
with
22 additions
and
0 deletions
Show diff stats
src/ProtocolCode.lua
... | ... | @@ -64,6 +64,7 @@ actionCodes = { |
64 | 64 | Role_itemConvertSpecialRpc = 145, -- 兑换月卡/战令探索指令等 特殊道具 |
65 | 65 | Role_worldLineRouletteRpc = 146, --世界线抽轮盘 |
66 | 66 | Role_worldLineRewardRpc = 147, -- 世界线一键领取奖励 |
67 | + Role_itemConvertDevilTicketRpc = 148, -- 兑换魔鬼训练营门票 | |
67 | 68 | |
68 | 69 | Adv_startAdvRpc = 151, |
69 | 70 | Adv_startHangRpc = 152, | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -1819,4 +1819,24 @@ function _M.worldLineRewardRpc(agent, data) |
1819 | 1819 | return true |
1820 | 1820 | end |
1821 | 1821 | |
1822 | +function _M.itemConvertDevilTicketRpc(agent, data) | |
1823 | + local role = agent.role | |
1824 | + local msg = MsgPack.unpack(data) | |
1825 | + local itemId = msg.itemId --道具id | |
1826 | + local count = msg.count or 1 --兑换生成的数量 | |
1827 | + local itemData = csvdb["itemCsv"][itemId] | |
1828 | + if itemData.use_type ~= 11 then return 2 end | |
1829 | + | |
1830 | + local createCost = globalCsv.moguixunlianying_create_cost[itemId]:toArray(true, "=") | |
1831 | + if not next(createCost) then return 3 end | |
1832 | + | |
1833 | + local cost = {[itemId] = createCost[1] * count} | |
1834 | + if not role:checkItemEnough(cost) then return 4 end | |
1835 | + role:costItems({cost}, {log = {desc = "itemConvertDevilTicket"}}) | |
1836 | + local reward, change = role:award({[createCost[2]] = count}, {log = {desc = "itemConvertDevilTicket", int1 = itemId, int2 = cost[itemId]}}) | |
1837 | + | |
1838 | + SendPacket(actionCodes.Role_itemConvertDevilTicketRpc, MsgPack.pack(role:packReward(reward, change))) | |
1839 | + return true | |
1840 | +end | |
1841 | + | |
1822 | 1842 | return _M |
1823 | 1843 | \ No newline at end of file | ... | ... |
src/models/RoleLog.lua