diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 2c0b8de..494bad9 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -1716,31 +1716,41 @@ function _M.itemConvertSpecialRpc(agent, data) local role = agent.role local msg = MsgPack.unpack(data) local itemId = msg.item_id - local count = msg.count or 1 - local exchangeId = msg.exchange_id + local exchangeId = tonumber(msg.exchange_id) local itemData = csvdb["itemCsv"][itemId] if not itemData then return 1 end - if not role:checkItemEnough({[itemId] = count}) then return 2 end - role:costItems({[itemId] = count}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}}) - local rechargeData = csvdb["shop_rechargeCsv"][exchangeId] if not rechargeData then skynet.error("[recharge] recharge id not exist", exchangeId) - return 3 + return 2 end - local reward = {} - for i = 1, count do - local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.id , rechargeData.activity_id) + + if not role:checkItemEnough({[itemId] = 1}) then return 3 end + + local reward = {} + if rechargeData.type == CardType.ActBattleCommandCard then + if role.activity:isOpenById(rechargeData.activity_id, "ActShopGoods") then + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) + if tmpreward then + table.rewardMerge(reward, tmpreward) + end + else + skynet.error("not open id: ".. rechargeData.id .. "; actid: " .. rechargeData.activity_id) + SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack({result = 4})) + return true + end + else + local tmpreward, _ = role.storeData:onBuyCard(rechargeData.type, rechargeData.time, rechargeData.id, rechargeData.activity_id) if tmpreward then table.rewardMerge(reward, tmpreward) - else - return end end - SendPacket(actionCodes.Role_itemConvertMonthCardRpc, MsgPack.pack(role:packReward(reward))) + role:costItems({[itemId] = 1}, {log = {desc = "itemConvertSpecial", int1 = itemId, int2 = itemData.type}}) + + SendPacket(actionCodes.Role_itemConvertSpecialRpc, MsgPack.pack(role:packReward(reward))) return true end -- libgit2 0.21.2