Commit d4f83f164ed30dcd919405ffd1e7b77ce5ce6cb4
1 parent
a997a3b0
feat: 一番赏 增加抽扭蛋机消耗票 指令
Capsule_convertCapsuleRpc = 890, --兑换消耗票
Showing
4 changed files
with
27 additions
and
3 deletions
Show diff stats
src/ProtocolCode.lua
... | ... | @@ -59,7 +59,7 @@ actionCodes = { |
59 | 59 | Role_runeBuyRpc = 142, -- 铭文购买 |
60 | 60 | Role_setFriendTeamRpc = 143, -- 设置好友切磋队伍 |
61 | 61 | Role_setBgRpc = 144, -- 设置看板娘 |
62 | - Role_itemExchangeRpc = 145, -- 道具兑换 | |
62 | + Role_itemConvertMonthCardRpc = 145, -- 兑换月卡道具 | |
63 | 63 | |
64 | 64 | Adv_startAdvRpc = 151, |
65 | 65 | Adv_startHangRpc = 152, |
... | ... | @@ -284,6 +284,7 @@ actionCodes = { |
284 | 284 | Capsule_payReward = 857, -- 特殊赏 奖励通知 |
285 | 285 | Capsule_exitRpc = 858, -- 退出 |
286 | 286 | Capsule_getDataRpc = 859, --获取扭蛋机信息 |
287 | + Capsule_convertCapsuleRpc = 890, --兑换消耗票 | |
287 | 288 | } |
288 | 289 | |
289 | 290 | rpcResponseBegin = 10000 | ... | ... |
src/actions/CapsuleAction.lua
... | ... | @@ -173,4 +173,26 @@ function _M.getDataRpc(agent, data) |
173 | 173 | |
174 | 174 | end |
175 | 175 | |
176 | +function _M.convertCapsuleRpc(agent, data) | |
177 | + local role = agent.role | |
178 | + local msg = MsgPack.unpack(data) | |
179 | + local coin = msg.coin | |
180 | + local count = msg.count or 1 | |
181 | + | |
182 | + local cost, convert = {} | |
183 | + for k, v in pairs(globalCsv.ichibankuji_buy_cost)do | |
184 | + if k == coin then | |
185 | + convert = v:toArray(true, "=") | |
186 | + break | |
187 | + end | |
188 | + end | |
189 | + cost[convert[1]] = convert[2] * count | |
190 | + if not role:checkItemEnough(cost) then return 1 end | |
191 | + role:costItems(cost, {log = {desc = "CapsuleConvert", int1 = convert[1], int2 = cost[convert[1]]}}) | |
192 | + | |
193 | + local reward, change = role:award({coin = count}, {log = {desc = "CapsuleConvert"}}) | |
194 | + SendPacket(actionCodes.Capsule_convertCapsuleRpc, MsgPack.pack(role:packReward(reward, change))) | |
195 | + return true | |
196 | +end | |
197 | + | |
176 | 198 | return _M |
177 | 199 | \ No newline at end of file | ... | ... |
src/actions/RoleAction.lua
... | ... | @@ -1710,7 +1710,7 @@ function _M.setBgRpc(agent, data) |
1710 | 1710 | return true |
1711 | 1711 | end |
1712 | 1712 | |
1713 | -function _M.itemExchangeRpc(agent, data) | |
1713 | +function _M.itemConvertMonthCardRpc(agent, data) | |
1714 | 1714 | local role = agent.role |
1715 | 1715 | local msg = MsgPack.unpack(data) |
1716 | 1716 | local itemId = msg.item_id |
... | ... | @@ -1738,7 +1738,7 @@ function _M.itemExchangeRpc(agent, data) |
1738 | 1738 | end |
1739 | 1739 | end |
1740 | 1740 | |
1741 | - SendPacket(actionCodes.Role_itemExchangeRpc, MsgPack.pack(role:packReward(reward))) | |
1741 | + SendPacket(actionCodes.Role_itemConvertMonthCardRpc, MsgPack.pack(role:packReward(reward))) | |
1742 | 1742 | return status |
1743 | 1743 | end |
1744 | 1744 | ... | ... |